Method | Description | |
---|---|---|
apply ( grafika\ImageInterface &$image, grafika\FilterInterface $filter ) : grafika\EditorInterface | Apply a filter to the image. See Filters section for a list of available filters. | |
blend ( grafika\ImageInterface &$image1, grafika\ImageInterface $image2, string $type = 'normal', float $opacity = 1, string $position = 'top-left', integer $offsetX, integer $offsetY ) : grafika\EditorInterface | Blend two images together with the first image as the base and the second image on top. Supports several blend modes. | |
compare ( string | grafika\ImageInterface $image1, string | grafika\ImageInterface $image2 ) : integer | Compare two images and returns a hamming distance. A value of 0 indicates a likely similar picture. A value between 1 and 10 is potentially a variation. A value greater than 10 is likely a different image. | |
crop ( grafika\ImageInterface &$image, integer $cropWidth, integer $cropHeight, string $position = 'center', integer $offsetX, integer $offsetY ) : grafika\EditorInterface | Crop the image to the given dimension and position. | |
draw ( grafika\ImageInterface &$image, grafika\DrawingObjectInterface $drawingObject ) : grafika\EditorInterface | Draw a DrawingObject on the image. See Drawing Objects section. | |
equal ( string | grafika\ImageInterface $image1, string | grafika\ImageInterface $image2 ) : boolean | Compare if two images are equal. It will compare if the two images are of the same width and height. If the dimensions differ, it will return false. If the dimensions are equal, it will loop through each pixels. If one of the pixel don't match, it will return false. The pixels are compared using their RGB (Red, Green, Blue) values. | |
fill ( grafika\ImageInterface &$image, |
Fill entire image with color. | |
flatten ( grafika\ImageInterface &$image ) : grafika\EditorInterface | Flatten if animated GIF. Do nothing otherwise. | |
flip ( grafika\ImageInterface &$image, string $mode ) : grafika\EditorInterface | Flip an image. | |
free ( grafika\ImageInterface &$image ) : grafika\EditorInterface | Free the image clearing resources associated with it. | |
isAvailable ( ) : boolean | Checks the PHP install if the editor is available. | |
opacity ( grafika\ImageInterface &$image, float $opacity ) : grafika\EditorInterface | Change the image opacity. | |
open ( grafika\ImageInterface &$image, string $imageFile ) : grafika\EditorInterface | Open an image file and assign Image to first parameter. Grafika officially supports JPEG, PNG, GIF, and animated GIF. In theory, Grafika can open and edit other image formats as long as they are supported by GD and Imagick but it is currently untested. | |
resize ( grafika\ImageInterface &$image, integer $newWidth, integer $newHeight, string $mode = 'fit' ) : grafika\EditorInterface | Wrapper function for the resizeXXX family of functions. Resize an image to a given width, height and mode. | |
resizeExact ( grafika\ImageInterface &$image, integer $newWidth, integer $newHeight ) : grafika\EditorInterface | Resize image to exact dimensions ignoring aspect ratio. Useful if you want to force exact width and height. | |
resizeExactHeight ( grafika\ImageInterface &$image, integer $newHeight ) : grafika\EditorInterface | Resize image to exact height. Width is auto calculated. Useful for creating row of images with the same height. | |
resizeExactWidth ( grafika\ImageInterface &$image, integer $newWidth ) : grafika\EditorInterface | Resize image to exact width. Height is auto calculated. Useful for creating column of images with the same width. | |
resizeFill ( grafika\ImageInterface &$image, integer $newWidth, integer $newHeight ) : grafika\EditorInterface | Resize image to fill all the space in the given dimension. Excess parts are cropped. | |
resizeFit ( grafika\ImageInterface &$image, integer $newWidth, integer $newHeight ) : grafika\EditorInterface | Resize an image to fit within the given width and height. The re-sized image will not exceed the given dimension. Useful if you want to preserve the aspect ratio. | |
rotate ( grafika\ImageInterface &$image, integer $angle, |
Rotate an image counter-clockwise. | |
save ( grafika\ImageInterface $image, string $file, null | string $type = null, null | string $quality = null, boolean $interlace = false, integer $permission = 493 ) : grafika\EditorInterface | Save the image to an image format. | |
text ( grafika\ImageInterface &$image, string $text, integer $size = 12, integer $x, integer $y = 12, |
Write text to image. |
public apply ( grafika\ImageInterface &$image, grafika\FilterInterface $filter ) : grafika\EditorInterface | ||
$image | grafika\ImageInterface | Instance of Image. |
$filter | grafika\FilterInterface | Instance implementing the FilterInterface. |
return | grafika\EditorInterface | An instance of Editor. |
public blend ( grafika\ImageInterface &$image1, grafika\ImageInterface $image2, string $type = 'normal', float $opacity = 1, string $position = 'top-left', integer $offsetX, integer $offsetY ) : grafika\EditorInterface | ||
$image1 | grafika\ImageInterface | The base image. |
$image2 | grafika\ImageInterface | The image placed on top of the base image. |
$type | string | The blend mode. Can be: normal, multiply, overlay or screen. |
$opacity | float | The opacity of $image2. Possible values 0.0 to 1.0 where 0.0 is fully transparent and 1.0 is fully opaque. Defaults to 1.0. |
$position | string | The position of $image2 on $image1. Possible values top-left, top-center, top-right, center-left, center, center-right, bottom-left, bottom-center, bottom-right and smart. Defaults to top-left. |
$offsetX | integer | Number of pixels to add to the X position of $image2. |
$offsetY | integer | Number of pixels to add to the Y position of $image2. |
return | grafika\EditorInterface | An instance of Editor. |
public compare ( string | grafika\ImageInterface $image1, string | grafika\ImageInterface $image2 ) : integer | ||
$image1 | string | grafika\ImageInterface | Can be an instance of Image or string containing the file system path to image. |
$image2 | string | grafika\ImageInterface | Can be an instance of Image or string containing the file system path to image. |
return | integer | Hamming distance. Note: This breaks the chain if you are doing fluent api calls as it does not return an Editor. |
public crop ( grafika\ImageInterface &$image, integer $cropWidth, integer $cropHeight, string $position = 'center', integer $offsetX, integer $offsetY ) : grafika\EditorInterface | ||
$image | grafika\ImageInterface | Instance of Image. |
$cropWidth | integer | Crop width in pixels. |
$cropHeight | integer | Crop Height in pixels. |
$position | string | The crop position. Possible values top-left, top-center, top-right, center-left, center, center-right, bottom-left, bottom-center, bottom-right and smart. Defaults to center. |
$offsetX | integer | Number of pixels to add to the X position of the crop. |
$offsetY | integer | Number of pixels to add to the Y position of the crop. |
return | grafika\EditorInterface | An instance of Editor. |
public draw ( grafika\ImageInterface &$image, grafika\DrawingObjectInterface $drawingObject ) : grafika\EditorInterface | ||
$image | grafika\ImageInterface | Instance of Image. |
$drawingObject | grafika\DrawingObjectInterface | Instance of DrawingObject. |
return | grafika\EditorInterface | An instance of Editor. |
public equal ( string | grafika\ImageInterface $image1, string | grafika\ImageInterface $image2 ) : boolean | ||
$image1 | string | grafika\ImageInterface | Can be an instance of Image or string containing the file system path to image. |
$image2 | string | grafika\ImageInterface | Can be an instance of Image or string containing the file system path to image. |
return | boolean | True if equals false if not. Note: This breaks the chain if you are doing fluent api calls as it does not return an Editor. |
public fill ( grafika\ImageInterface &$image, |
||
$image | grafika\ImageInterface | Instance of Image. |
$color | An instance of Grafika\Color class. | |
$x | integer | X-coordinate of start point. |
$y | integer | Y-coordinate of start point. |
return | grafika\EditorInterface | An instance of Editor. |
public flatten ( grafika\ImageInterface &$image ) : grafika\EditorInterface | ||
$image | grafika\ImageInterface | Instance of Image. |
return | grafika\EditorInterface | An instance of Editor. |
public free ( grafika\ImageInterface &$image ) : grafika\EditorInterface | ||
$image | grafika\ImageInterface | Instance of Image. |
return | grafika\EditorInterface | An instance of Editor. |
public isAvailable ( ) : boolean | ||
return | boolean | True if available false if not. |
public resize ( grafika\ImageInterface &$image, integer $newWidth, integer $newHeight, string $mode = 'fit' ) : grafika\EditorInterface | ||
$image | grafika\ImageInterface | Instance of Image. |
$newWidth | integer | Width in pixels. |
$newHeight | integer | Height in pixels. |
$mode | string | Resize mode. Possible values: "exact", "exactHeight", "exactWidth", "fill", "fit". |
return | grafika\EditorInterface | An instance of Editor. |
public resizeExact ( grafika\ImageInterface &$image, integer $newWidth, integer $newHeight ) : grafika\EditorInterface | ||
$image | grafika\ImageInterface | Instance of Image. |
$newWidth | integer | Width in pixels. |
$newHeight | integer | Height in pixels. |
return | grafika\EditorInterface | An instance of Editor. |
public resizeExactHeight ( grafika\ImageInterface &$image, integer $newHeight ) : grafika\EditorInterface | ||
$image | grafika\ImageInterface | Instance of Image. |
$newHeight | integer | Height in pixels. |
return | grafika\EditorInterface | An instance of Editor. |
public resizeExactWidth ( grafika\ImageInterface &$image, integer $newWidth ) : grafika\EditorInterface | ||
$image | grafika\ImageInterface | Instance of Image. |
$newWidth | integer | Width in pixels. |
return | grafika\EditorInterface | An instance of Editor. |
public resizeFill ( grafika\ImageInterface &$image, integer $newWidth, integer $newHeight ) : grafika\EditorInterface | ||
$image | grafika\ImageInterface | Instance of Image. |
$newWidth | integer | Width in pixels. |
$newHeight | integer | Height in pixels. |
return | grafika\EditorInterface | An instance of Editor. |
public rotate ( grafika\ImageInterface &$image, integer $angle, |
||
$image | grafika\ImageInterface | Instance of Image. |
$angle | integer | The angle in degrees. |
$color | The Color object containing the background color. | |
return | grafika\EditorInterface | An instance of Editor. |
public save ( grafika\ImageInterface $image, string $file, null | string $type = null, null | string $quality = null, boolean $interlace = false, integer $permission = 493 ) : grafika\EditorInterface | ||
$image | grafika\ImageInterface | Instance of Image. Saving the image to a different format will have NO effect on the Image instance. |
$file | string | File path where to save the image. |
$type | null | string | The image format to use. Can be null, "gif", "png", or "jpeg". If null, an appropriate format will be chosen based on the output file name in $file. |
$quality | null | string | Quality of image. Applies to JPEG only. Accepts number 0 - 100 where 0 is lowest and 100 is the highest quality. Or null for default. Default quality if null is 75. |
$interlace | boolean | Set to true for progressive JPEG. Applies to JPEG only. Default false. |
$permission | integer | Default permission when creating non-existing target directory. Default is 0755. Note: Its using PHP's octal notation so you must prepend numbers with zero (0). |
return | grafika\EditorInterface | An instance of Editor. |
public text ( grafika\ImageInterface &$image, string $text, integer $size = 12, integer $x, integer $y = 12, |
||
$image | grafika\ImageInterface | Instance of Image. |
$text | string | The text to be written. |
$size | integer | The font size. Defaults to 12. |
$x | integer | The distance from the left edge of the image to the left of the text. Defaults to 0. |
$y | integer | The distance from the top edge of the image to the baseline of the text. Defaults to 12 (equal to font size) so that the text is placed within the image. |
$color | The Color object. Default text color is black. | |
$font | string | Full path to font file. If blank, will default to Liberation Sans font. |
$angle | integer | Angle of text from 0 - 359. Defaults to 0. |
return | grafika\EditorInterface | An instance of Editor. |