$fileName
$fileName : string
The name of the file we're manipulating This must include the path to the file (absolute paths recommended)
PhpThumb : PHP Thumb Library <http://phpthumb.gxdlabs.com> Copyright (c) 2009, Ian Selby/Gen X Design
Author(s): Ian Selby ian@gen-x-design.com
Licensed under the MIT License Redistributions of files must retain the above copyright notice.
setOptions(array $options = array()) : \PHPThumb\GD
Sets options for all operations.
| array | $options |
setFileName( $fileName) : \PHPThumb\PHPThumb
Sets the filename.
| $fileName |
setFormat( $format) : \PHPThumb\PHPThumb
Sets the format.
| $format |
pad( $width, $height, array $color = array(255, 255, 255)) : \PHPThumb\GD
Pad an image to desired dimensions. Moves the image into the center and fills the rest with $color.
| $width | ||
| $height | ||
| array | $color |
resize(integer $maxWidth, integer $maxHeight) : \PHPThumb\GD
Resizes an image to be no larger than $maxWidth or $maxHeight
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.
| integer | $maxWidth | The maximum width of the image in pixels |
| integer | $maxHeight | The maximum height of the image in pixels |
adaptiveResize( $width, $height) : \PHPThumb\GD
Adaptively Resizes the Image
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
| $width | ||
| $height |
adaptiveResizePercent( $width, $height, integer $percent = 50) : \PHPThumb\GD
Adaptively Resizes the Image and Crops Using a Percentage
This function attempts to get the image to as close to the provided dimensions as possible, and then crops the remaining overflow using a provided percentage to get the image to be the size specified.
The percentage mean different things depending on the orientation of the original image.
A percentage of 1 would crop the image all the way to the left, which would be the same as using adaptiveResizeQuadrant() with $quadrant = 'L'
A percentage of 50 would crop the image to the center which would be the same as using adaptiveResizeQuadrant() with $quadrant = 'C', or even the original adaptiveResize()
A percentage of 100 would crop the image to the image all the way to the right, etc, etc. Note that you can use any percentage between 1 and 100.
This works the same as for Landscape images except that a percentage of 1 means top and 100 means bottom
| $width | ||
| $height | ||
| integer | $percent |
adaptiveResizeQuadrant( $width, $height, string $quadrant = 'C') : \PHPThumb\GD
Adaptively Resizes the Image and Crops Using a Quadrant
This function attempts to get the image to as close to the provided dimensions as possible, and then crops the remaining overflow using the quadrant to get the image to be the size specified.
The quadrants available are Top, Bottom, Center, Left, and Right:
+---+---+---+ | | T | | +---+---+---+ | L | C | R | +---+---+---+ | | B | | +---+---+---+
Note that if your image is Landscape and you choose either of the Top or Bottom quadrants (which won't make sence since only the Left and Right would be available, then the Center quadrant will be used to crop. This would have exactly the same result as using adaptiveResize(). The same goes if your image is portrait and you choose either the Left or Right quadrants.
| $width | ||
| $height | ||
| string | $quadrant | T, B, C, L, R |
resizePercent(integer $percent) : \PHPThumb\GD
Resizes an image by a given percent uniformly, Percentage should be whole number representation (i.e. 1-100)
| integer | $percent |
cropFromCenter(integer $cropWidth, integer $cropHeight = null) : \PHPThumb\GD
Crops an image from the center with provided dimensions
If no height is given, the width will be used as a height, thus creating a square crop
| integer | $cropWidth | |
| integer | $cropHeight |
crop(integer $startX, integer $startY, integer $cropWidth, integer $cropHeight) : \PHPThumb\GD
Vanilla Cropping - Crops from x,y with specified width and height
| integer | $startX | |
| integer | $startY | |
| integer | $cropWidth | |
| integer | $cropHeight |
rotateImageNDegrees(integer $degrees) : \PHPThumb\GD
Rotates image specified number of degrees
| integer | $degrees |
imageFilter(integer $filter, $arg1 = false, $arg2 = false, $arg3 = false, $arg4 = false) : \PHPThumb\GD
Applies a filter to the image
| integer | $filter | |
| $arg1 | ||
| $arg2 | ||
| $arg3 | ||
| $arg4 |
show(boolean $rawData = false) : \PHPThumb\GD
Shows an image
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
| boolean | $rawData | Whether or not the raw image stream should be output |
save(string $fileName, string $format = null) : \PHPThumb\GD
Saves an image
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.
| string | $fileName | The full path and filename of the image to save |
| string | $format | The format to save the image in (optional, must be one of [GIF,JPG,PNG] |
setCurrentDimensions( $currentDimensions) : \PHPThumb\GD
| $currentDimensions |
setMaxHeight( $maxHeight) : \PHPThumb\GD
| $maxHeight |
setMaxWidth( $maxWidth) : \PHPThumb\GD
| $maxWidth |
preserveAlpha()
Preserves the alpha or transparency for PNG and GIF files
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! :)