PHP 클래스 Grafika\Gd\Editor

상속: implements Grafika\EditorInterface
파일 보기 프로젝트 열기: kosinix/grafika 1 사용 예제들

공개 메소드들

메소드 설명
apply ( Image &$image, Grafika\FilterInterface $filter ) : Editor Apply a filter to the image. See Filters section for a list of available filters.
blend ( Image &$image1, Image $image2, string $type = 'normal', float $opacity = 1, string $position = 'top-left', integer $offsetX, integer $offsetY ) : Editor Blend two images together with the first image as the base and the second image on top. Supports several blend modes.
compare ( Grafika\ImageInterface | string $image1, Grafika\ImageInterface | string $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 ( Image &$image, integer $cropWidth, integer $cropHeight, string $position = 'center', integer $offsetX, integer $offsetY ) : Editor Crop the image to the given dimension and position.
draw ( Image &$image, Grafika\DrawingObjectInterface $drawingObject ) 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 ( Image &$image, Color $color, integer $x, integer $y ) : Editor Fill entire image with color.
flatten ( Image &$image ) : Editor Flatten if animated GIF. Do nothing otherwise.
flip ( Image &$image, string $mode ) : Editor Flip or mirrors the image.
free ( Image &$image ) : Editor Free the image clearing resources associated with it.
gdAlpha ( float $alpha ) : integer Convert alpha value of 0 - 1 to GD compatible alpha value of 0 - 127 where 0 is opaque and 127 is transparent
isAvailable ( ) : boolean Checks if the editor is available on the current PHP install.
opacity ( Image &$image, float $opacity ) : Editor Sets the image to the specified opacity level where 1.0 is fully opaque and 0.0 is fully transparent.
open ( Image &$image, string $imageFile ) : Editor Open an image file and assign Image to first parameter.
resize ( Image &$image, integer $newWidth, integer $newHeight, string $mode = 'fit' ) : Editor Wrapper function for the resizeXXX family of functions. Resize image given width, height and mode.
resizeExact ( Image &$image, integer $newWidth, integer $newHeight ) : Editor Resize image to exact dimensions ignoring aspect ratio. Useful if you want to force exact width and height.
resizeExactHeight ( Image &$image, integer $newHeight ) : Editor Resize image to exact height. Width is auto calculated. Useful for creating row of images with the same height.
resizeExactWidth ( Image &$image, integer $newWidth ) : Editor Resize image to exact width. Height is auto calculated. Useful for creating column of images with the same width.
resizeFill ( Image &$image, integer $newWidth, integer $newHeight ) : Editor Resize image to fill all the space in the given dimension. Excess parts are cropped.
resizeFit ( Image &$image, integer $newWidth, integer $newHeight ) : Editor Resize image to fit inside the given dimension. No part of the image is lost.
rotate ( Image &$image, integer $angle, Color | null $color = null ) : Grafika\EditorInterface Rotate an image counter-clockwise.
save ( Image $image, string $file, null | string $type = null, null | string $quality = null, boolean | false $interlace = false, integer $permission = 493 ) : Editor Save the image to an image format.
text ( Image &$image, string $text, integer $size = 12, integer $x, integer $y, Color $color = null, string $font = '', integer $angle ) : Grafika\EditorInterface Write text to image.

비공개 메소드들

메소드 설명
_blendMultiply ( $canvas, $gd1, $gd2, $loopStartY, $loopEndY, $loopStartX, $loopEndX, $offsetX, $offsetY, $opacity )
_blendOverlay ( $canvas, $gd1, $gd2, $loopStartY, $loopEndY, $loopStartX, $loopEndX, $offsetX, $offsetY, $opacity )
_blendScreen ( $canvas, $gd1, $gd2, $loopStartY, $loopEndY, $loopStartX, $loopEndX, $offsetX, $offsetY, $opacity )
_entropy ( $hist ) : float | integer Calculate entropy based on histogram.
_flip ( Image $image, $mode ) : Image Flips image.
_getImageTypeFromFileName ( integer $imageFile ) : ImageType Get image type base on file extension.
_resize ( Image &$image, integer $newWidth, integer $newHeight, integer $targetX, integer $targetY, integer $srcX, integer $srcY ) Resize helper function.
_smartCrop ( Image $oldImage, $cropW, $cropH ) : array Crop based on entropy.

메소드 상세

apply() 공개 메소드

Apply a filter to the image. See Filters section for a list of available filters.
public apply ( Image &$image, Grafika\FilterInterface $filter ) : Editor
$image Image
$filter Grafika\FilterInterface
리턴 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 ( Image &$image1, Image $image2, string $type = 'normal', float $opacity = 1, string $position = 'top-left', integer $offsetX, integer $offsetY ) : Editor
$image1 Image The base image.
$image2 Image 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.
리턴 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 ( Grafika\ImageInterface | string $image1, Grafika\ImageInterface | string $image2 ) : integer
$image1 Grafika\ImageInterface | string
$image2 Grafika\ImageInterface | string
리턴 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 ( Image &$image, integer $cropWidth, integer $cropHeight, string $position = 'center', integer $offsetX, integer $offsetY ) : Editor
$image 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.
리턴 Editor

draw() 공개 메소드

Draw a DrawingObject on the image. See Drawing Objects section.
public draw ( Image &$image, Grafika\DrawingObjectInterface $drawingObject )
$image Image
$drawingObject Grafika\DrawingObjectInterface

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 ( Image &$image, Color $color, integer $x, integer $y ) : Editor
$image Image
$color Grafika\Color Color object
$x integer X-coordinate of start point
$y integer Y-coordinate of start point
리턴 Editor

flatten() 공개 메소드

Flatten if animated GIF. Do nothing otherwise.
public flatten ( Image &$image ) : Editor
$image Image
리턴 Editor

flip() 공개 메소드

Flip or mirrors the image.
public flip ( Image &$image, string $mode ) : Editor
$image Image
$mode string The type of flip: 'h' for horizontal flip or 'v' for vertical.
리턴 Editor

free() 공개 메소드

Free the image clearing resources associated with it.
public free ( Image &$image ) : Editor
$image Image
리턴 Editor

gdAlpha() 공개 정적인 메소드

Convert alpha value of 0 - 1 to GD compatible alpha value of 0 - 127 where 0 is opaque and 127 is transparent
public static gdAlpha ( float $alpha ) : integer
$alpha float Alpha value of 0 - 1. Example: 0, 0.60, 0.9, 1
리턴 integer

isAvailable() 공개 메소드

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

opacity() 공개 메소드

Warning: This function loops thru each pixel manually which can be slow. Use sparingly.
public opacity ( Image &$image, float $opacity ) : Editor
$image Image
$opacity float
리턴 Editor

open() 공개 메소드

Open an image file and assign Image to first parameter.
public open ( Image &$image, string $imageFile ) : Editor
$image Image
$imageFile string
리턴 Editor

resize() 공개 메소드

Wrapper function for the resizeXXX family of functions. Resize image given width, height and mode.
public resize ( Image &$image, integer $newWidth, integer $newHeight, string $mode = 'fit' ) : Editor
$image Image
$newWidth integer Width in pixels.
$newHeight integer Height in pixels.
$mode string Resize mode. Possible values: "exact", "exactHeight", "exactWidth", "fill", "fit".
리턴 Editor

resizeExact() 공개 메소드

Resize image to exact dimensions ignoring aspect ratio. Useful if you want to force exact width and height.
public resizeExact ( Image &$image, integer $newWidth, integer $newHeight ) : Editor
$image Image
$newWidth integer Width in pixels.
$newHeight integer Height in pixels.
리턴 Editor

resizeExactHeight() 공개 메소드

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

resizeExactWidth() 공개 메소드

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

resizeFill() 공개 메소드

Resize image to fill all the space in the given dimension. Excess parts are cropped.
public resizeFill ( Image &$image, integer $newWidth, integer $newHeight ) : Editor
$image Image
$newWidth integer Width in pixels.
$newHeight integer Height in pixels.
리턴 Editor

resizeFit() 공개 메소드

Resize image to fit inside the given dimension. No part of the image is lost.
public resizeFit ( Image &$image, integer $newWidth, integer $newHeight ) : Editor
$image Image
$newWidth integer Width in pixels.
$newHeight integer Height in pixels.
리턴 Editor

rotate() 공개 메소드

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

save() 공개 메소드

Save the image to an image format.
public save ( Image $image, string $file, null | string $type = null, null | string $quality = null, boolean | false $interlace = false, integer $permission = 493 ) : Editor
$image Image
$file string File path where to save the image.
$type null | string Type of image. Can be null, "GIF", "PNG", or "JPEG".
$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.
$interlace boolean | false Set to true for progressive JPEG. Applies to JPEG only.
$permission integer Default permission when creating non-existing target directory.
리턴 Editor

text() 공개 메소드

Write text to image.
public text ( Image &$image, string $text, integer $size = 12, integer $x, integer $y, Color $color = null, string $font = '', integer $angle ) : Grafika\EditorInterface
$image 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 top of the text. Defaults to 12 (equal to font size) so that the text is placed within the image.
$color Grafika\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