PHP 클래스 yii\imagine\BaseImage

Do not use BaseImage. Use [[Image]] instead.
부터: 2.0
저자: Antonio Ramirez ([email protected])
저자: Qiang Xue ([email protected])
파일 보기 프로젝트 열기: yiisoft/yii2-imagine 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$driver the driver to use. This can be either a single driver name or an array of driver names. If the latter, the first available driver will be used.
$thumbnailBackgroundAlpha background alpha (transparency) to use when creating thumbnails in ImageInterface::THUMBNAIL_INSET mode with both width and height specified. Default is solid.
$thumbnailBackgroundColor background color to use when creating thumbnails in ImageInterface::THUMBNAIL_INSET mode with both width and height specified. Default is white.

공개 메소드들

메소드 설명
autorotate ( string | resource | Imagine\Image\ImageInterface $image, string $color = '000000' ) : Imagine\Image\ImageInterface Rotates an image automatically based on EXIF information.
crop ( string | resource | Imagine\Image\ImageInterface $image, integer $width, integer $height, array $start = [0, 0] ) : Imagine\Image\ImageInterface Crops an image.
frame ( string | resource | Imagine\Image\ImageInterface $image, integer $margin = 20, string $color = '666', integer $alpha = 100 ) : Imagine\Image\ImageInterface Adds a frame around of the image. Please note that the image size will increase by $margin x 2.
getImagine ( ) : Imagine\Image\ImagineInterface Returns the Imagine object that supports various image manipulations.
resize ( string | resource | Imagine\Image\ImageInterface $image, integer $width, integer $height, boolean $keepAspectRatio = true, boolean $allowUpscaling = false ) : Imagine\Image\ImageInterface Resizes an image.
setImagine ( Imagine\Image\ImagineInterface $imagine )
text ( string | resource | Imagine\Image\ImageInterface $image, string $text, string $fontFile, array $start = [0, 0], array $fontOptions = [] ) : Imagine\Image\ImageInterface Draws a text string on an existing image.
thumbnail ( string | resource | Imagine\Image\ImageInterface $image, integer $width, integer $height, string $mode = ManipulatorInterface::THUMBNAIL_OUTBOUND ) : Imagine\Image\ImageInterface Creates a thumbnail image.
watermark ( string | resource | Imagine\Image\ImageInterface $image, string | resource | Imagine\Image\ImageInterface $watermarkImage, array $start = [0, 0] ) : Imagine\Image\ImageInterface Adds a watermark to an existing image.

보호된 메소드들

메소드 설명
createImagine ( ) : Imagine\Image\ImagineInterface Creates an Imagine object based on the specified [[driver]].
ensureImageInterfaceInstance ( string | resource | Imagine\Image\ImageInterface $image ) : Imagine\Image\ImageInterface Takes either file path or ImageInterface. In case of file path, creates an instance of ImageInterface from it.
getBox ( Imagine\Image\BoxInterface $sourceBox, integer $width, integer $height, boolean $keepAspectRatio = true ) : Imagine\Image\BoxInterface Returns box for an image to be created.
getThumbnailBox ( Imagine\Image\BoxInterface $sourceBox, integer $width, integer $height ) : Imagine\Image\BoxInterface Returns box for a thumbnail to be created. If one of the dimensions is set to null, another one is calculated automatically based on width to height ratio of original image box.
isUpscaling ( Imagine\Image\BoxInterface $sourceBox, Imagine\Image\BoxInterface $destinationBox ) : boolean Checks if upscaling is going to happen

메소드 상세

autorotate() 공개 정적인 메소드

Rotates an image automatically based on EXIF information.
부터: 2.1.0
public static autorotate ( string | resource | Imagine\Image\ImageInterface $image, string $color = '000000' ) : Imagine\Image\ImageInterface
$image string | resource | Imagine\Image\ImageInterface either ImageInterface, resource or a string containing file path
$color string
리턴 Imagine\Image\ImageInterface

createImagine() 보호된 정적인 메소드

Creates an Imagine object based on the specified [[driver]].
protected static createImagine ( ) : Imagine\Image\ImagineInterface
리턴 Imagine\Image\ImagineInterface the new `Imagine` object

crop() 공개 정적인 메소드

For example, ~~~ $obj->crop('path\to\image.jpg', 200, 200, [5, 5]); $point = new \Imagine\Image\Point(5, 5); $obj->crop('path\to\image.jpg', 200, 200, $point); ~~~
public static crop ( string | resource | Imagine\Image\ImageInterface $image, integer $width, integer $height, array $start = [0, 0] ) : Imagine\Image\ImageInterface
$image string | resource | Imagine\Image\ImageInterface either ImageInterface, resource or a string containing file path
$width integer the crop width
$height integer the crop height
$start array the starting point. This must be an array with two elements representing `x` and `y` coordinates.
리턴 Imagine\Image\ImageInterface

ensureImageInterfaceInstance() 보호된 정적인 메소드

Takes either file path or ImageInterface. In case of file path, creates an instance of ImageInterface from it.
부터: 2.1.0
protected static ensureImageInterfaceInstance ( string | resource | Imagine\Image\ImageInterface $image ) : Imagine\Image\ImageInterface
$image string | resource | Imagine\Image\ImageInterface
리턴 Imagine\Image\ImageInterface

frame() 공개 정적인 메소드

Adds a frame around of the image. Please note that the image size will increase by $margin x 2.
public static frame ( string | resource | Imagine\Image\ImageInterface $image, integer $margin = 20, string $color = '666', integer $alpha = 100 ) : Imagine\Image\ImageInterface
$image string | resource | Imagine\Image\ImageInterface either ImageInterface, resource or a string containing file path
$margin integer the frame size to add around the image
$color string the frame color
$alpha integer the alpha value of the frame.
리턴 Imagine\Image\ImageInterface

getBox() 보호된 정적인 메소드

If one of the dimensions is set to null, another one is calculated automatically based on width to height ratio of original image box. If both of the dimensions are set then new dimensions are calculated so that image keeps aspect ratio. You can set $keepAspectRatio to false if you want to force fixed width and height.
부터: 2.1.1
protected static getBox ( Imagine\Image\BoxInterface $sourceBox, integer $width, integer $height, boolean $keepAspectRatio = true ) : Imagine\Image\BoxInterface
$sourceBox Imagine\Image\BoxInterface original image box
$width integer new image width
$height integer new image height
$keepAspectRatio boolean should we keep aspect ratio even if both with and height are set
리턴 Imagine\Image\BoxInterface new image box

getImagine() 공개 정적인 메소드

Returns the Imagine object that supports various image manipulations.
public static getImagine ( ) : Imagine\Image\ImagineInterface
리턴 Imagine\Image\ImagineInterface the `Imagine` object

getThumbnailBox() 보호된 정적인 메소드

Returns box for a thumbnail to be created. If one of the dimensions is set to null, another one is calculated automatically based on width to height ratio of original image box.
부터: 2.0.4
protected static getThumbnailBox ( Imagine\Image\BoxInterface $sourceBox, integer $width, integer $height ) : Imagine\Image\BoxInterface
$sourceBox Imagine\Image\BoxInterface original image box
$width integer thumbnail width
$height integer thumbnail height
리턴 Imagine\Image\BoxInterface thumbnail box

isUpscaling() 보호된 정적인 메소드

Checks if upscaling is going to happen
protected static isUpscaling ( Imagine\Image\BoxInterface $sourceBox, Imagine\Image\BoxInterface $destinationBox ) : boolean
$sourceBox Imagine\Image\BoxInterface
$destinationBox Imagine\Image\BoxInterface
리턴 boolean

resize() 공개 정적인 메소드

If one of the dimensions is set to null, another one is calculated automatically based on aspect ratio of original image. If both of the dimensions are set then new dimensions are calculated so that image keeps aspect ratio. You can set $keepAspectRatio to false if you want to force fixed width and height.
부터: 2.1.1
public static resize ( string | resource | Imagine\Image\ImageInterface $image, integer $width, integer $height, boolean $keepAspectRatio = true, boolean $allowUpscaling = false ) : Imagine\Image\ImageInterface
$image string | resource | Imagine\Image\ImageInterface either ImageInterface, resource or a string containing file path
$width integer the width in pixels
$height integer the height in pixels
$keepAspectRatio boolean should the image keep aspect ratio
$allowUpscaling boolean should the image be upscaled if needed
리턴 Imagine\Image\ImageInterface

setImagine() 공개 정적인 메소드

public static setImagine ( Imagine\Image\ImagineInterface $imagine )
$imagine Imagine\Image\ImagineInterface the `Imagine` object.

text() 공개 정적인 메소드

Draws a text string on an existing image.
public static text ( string | resource | Imagine\Image\ImageInterface $image, string $text, string $fontFile, array $start = [0, 0], array $fontOptions = [] ) : Imagine\Image\ImageInterface
$image string | resource | Imagine\Image\ImageInterface either ImageInterface, resource or a string containing file path
$text string the text to write to the image
$fontFile string the file path or path alias
$start array the starting position of the text. This must be an array with two elements representing `x` and `y` coordinates.
$fontOptions array the font options. The following options may be specified: - color: The font color. Defaults to "fff". - size: The font size. Defaults to 12. - angle: The angle to use to write the text. Defaults to 0.
리턴 Imagine\Image\ImageInterface

thumbnail() 공개 정적인 메소드

If one of thumbnail dimensions is set to null, another one is calculated automatically based on aspect ratio of original image. Note that calculated thumbnail dimension may vary depending on the source image in this case. If both dimensions are specified, resulting thumbnail would be exactly the width and height specified. How it's achieved depends on the mode. If ImageInterface::THUMBNAIL_OUTBOUND mode is used, which is default, then the thumbnail is scaled so that its smallest side equals the length of the corresponding side in the original image. Any excess outside of the scaled thumbnail’s area will be cropped, and the returned thumbnail will have the exact width and height specified. If thumbnail mode is ImageInterface::THUMBNAIL_INSET, the original image is scaled down so it is fully contained within the thumbnail dimensions. The rest is filled with background that could be configured via [[Image::$thumbnailBackgroundColor]] and [[Image::$thumbnailBackgroundAlpha]].
public static thumbnail ( string | resource | Imagine\Image\ImageInterface $image, integer $width, integer $height, string $mode = ManipulatorInterface::THUMBNAIL_OUTBOUND ) : Imagine\Image\ImageInterface
$image string | resource | Imagine\Image\ImageInterface either ImageInterface, resource or a string containing file path
$width integer the width in pixels to create the thumbnail
$height integer the height in pixels to create the thumbnail
$mode string mode of resizing original image to use in case both width and height specified
리턴 Imagine\Image\ImageInterface

watermark() 공개 정적인 메소드

Adds a watermark to an existing image.
public static watermark ( string | resource | Imagine\Image\ImageInterface $image, string | resource | Imagine\Image\ImageInterface $watermarkImage, array $start = [0, 0] ) : Imagine\Image\ImageInterface
$image string | resource | Imagine\Image\ImageInterface either ImageInterface, resource or a string containing file path
$watermarkImage string | resource | Imagine\Image\ImageInterface either ImageInterface, resource or a string containing watermark file path
$start array the starting point. This must be an array with two elements representing `x` and `y` coordinates.
리턴 Imagine\Image\ImageInterface

프로퍼티 상세

$driver 공개적으로 정적으로 프로퍼티

the driver to use. This can be either a single driver name or an array of driver names. If the latter, the first available driver will be used.
public static $driver

$thumbnailBackgroundAlpha 공개적으로 정적으로 프로퍼티

background alpha (transparency) to use when creating thumbnails in ImageInterface::THUMBNAIL_INSET mode with both width and height specified. Default is solid.
부터: 2.0.4
public static $thumbnailBackgroundAlpha

$thumbnailBackgroundColor 공개적으로 정적으로 프로퍼티

background color to use when creating thumbnails in ImageInterface::THUMBNAIL_INSET mode with both width and height specified. Default is white.
부터: 2.0.4
public static $thumbnailBackgroundColor