PHP 인터페이스 Grafika\EditorInterface

파일 보기 프로젝트 열기: kosinix/grafika

공개 메소드들

메소드 설명
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, Color $color, integer $x, integer $y ) : grafika\EditorInterface 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, Color | null $color = null ) : grafika\EditorInterface 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, Color $color = null, string $font = '', integer $angle ) : grafika\EditorInterface Write text to image.

메소드 상세

apply() 공개 메소드

Apply a filter to the image. See Filters section for a list of available filters.
public apply ( grafika\ImageInterface &$image, grafika\FilterInterface $filter ) : grafika\EditorInterface
$image grafika\ImageInterface Instance of Image.
$filter grafika\FilterInterface Instance implementing the FilterInterface.
리턴 grafika\EditorInterface An instance of Editor.

blend() 공개 메소드

Blend two images together with the first image as the base and the second image on top. Supports several blend modes.
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.
리턴 grafika\EditorInterface An instance of Editor.

compare() 공개 메소드

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.
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.
리턴 integer Hamming distance. Note: This breaks the chain if you are doing fluent api calls as it does not return an Editor.

crop() 공개 메소드

Crop the image to the given dimension and position.
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.
리턴 grafika\EditorInterface An instance of Editor.

draw() 공개 메소드

Draw a DrawingObject on the image. See Drawing Objects section.
public draw ( grafika\ImageInterface &$image, grafika\DrawingObjectInterface $drawingObject ) : grafika\EditorInterface
$image grafika\ImageInterface Instance of Image.
$drawingObject grafika\DrawingObjectInterface Instance of DrawingObject.
리턴 grafika\EditorInterface An instance of Editor.

equal() 공개 메소드

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.
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.
리턴 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.

fill() 공개 메소드

Fill entire image with color.
public fill ( grafika\ImageInterface &$image, Color $color, integer $x, integer $y ) : grafika\EditorInterface
$image grafika\ImageInterface Instance of Image.
$color Color An instance of Grafika\Color class.
$x integer X-coordinate of start point.
$y integer Y-coordinate of start point.
리턴 grafika\EditorInterface An instance of Editor.

flatten() 공개 메소드

Flatten if animated GIF. Do nothing otherwise.
public flatten ( grafika\ImageInterface &$image ) : grafika\EditorInterface
$image grafika\ImageInterface Instance of Image.
리턴 grafika\EditorInterface An instance of Editor.

flip() 공개 메소드

Flip an image.
public flip ( grafika\ImageInterface &$image, string $mode ) : grafika\EditorInterface
$image grafika\ImageInterface Instance of Image.
$mode string The type of flip: 'h' for horizontal flip or 'v' for vertical.
리턴 grafika\EditorInterface An instance of Editor.

free() 공개 메소드

Free the image clearing resources associated with it.
public free ( grafika\ImageInterface &$image ) : grafika\EditorInterface
$image grafika\ImageInterface Instance of Image.
리턴 grafika\EditorInterface An instance of Editor.

isAvailable() 공개 메소드

Checks the PHP install if the editor is available.
public isAvailable ( ) : boolean
리턴 boolean True if available false if not.

opacity() 공개 메소드

Change the image opacity.
public opacity ( grafika\ImageInterface &$image, float $opacity ) : grafika\EditorInterface
$image grafika\ImageInterface Instance of Image.
$opacity float The opacity level where 1.0 is fully opaque and 0.0 is fully transparent.
리턴 grafika\EditorInterface An instance of Editor.

open() 공개 메소드

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.
public open ( grafika\ImageInterface &$image, string $imageFile ) : grafika\EditorInterface
$image grafika\ImageInterface Instance of Image.
$imageFile string File system path to image file.
리턴 grafika\EditorInterface An instance of Editor.

resize() 공개 메소드

Wrapper function for the resizeXXX family of functions. Resize an image to a given width, height and mode.
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".
리턴 grafika\EditorInterface An instance of Editor.

resizeExact() 공개 메소드

Resize image to exact dimensions ignoring aspect ratio. Useful if you want to force exact width and height.
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.
리턴 grafika\EditorInterface An instance of Editor.

resizeExactHeight() 공개 메소드

Resize image to exact height. Width is auto calculated. Useful for creating row of images with the same height.
public resizeExactHeight ( grafika\ImageInterface &$image, integer $newHeight ) : grafika\EditorInterface
$image grafika\ImageInterface Instance of Image.
$newHeight integer Height in pixels.
리턴 grafika\EditorInterface An instance of Editor.

resizeExactWidth() 공개 메소드

Resize image to exact width. Height is auto calculated. Useful for creating column of images with the same width.
public resizeExactWidth ( grafika\ImageInterface &$image, integer $newWidth ) : grafika\EditorInterface
$image grafika\ImageInterface Instance of Image.
$newWidth integer Width in pixels.
리턴 grafika\EditorInterface An instance of Editor.

resizeFill() 공개 메소드

Resize image to fill all the space in the given dimension. Excess parts are cropped.
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.
리턴 grafika\EditorInterface An instance of Editor.

resizeFit() 공개 메소드

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.
public resizeFit ( grafika\ImageInterface &$image, integer $newWidth, integer $newHeight ) : grafika\EditorInterface
$image grafika\ImageInterface Instance of Image.
$newWidth integer Width in pixels.
$newHeight integer Width in pixels.
리턴 grafika\EditorInterface An instance of Editor.

rotate() 공개 메소드

Rotate an image counter-clockwise.
public rotate ( grafika\ImageInterface &$image, integer $angle, Color | null $color = null ) : grafika\EditorInterface
$image grafika\ImageInterface Instance of Image.
$angle integer The angle in degrees.
$color Color | null The Color object containing the background color.
리턴 grafika\EditorInterface An instance of Editor.

save() 공개 메소드

Save the image to an image format.
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).
리턴 grafika\EditorInterface An instance of Editor.

text() 공개 메소드

Write text to image.
public text ( grafika\ImageInterface &$image, string $text, integer $size = 12, integer $x, integer $y = 12, Color $color = null, string $font = '', integer $angle ) : grafika\EditorInterface
$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 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.
리턴 grafika\EditorInterface An instance of Editor.