PHP 클래스 GdThumb, thinksns

This is the GD Implementation of the PHP Thumb library.
상속: extends ThumbBase
파일 보기 프로젝트 열기: medz/thinksns-4 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$currentDimensions array The current dimensions of the image
$maxHeight integer The maximum height an image can be after resizing (in pixels)
$maxWidth integer The maximum width an image can be after resizing (in pixels)
$newDimensions array The new, calculated dimensions of the image
$oldImage resource The prior image (before manipulation)
$options array This array contains various options that determine the behavior in various functions throughout the class. Functions note which specific option key / values are used in their documentation
$percent integer The percentage to resize the image by
$workingImage resource The working image (used during manipulation)

공개 메소드들

메소드 설명
__construct ( string $fileName, $options = [], $isDataStream = false ) : GdThumb Class Constructor
__destruct ( ) Class Destructor
adaptiveResize ( $width, $height ) : GdThumb Adaptively Resizes the Image
crop ( integer $startX, integer $startY, integer $cropWidth, integer $cropHeight ) : GdThumb Vanilla Cropping - Crops from x,y with specified width and height
cropFromCenter ( integer $cropWidth, integer $cropHeight = null ) : GdThumb Crops an image from the center with provided dimensions
getCurrentDimensions ( ) Returns $currentDimensions.
getImageAsString ( ) : string Returns the Working Image as a String
getMaxHeight ( ) Returns $maxHeight.
getMaxWidth ( ) Returns $maxWidth.
getNewDimensions ( ) Returns $newDimensions.
getOldImage ( ) Returns $oldImage.
getOptions ( ) Returns $options.
getPercent ( ) Returns $percent.
getWorkingImage ( ) Returns $workingImage.
resize ( integer $maxWidth, integer $maxHeight ) : GdThumb Resizes an image to be no larger than $maxWidth or $maxHeight
resizePercent ( integer $percent ) : GdThumb Resizes an image by a given percent uniformly
rotateImage ( string $direction = 'CW' ) Rotates image either 90 degrees clockwise or counter-clockwise
rotateImageNDegrees ( integer $degrees ) : GdThumb Rotates image specified number of degrees
save ( string $fileName, string $format = null ) : GdThumb Saves an image
setCurrentDimensions ( object $currentDimensions ) Sets $currentDimensions.
setMaxHeight ( object $maxHeight ) Sets $maxHeight.
setMaxWidth ( object $maxWidth ) Sets $maxWidth.
setNewDimensions ( object $newDimensions ) Sets $newDimensions.
setOldImage ( object $oldImage ) Sets $oldImage.
setOptions ( array $options = [] ) Sets $this->options to $options
setPercent ( object $percent ) Sets $percent.
setWorkingImage ( object $workingImage ) Sets $workingImage.
show ( boolean $rawData = false ) : GdThumb Shows an image

보호된 메소드들

메소드 설명
calcHeight ( integer $width, integer $height ) : array Calculates a new width and height for the image based on $this->maxWidth and the provided dimensions
calcImageSize ( integer $width, integer $height ) Calculates the new image dimensions
calcImageSizePercent ( integer $width, integer $height ) Calculates new dimensions based on $this->percent and the provided dimensions
calcImageSizeStrict ( integer $width, integer $height ) Calculates new image dimensions, not allowing the width and height to be less than either the max width or height
calcPercent ( integer $width, integer $height ) : array Calculates a new width and height for the image based on $this->percent and the provided dimensions
calcWidth ( integer $width, integer $height ) : array Calculates a new width and height for the image based on $this->maxWidth and the provided dimensions
determineFormat ( ) Determines the file format by mime-type
preserveAlpha ( ) Preserves the alpha or transparency for PNG and GIF files
verifyFormatCompatiblity ( ) Makes sure the correct GD implementation exists for the file type

메소드 상세

__construct() 공개 메소드

Class Constructor
public __construct ( string $fileName, $options = [], $isDataStream = false ) : GdThumb
$fileName string
리턴 GdThumb

__destruct() 공개 메소드

Class Destructor
public __destruct ( )

adaptiveResize() 공개 메소드

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
public adaptiveResize ( $width, $height ) : GdThumb
리턴 GdThumb

calcHeight() 보호된 메소드

Calculates a new width and height for the image based on $this->maxWidth and the provided dimensions
protected calcHeight ( integer $width, integer $height ) : array
$width integer
$height integer
리턴 array

calcImageSize() 보호된 메소드

These calculations are based on both the provided dimensions and $this->maxWidth and $this->maxHeight
protected calcImageSize ( integer $width, integer $height )
$width integer
$height integer

calcImageSizePercent() 보호된 메소드

Calculates new dimensions based on $this->percent and the provided dimensions
protected calcImageSizePercent ( integer $width, integer $height )
$width integer
$height integer

calcImageSizeStrict() 보호된 메소드

Calculates new image dimensions, not allowing the width and height to be less than either the max width or height
protected calcImageSizeStrict ( integer $width, integer $height )
$width integer
$height integer

calcPercent() 보호된 메소드

Calculates a new width and height for the image based on $this->percent and the provided dimensions
protected calcPercent ( integer $width, integer $height ) : array
$width integer
$height integer
리턴 array

calcWidth() 보호된 메소드

Calculates a new width and height for the image based on $this->maxWidth and the provided dimensions
protected calcWidth ( integer $width, integer $height ) : array
$width integer
$height integer
리턴 array

crop() 공개 메소드

Vanilla Cropping - Crops from x,y with specified width and height
public crop ( integer $startX, integer $startY, integer $cropWidth, integer $cropHeight ) : GdThumb
$startX integer
$startY integer
$cropWidth integer
$cropHeight integer
리턴 GdThumb

cropFromCenter() 공개 메소드

If no height is given, the width will be used as a height, thus creating a square crop
public cropFromCenter ( integer $cropWidth, integer $cropHeight = null ) : GdThumb
$cropWidth integer
$cropHeight integer
리턴 GdThumb

determineFormat() 보호된 메소드

This function will throw exceptions for invalid images / mime-types
protected determineFormat ( )

getCurrentDimensions() 공개 메소드

Returns $currentDimensions.
또한 보기: GdThumb::$currentDimensions

getImageAsString() 공개 메소드

This function is useful for getting the raw image data as a string for storage in a database, or other similar things.
public getImageAsString ( ) : string
리턴 string

getMaxHeight() 공개 메소드

Returns $maxHeight.
또한 보기: GdThumb::$maxHeight
public getMaxHeight ( )

getMaxWidth() 공개 메소드

Returns $maxWidth.
또한 보기: GdThumb::$maxWidth
public getMaxWidth ( )

getNewDimensions() 공개 메소드

Returns $newDimensions.
또한 보기: GdThumb::$newDimensions
public getNewDimensions ( )

getOldImage() 공개 메소드

Returns $oldImage.
또한 보기: GdThumb::$oldImage
public getOldImage ( )

getOptions() 공개 메소드

Returns $options.
또한 보기: GdThumb::$options
public getOptions ( )

getPercent() 공개 메소드

Returns $percent.
또한 보기: GdThumb::$percent
public getPercent ( )

getWorkingImage() 공개 메소드

Returns $workingImage.
또한 보기: GdThumb::$workingImage
public getWorkingImage ( )

preserveAlpha() 보호된 메소드

Alpha / transparency will not be preserved if the appropriate options are set to false. Also, the GIF transparency is pretty skunky (the results aren't awesome), but it works like a champ... that's the nature of GIFs tho, so no huge surprise. This functionality was originally suggested by commenter Aimi (no links / site provided) - Thanks! :)
protected preserveAlpha ( )

resize() 공개 메소드

If either param is set to zero, then that dimension will not be considered as a part of the resize. Additionally, if $this->options['resizeUp'] is set to true (false by default), then this function will also scale the image up to the maximum dimensions provided.
public resize ( integer $maxWidth, integer $maxHeight ) : GdThumb
$maxWidth integer The maximum width of the image in pixels
$maxHeight integer The maximum height of the image in pixels
리턴 GdThumb

resizePercent() 공개 메소드

Percentage should be whole number representation (i.e. 1-100)
public resizePercent ( integer $percent ) : GdThumb
$percent integer
리턴 GdThumb

rotateImage() 공개 메소드

Rotates image either 90 degrees clockwise or counter-clockwise
public rotateImage ( string $direction = 'CW' )
$direction string

rotateImageNDegrees() 공개 메소드

Rotates image specified number of degrees
public rotateImageNDegrees ( integer $degrees ) : GdThumb
$degrees integer
리턴 GdThumb

save() 공개 메소드

This function will make sure the target directory is writeable, and then save the image. If the target directory is not writeable, the function will try to correct the permissions (if allowed, this is set as an option ($this->options['correctPermissions']). If the target cannot be made writeable, then a RuntimeException is thrown. TODO: Create additional paramter for color matte when saving images with alpha to non-alpha formats (i.e. PNG => JPG)
public save ( string $fileName, string $format = null ) : GdThumb
$fileName string The full path and filename of the image to save
$format string The format to save the image in (optional, must be one of [GIF,JPG,PNG]
리턴 GdThumb

setCurrentDimensions() 공개 메소드

Sets $currentDimensions.
또한 보기: GdThumb::$currentDimensions
public setCurrentDimensions ( object $currentDimensions )
$currentDimensions object

setMaxHeight() 공개 메소드

Sets $maxHeight.
또한 보기: GdThumb::$maxHeight
public setMaxHeight ( object $maxHeight )
$maxHeight object

setMaxWidth() 공개 메소드

Sets $maxWidth.
또한 보기: GdThumb::$maxWidth
public setMaxWidth ( object $maxWidth )
$maxWidth object

setNewDimensions() 공개 메소드

Sets $newDimensions.
또한 보기: GdThumb::$newDimensions
public setNewDimensions ( object $newDimensions )
$newDimensions object

setOldImage() 공개 메소드

Sets $oldImage.
또한 보기: GdThumb::$oldImage
public setOldImage ( object $oldImage )
$oldImage object

setOptions() 공개 메소드

Sets $this->options to $options
public setOptions ( array $options = [] )
$options array

setPercent() 공개 메소드

Sets $percent.
또한 보기: GdThumb::$percent
public setPercent ( object $percent )
$percent object

setWorkingImage() 공개 메소드

Sets $workingImage.
또한 보기: GdThumb::$workingImage
public setWorkingImage ( object $workingImage )
$workingImage object

show() 공개 메소드

This function will show the current image by first sending the appropriate header for the format, and then outputting the image data. If headers have already been sent, a runtime exception will be thrown
public show ( boolean $rawData = false ) : GdThumb
$rawData boolean Whether or not the raw image stream should be output
리턴 GdThumb

verifyFormatCompatiblity() 보호된 메소드

Makes sure the correct GD implementation exists for the file type
protected verifyFormatCompatiblity ( )

프로퍼티 상세

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

The current dimensions of the image
protected array $currentDimensions
리턴 array

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

The maximum height an image can be after resizing (in pixels)
protected int $maxHeight
리턴 integer

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

The maximum width an image can be after resizing (in pixels)
protected int $maxWidth
리턴 integer

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

The new, calculated dimensions of the image
protected array $newDimensions
리턴 array

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

The prior image (before manipulation)
protected resource $oldImage
리턴 resource

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

This array contains various options that determine the behavior in various functions throughout the class. Functions note which specific option key / values are used in their documentation
protected array $options
리턴 array

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

The percentage to resize the image by
protected int $percent
리턴 integer

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

The working image (used during manipulation)
protected resource $workingImage
리턴 resource