to the image using TrueType * fonts. * * @param resource $image An image resource, returned by one of the image creation functions, * such as imagecreatetruecolor. * @param float $size The font size in points. * @param float $angle The angle in degrees, with 0 degrees being left-to-right reading text. * Higher values represent a counter-clockwise rotation. For example, a * value of 90 would result in bottom-to-top reading text. * @param int $x The coordinates given by x and * y will define the basepoint of the first * character (roughly the lower-left corner of the character). This * is different from the imagestring, where * x and y define the * upper-left corner of the first character. For example, "top left" * is 0, 0. * @param int $y The y-ordinate. This sets the position of the fonts baseline, not the * very bottom of the character. * @param int $color The color index. Using the negative of a color index has the effect of * turning off antialiasing. See imagecolorallocate. * @param string $fontfile The path to the TrueType font you wish to use. * * Depending on which version of the GD library PHP is using, when * fontfile does not begin with a leading * / then .ttf will be appended * to the filename and the library will attempt to search for that * filename along a library-defined font path. * * When using versions of the GD library lower than 2.0.18, a space character, * rather than a semicolon, was used as the 'path separator' for different font files. * Unintentional use of this feature will result in the warning message: * Warning: Could not find/open font. For these affected versions, the * only solution is moving the font to a path which does not contain spaces. * * In many cases where a font resides in the same directory as the script using it * the following trick will alleviate any include problems. * * * ]]> * * * Note that open_basedir does * not apply to fontfile. * @param string $text The text string in UTF-8 encoding. * * May include decimal numeric character references (of the form: * €) to access characters in a font beyond position 127. * The hexadecimal format (like ©) is supported. * Strings in UTF-8 encoding can be passed directly. * * Named entities, such as ©, are not supported. Consider using * html_entity_decode * to decode these named entities into UTF-8 strings. * * If a character is used in the string which is not supported by the * font, a hollow rectangle will replace the character. * @return array Returns an array with 8 elements representing four points making the * bounding box of the text. The order of the points is lower left, lower * right, upper right, upper left. The points are relative to the text * regardless of the angle, so "upper left" means in the top left-hand * corner when you see the text horizontally. * @throws ImageException * */ function imagettftext($image, float $size, float $angle, int $x, int $y, int $color, string $fontfile, string $text): array { error_clear_last(); $result = \imagettftext($image, $size, $angle, $x, $y, $color, $fontfile, $text); if ($result === false) { throw ImageException::createFromPhpError(); } return $result; }/** * imagewbmp outputs or save a WBMP * version of the given image. * * @param resource $image An image resource, returned by one of the image creation functions, * such as imagecreatetruecolor. * @param mixed $to The path or an open stream resource (which is automatically being closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be outputted directly. * @param int $foreground You can set the foreground color with this parameter by setting an * identifier obtained from imagecolorallocate. * The default foreground color is black. * @throws ImageException * */ function imagewbmp($image, $to = null, int $foreground = null): void { error_clear_last(); if ($foreground !== null) { $result = \imagewbmp($image, $to, $foreground); } else { $result = \imagewbmp($image, $to); } if ($result === false) { throw ImageException::createFromPhpError(); } }/** * Outputs or saves a WebP version of the given image. * * @param resource $image An image resource, returned by one of the image creation functions, * such as imagecreatetruecolor. * @param mixed $to The path or an open stream resource (which is automatically being closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be outputted directly. * @param int $quality quality ranges from 0 (worst * quality, smaller file) to 100 (best quality, biggest file). * @throws ImageException * */ function imagewebp($image, $to = null, int $quality = 80): void { error_clear_last(); $result = \imagewebp($image, $to, $quality); if ($result === false) { throw ImageException::createFromPhpError(); } }/** * Outputs or save an XBM version of the given * image. * * @param resource $image An image resource, returned by one of the image creation functions, * such as imagecreatetruecolor. * @param string|null $filename The path to save the file to, given as string. If NULL, the raw image stream will be output directly. * * The filename (without the .xbm extension) is also * used for the C identifiers of the XBM, whereby non * alphanumeric characters of the current locale are substituted by * underscores. If filename is set to NULL, * image is used to build the C identifiers. * @param int $foreground You can set the foreground color with this parameter by setting an * identifier obtained from imagecolorallocate. * The default foreground color is black. All other colors are treated as * background. * @throws ImageException * */ function imagexbm($image, ?string $filename, int $foreground = null): void { error_clear_last(); if ($foreground !== null) { $result = \imagexbm($image, $filename, $foreground); } else { $result = \imagexbm($image, $filename); } if ($result === false) { throw ImageException::createFromPhpError(); } }/** * Embeds binary IPTC data into a JPEG image. * * @param string $iptcdata The data to be written. * @param string $jpeg_file_name Path to the JPEG image. * @param int $spool Spool flag. If the spool flag is less than 2 then the JPEG will be * returned as a string. Otherwise the JPEG will be printed to STDOUT. * @return string|bool If spool is less than 2, the JPEG will be returned. Otherwise returns TRUE on success. * @throws ImageException * */ function iptcembed(string $iptcdata, string $jpeg_file_name, int $spool = 0) { error_clear_last(); $result = \iptcembed($iptcdata, $jpeg_file_name, $spool); if ($result === false) { throw ImageException::createFromPhpError(); } return $result; }/** * Parses an IPTC block into its single tags. * * @param string $iptcblock A binary IPTC block. * @return array Returns an array using the tagmarker as an index and the value as the * value. It returns FALSE on error or if no IPTC data was found. * @throws ImageException * */ function iptcparse(string $iptcblock): array { error_clear_last(); $result = \iptcparse($iptcblock); if ($result === false) { throw ImageException::createFromPhpError(); } return $result; }/** * Converts a JPEG file into a WBMP file. * * @param string $jpegname Path to JPEG file. * @param string $wbmpname Path to destination WBMP file. * @param int $dest_height Destination image height. * @param int $dest_width Destination image width. * @param int $threshold Threshold value, between 0 and 8 (inclusive). * @throws ImageException * */ function jpeg2wbmp(string $jpegname, string $wbmpname, int $dest_height, int $dest_width, int $threshold): void { error_clear_last(); $result = \jpeg2wbmp($jpegname, $wbmpname, $dest_height, $dest_width, $threshold); if ($result === false) { throw ImageException::createFromPhpError(); } }/** * Converts a PNG file into a WBMP file. * * @param string $pngname Path to PNG file. * @param string $wbmpname Path to destination WBMP file. * @param int $dest_height Destination image height. * @param int $dest_width Destination image width. * @param int $threshold Threshold value, between 0 and 8 (inclusive). * @throws ImageException * */ function png2wbmp(string $pngname, string $wbmpname, int $dest_height, int $dest_width, int $threshold): void { error_clear_last(); $result = \png2wbmp($pngname, $wbmpname, $dest_height, $dest_width, $threshold); if ($result === false) { throw ImageException::createFromPhpError(); } }