PHP 클래스 JBZoo\Image\Image

파일 보기 프로젝트 열기: JBZoo/Image 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_exif array
$_filename string
$_height integer
$_image mixed GD Resource
$_mime string
$_orient string
$_quality integer
$_width integer

공개 메소드들

메소드 설명
__construct ( string | null $filename = null, boolean | null $strict = false ) Constructor
__destruct ( ) Destroy image resource
addFilter ( string | callable $filter ) Add filter to current image
autoOrient ( ) Rotates and/or flips an image automatically so the orientation will be correct (based on exif 'Orientation')
bestFit ( integer $maxWidth, integer $maxHeight ) Best fit (proportionally resize to fit in specified width/height) Shrink the image proportionally to fit inside a $width x $height box
cleanup ( ) Clean whole image object
create ( integer $width, integer | null $height = null, null | string $color = null ) Create an image from scratch
crop ( integer $left, integer $top, integer $right, integer $bottom ) Crop an image
fitToHeight ( integer $height ) Fit to height (proportionally resize to specified height)
fitToWidth ( integer $width ) Fit to width (proportionally resize to specified width)
getBase64 ( null | string $format = 'gif', integer | null $quality = null, $addMime = true ) : string Outputs image as data base64 to use as img src
getBinary ( null | string $format = null, integer | null $quality = null ) : string Outputs image as binary data
getHeight ( ) : integer Get the current height
getImage ( ) : mixed Get the current image resource
getInfo ( ) : array
getPath ( ) : string Get relative path to image
getUrl ( ) : string Get full URL to image (if not CLI mode)
getWidth ( ) : integer Get the current width
isGif ( ) : boolean
isJpeg ( ) : boolean
isLandscape ( ) : boolean
isPng ( ) : boolean
isPortrait ( ) : boolean
isSquare ( ) : boolean
loadFile ( string $filename ) Load an image
loadResource ( mixed $imageRes ) Load image resource
loadString ( string $imageString, boolean | null $strict = false ) Load an image
overlay ( string | Image $overlay, string $position = 'bottom right', float | integer $opacity = 0.4, integer $globOffsetX, integer $globOffsetY ) Overlay an image on top of another, works with 24-bit PNG alpha-transparency
resize ( integer $width, integer $height ) Resize an image to the specified dimensions
save ( null | integer $quality = null ) Save an image The resulting format will be determined by the file extension.
saveAs ( string $filename, null | integer $quality = null ) Save an image The resulting format will be determined by the file extension.
setQuality ( integer $newQuality )
thumbnail ( integer $width, integer | null $height = null, boolean $topIsZero = false ) Thumbnail.

보호된 메소드들

메소드 설명
_destroyImage ( ) Destroy image resource if not empty
_getExif ( ) : array
_getOrientation ( ) : string Get the current orientation
_imageCreate ( string $format ) : resource Create image resource
_loadMeta ( null | string $image = null, boolean | null $strict = false ) Get meta data of image or base64 string
_renderBinary ( string $format, integer $quality ) : array
_renderImageByFormat ( string $format, string $filename, integer $quality ) : boolean | string Render image resource as binary
_replaceImage ( $newImage )
_save ( string $filename, integer $quality ) : boolean Save image to file
_saveGif ( string $filename ) : boolean
_saveJpeg ( string $filename, integer $quality ) : boolean
_savePng ( string $filename, integer $quality ) : boolean

메소드 상세

__construct() 공개 메소드

Constructor
public __construct ( string | null $filename = null, boolean | null $strict = false )
$filename string | null
$strict boolean | null

__destruct() 공개 메소드

Destroy image resource
public __destruct ( )

_destroyImage() 보호된 메소드

Destroy image resource if not empty
protected _destroyImage ( )

_getExif() 보호된 메소드

protected _getExif ( ) : array
리턴 array

_getOrientation() 보호된 메소드

Get the current orientation
protected _getOrientation ( ) : string
리턴 string portrait|landscape|square

_imageCreate() 보호된 메소드

Create image resource
protected _imageCreate ( string $format ) : resource
$format string
리턴 resource

_loadMeta() 보호된 메소드

Get meta data of image or base64 string
protected _loadMeta ( null | string $image = null, boolean | null $strict = false )
$image null | string
$strict boolean | null

_renderBinary() 보호된 메소드

protected _renderBinary ( string $format, integer $quality ) : array
$format string
$quality integer
리턴 array

_renderImageByFormat() 보호된 메소드

Render image resource as binary
protected _renderImageByFormat ( string $format, string $filename, integer $quality ) : boolean | string
$format string
$filename string
$quality integer
리턴 boolean | string

_replaceImage() 보호된 메소드

protected _replaceImage ( $newImage )
$newImage

_save() 보호된 메소드

Save image to file
protected _save ( string $filename, integer $quality ) : boolean
$filename string
$quality integer
리턴 boolean

_saveGif() 보호된 메소드

protected _saveGif ( string $filename ) : boolean
$filename string
리턴 boolean

_saveJpeg() 보호된 메소드

protected _saveJpeg ( string $filename, integer $quality ) : boolean
$filename string
$quality integer
리턴 boolean

_savePng() 보호된 메소드

protected _savePng ( string $filename, integer $quality ) : boolean
$filename string
$quality integer
리턴 boolean

addFilter() 공개 메소드

Add filter to current image
public addFilter ( string | callable $filter )
$filter string | callable

autoOrient() 공개 메소드

Rotates and/or flips an image automatically so the orientation will be correct (based on exif 'Orientation')
public autoOrient ( )

bestFit() 공개 메소드

Best fit (proportionally resize to fit in specified width/height) Shrink the image proportionally to fit inside a $width x $height box
public bestFit ( integer $maxWidth, integer $maxHeight )
$maxWidth integer
$maxHeight integer

cleanup() 공개 메소드

Clean whole image object
public cleanup ( )

create() 공개 메소드

Create an image from scratch
public create ( integer $width, integer | null $height = null, null | string $color = null )
$width integer Image width
$height integer | null If omitted - assumed equal to $width
$color null | string Hex color string, array(red, green, blue) or array(red, green, blue, alpha). Where red, green, blue - integers 0-255, alpha - integer 0-127

crop() 공개 메소드

Crop an image
public crop ( integer $left, integer $top, integer $right, integer $bottom )
$left integer Left
$top integer Top
$right integer Right
$bottom integer Bottom

fitToHeight() 공개 메소드

Fit to height (proportionally resize to specified height)
public fitToHeight ( integer $height )
$height integer

fitToWidth() 공개 메소드

Fit to width (proportionally resize to specified width)
public fitToWidth ( integer $width )
$width integer

getBase64() 공개 메소드

Outputs image as data base64 to use as img src
public getBase64 ( null | string $format = 'gif', integer | null $quality = null, $addMime = true ) : string
$format null | string If omitted or null - format of original file will be used, may be gif|jpg|png
$quality integer | null Output image quality in percents 0-100
리턴 string

getBinary() 공개 메소드

Outputs image as binary data
public getBinary ( null | string $format = null, integer | null $quality = null ) : string
$format null | string If omitted or null - format of original file will be used, may be gif|jpg|png
$quality integer | null Output image quality in percents 0-100
리턴 string

getHeight() 공개 메소드

Get the current height
public getHeight ( ) : integer
리턴 integer

getImage() 공개 메소드

Get the current image resource
public getImage ( ) : mixed
리턴 mixed

getInfo() 공개 메소드

public getInfo ( ) : array
리턴 array

getPath() 공개 메소드

Get relative path to image
public getPath ( ) : string
리턴 string

getUrl() 공개 메소드

Get full URL to image (if not CLI mode)
public getUrl ( ) : string
리턴 string

getWidth() 공개 메소드

Get the current width
public getWidth ( ) : integer
리턴 integer

isGif() 공개 메소드

public isGif ( ) : boolean
리턴 boolean

isJpeg() 공개 메소드

public isJpeg ( ) : boolean
리턴 boolean

isLandscape() 공개 메소드

public isLandscape ( ) : boolean
리턴 boolean

isPng() 공개 메소드

public isPng ( ) : boolean
리턴 boolean

isPortrait() 공개 메소드

public isPortrait ( ) : boolean
리턴 boolean

isSquare() 공개 메소드

public isSquare ( ) : boolean
리턴 boolean

loadFile() 공개 메소드

Load an image
public loadFile ( string $filename )
$filename string Path to image file

loadResource() 공개 메소드

Load image resource
public loadResource ( mixed $imageRes )
$imageRes mixed Image GD Resource

loadString() 공개 메소드

Load an image
public loadString ( string $imageString, boolean | null $strict = false )
$imageString string Binary images
$strict boolean | null

overlay() 공개 메소드

Overlay an image on top of another, works with 24-bit PNG alpha-transparency
public overlay ( string | Image $overlay, string $position = 'bottom right', float | integer $opacity = 0.4, integer $globOffsetX, integer $globOffsetY )
$overlay string | Image An image filename or a Image object
$position string center|top|left|bottom|right|top left|top right|bottom left|bottom right
$opacity float | integer Overlay opacity 0-1 or 0-100
$globOffsetX integer Horizontal offset in pixels
$globOffsetY integer Vertical offset in pixels

resize() 공개 메소드

Resize an image to the specified dimensions
public resize ( integer $width, integer $height )
$width integer
$height integer

save() 공개 메소드

Save an image The resulting format will be determined by the file extension.
public save ( null | integer $quality = null )
$quality null | integer Output image quality in percents 0-100

saveAs() 공개 메소드

Save an image The resulting format will be determined by the file extension.
public saveAs ( string $filename, null | integer $quality = null )
$filename string If omitted - original file will be overwritten
$quality null | integer Output image quality in percents 0-100

setQuality() 공개 메소드

public setQuality ( integer $newQuality )
$newQuality integer

thumbnail() 공개 메소드

This function attempts to get the image to as close to the provided dimensions as possible, and then crops the remaining overflow (from the center) to get the image to be the size specified. Useful for generating thumbnails.
public thumbnail ( integer $width, integer | null $height = null, boolean $topIsZero = false )
$width integer
$height integer | null If omitted - assumed equal to $width
$topIsZero boolean Force top offset = 0

프로퍼티 상세

$_exif 보호되어 있는 프로퍼티

protected array $_exif
리턴 array

$_filename 보호되어 있는 프로퍼티

protected string $_filename
리턴 string

$_height 보호되어 있는 프로퍼티

protected int $_height
리턴 integer

$_image 보호되어 있는 프로퍼티

GD Resource
protected mixed $_image
리턴 mixed

$_mime 보호되어 있는 프로퍼티

protected string $_mime
리턴 string

$_orient 보호되어 있는 프로퍼티

protected string $_orient
리턴 string

$_quality 보호되어 있는 프로퍼티

protected int $_quality
리턴 integer

$_width 보호되어 있는 프로퍼티

protected int $_width
리턴 integer