EditorInterface
interface EditorInterface
Interface EditorInterface
Methods
Apply a filter to the image. See Filters section for a list of available filters.
Blend two images together with the first image as the base and the second image on top. Supports several blend modes.
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 the image to the given dimension and position.
Draw a DrawingObject on the image. See Drawing Objects section.
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.
Checks the PHP install if the editor is available.
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.
Wrapper function for the resizeXXX family of functions. Resize an image to a given width, height and mode.
Resize image to exact dimensions ignoring aspect ratio. Useful if you want to force exact width and height.
Resize image to exact height. Width is auto calculated. Useful for creating row of images with the same height.
Resize image to exact width. Height is auto calculated. Useful for creating column of images with the same width.
Resize image to fill all the space in the given dimension. Excess parts are cropped.
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 an image counter-clockwise.
Save the image to an image format.
Write text to image.
Details
at line line 18
EditorInterface
apply(ImageInterface $image, FilterInterface $filter)
Apply a filter to the image. See Filters section for a list of available filters.
at line line 33
EditorInterface
blend(ImageInterface $image1, ImageInterface $image2, string $type = 'normal', float $opacity = 1.0, string $position = 'top-left', int $offsetX, int $offsetY)
Blend two images together with the first image as the base and the second image on top. Supports several blend modes.
at line line 44
int
compare(string|ImageInterface $image1, string|ImageInterface $image2)
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.
at line line 58
EditorInterface
crop(ImageInterface $image, int $cropWidth, int $cropHeight, string $position = 'center', int $offsetX, int $offsetY)
Crop the image to the given dimension and position.
at line line 68
EditorInterface
draw(ImageInterface $image, DrawingObjectInterface $drawingObject)
Draw a DrawingObject on the image. See Drawing Objects section.
at line line 79
bool
equal(string|ImageInterface $image1, string|ImageInterface $image2)
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.
at line line 91
EditorInterface
fill(ImageInterface $image, Color $color, int $x, int $y)
Fill entire image with color.
at line line 100
EditorInterface
flatten(ImageInterface $image)
Flatten if animated GIF. Do nothing otherwise.
at line line 110
EditorInterface
flip(ImageInterface $image, string $mode)
Flip an image.
at line line 119
EditorInterface
free(ImageInterface $image)
Free the image clearing resources associated with it.
at line line 126
bool
isAvailable()
Checks the PHP install if the editor is available.
at line line 136
EditorInterface
opacity(ImageInterface $image, float $opacity)
Change the image opacity.
at line line 146
EditorInterface
open(ImageInterface $image, string $imageFile)
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.
at line line 158
EditorInterface
resize(ImageInterface $image, int $newWidth, int $newHeight, string $mode = 'fit')
Wrapper function for the resizeXXX family of functions. Resize an image to a given width, height and mode.
at line line 169
EditorInterface
resizeExact(ImageInterface $image, int $newWidth, int $newHeight)
Resize image to exact dimensions ignoring aspect ratio. Useful if you want to force exact width and height.
at line line 179
EditorInterface
resizeExactHeight(ImageInterface $image, int $newHeight)
Resize image to exact height. Width is auto calculated. Useful for creating row of images with the same height.
at line line 189
EditorInterface
resizeExactWidth(ImageInterface $image, int $newWidth)
Resize image to exact width. Height is auto calculated. Useful for creating column of images with the same width.
at line line 200
EditorInterface
resizeFill(ImageInterface $image, int $newWidth, int $newHeight)
Resize image to fill all the space in the given dimension. Excess parts are cropped.
at line line 211
EditorInterface
resizeFit(ImageInterface $image, int $newWidth, int $newHeight)
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.
at line line 222
EditorInterface
rotate(ImageInterface $image, int $angle, Color|null $color = null)
Rotate an image counter-clockwise.
at line line 236
EditorInterface
save(ImageInterface $image, string $file, null|string $type = null, null|string $quality = null, bool $interlace = false, int $permission = 493)
Save the image to an image format.
at line line 253
EditorInterface
text(ImageInterface $image, string $text, int $size = 12, int $x, int $y = 12, Color $color = null, string $font = '', int $angle)
Write text to image.