Detailed Description
GraphicsUtil provides support for graphic manipulation.
- Note
- This class requires ImageWorkshop, GifFrameExtractor and GifCreator
Definition at line 34 of file GraphicsUtil.php.
Public Member Functions | |
getErrorMsg () | |
isImage ($imgname) | |
isValidImageDimension ($imgname, $width, $height, $exact=true) | |
isValidImageWidth ($imgname, $width, $exact=true) | |
isValidImageHeight ($imgname, $height, $exact=true) | |
fitIntoSquare ($srcName, $maxDimension) | |
createThumbnail ($srcName, $destName, $width, $height) | |
cropImage ($srcName, $destName, $width, $height, $x=null, $y=null) | |
createBlackWhiteImage ($srcName, $destName) | |
processImageFunction ($srcName, $destName, $function, $params) | |
renderText ($text, $fontfile, $fontsize, $color, $bgcolor, $filename, $width=null, $height=null, $x=null, $y=null, $angle=0) | |
Member Function Documentation
getErrorMsg | ( | ) |
isImage | ( | $imgname | ) |
Check if a given file is an image.
- Parameters
-
$imgname Name of the imagefile to check
- Returns
- Boolean whether the file is an image
Definition at line 51 of file GraphicsUtil.php.
isValidImageDimension | ( | $imgname, | |
$width, | |||
$height, | |||
$exact = true |
|||
) |
Check image dimensions.
- Parameters
-
$imgname Name of the imagefile to check $width Width of the image, -1 means don't care $height Height of the image, -1 means don't care $exact Boolean whether the image should match the dimension exactly or might be smaller (default: true)
- Returns
- Boolean whether the image meets the dimensions, error string provided by getErrorMsg()
Definition at line 68 of file GraphicsUtil.php.
isValidImageWidth | ( | $imgname, | |
$width, | |||
$exact = true |
|||
) |
Check image width.
- Parameters
-
$imgname Name of the imagefile to check $width Width of the image $exact Boolean whether the image width should match exactly or might be smaller (default: true)
- Returns
- Boolean whether the image width meets the criteria, error string provided by getErrorMsg()
- Note
- This method returns true if the file does not exist.
Definition at line 82 of file GraphicsUtil.php.
isValidImageHeight | ( | $imgname, | |
$height, | |||
$exact = true |
|||
) |
Check image height.
- Parameters
-
$imgname Name of the imagefile to check $height Height of the image $exact Boolean whether the image height should match exactly or might be smaller (default: true)
- Returns
- Boolean whether the image width meets the criteria, error string provided by getErrorMsg()
- Note
- This method returns true if the file does not exist.
Definition at line 108 of file GraphicsUtil.php.
fitIntoSquare | ( | $srcName, | |
$maxDimension | |||
) |
Calculate image dimension to fit into a square, preserving the aspect ratio.
- Parameters
-
$srcName The source file name $maxDimension The maximum dimension the image should have (either width or height)
- Returns
- Array with width and height value or null, on error, error string provided by getErrorMsg()
Definition at line 132 of file GraphicsUtil.php.
createThumbnail | ( | $srcName, | |
$destName, | |||
$width, | |||
$height | |||
) |
Create a thumbnail of an image file.
- Parameters
-
$srcName The source file name $destName The destination file name $width The width of the thumbnail (maybe null) $height The height of the thumbnail (maybe null)
- Returns
- Boolean whether the operation succeeded, error string provided by getErrorMsg()
- Note
- : supported image formats are GIF, JPG, PNG if only width or height are given the other dimension is calculated to preserve the aspect
Definition at line 167 of file GraphicsUtil.php.
cropImage | ( | $srcName, | |
$destName, | |||
$width, | |||
$height, | |||
$x = null , |
|||
$y = null |
|||
) |
Crop an image to the given size starting from the middle of a given start point.
- Parameters
-
$srcName The source file name $destName The destination file name $width The width of the cropped image (maybe null) $height The height of the cropped image (maybe null) $x The start point x coordinate (maybe null, default null) $y The start point y coordinate (maybe null, default null)
- Returns
- Boolean whether the operation succeeded, error string provided by getErrorMsg()
- Note
- : supported image formats are GIF, JPG, PNG if only width or height are given the other dimension is taken from the original image
Definition at line 190 of file GraphicsUtil.php.
createBlackWhiteImage | ( | $srcName, | |
$destName | |||
) |
Create a black and white copy of an image.
- Parameters
-
$srcName The source file name $destName The destination file name
Definition at line 211 of file GraphicsUtil.php.
processImageFunction | ( | $srcName, | |
$destName, | |||
$function, | |||
$params | |||
) |
Process the given function on the given source image (supports animated gifs) and save the result in the given destination image.
- Parameters
-
$srcName The source file name $destName The destination file name $function The name of the function $params The paremeters to be passed to the function
Definition at line 229 of file GraphicsUtil.php.
renderText | ( | $text, | |
$fontfile, | |||
$fontsize, | |||
$color, | |||
$bgcolor, | |||
$filename, | |||
$width = null , |
|||
$height = null , |
|||
$x = null , |
|||
$y = null , |
|||
$angle = 0 |
|||
) |
Render a text to an image.
Using the default parameters the text will be rendered into a box that fits the text. If the width parameter is not null and the text exceeds the width, the text will be wrapped and the height parameter will be used as lineheight. Wrapping code is from http://de.php.net/manual/de/function.imagettfbbox.php#60673
- Parameters
-
$text The text to render $fontfile The ttf font file to use $fontsize The font size to use (in pixels) $color The color to use for the text (as HEX value) $bgcolor The color to use for the background (as HEX value) $filename The name of the file to write to $width The width of the image (or null if it should fit the text) (default: null) $height The height of the image (or null if it should fit the text) (default: null) $x The x offset of the text (or null if it should be centered) (default: null) $y The y offset of the text (or null if the baseline should be the image border) (default: null) $angle The angle of the text (optional, default: 0)
- Returns
- Boolean whether the operation succeeded, error string provided by getErrorMsg()
Definition at line 272 of file GraphicsUtil.php.