Detailed Description
Main graphics class.
Contains graphics factory and tools. Collects actions with "add"-methods.
Definition at line 40 of file Graphics.php.
Public Member Functions | |
__construct ($options=array()) | |
graphics class constructor More... | |
addBackground ($background) | |
Background "action". More... | |
addCrop ($width, $height, $x=0, $y=0) | |
Adds crop action. More... | |
addResize ($width, $height) | |
Adds resize action. More... | |
addThumb ($width, $height) | |
Adds thumb action. More... | |
addThumbfill ($width, $height, $centerX=50, $centerY=50) | |
Adds thumb-fill action. More... | |
render ($input, $output=null) | |
Main method for image handling. More... | |
renderFinished () | |
Called after rendering has finished. More... | |
optimizeImage ($filename) | |
Opimizes final image through one of the optimization programs. More... | |
setQuality ($quality) | |
Sets quality parameter. More... | |
Static Public Member Functions | |
static | factory ($options=array()) |
graphics object factory More... | |
static | which ($binary) |
Executes "which" command. More... | |
Protected Member Functions | |
escapeNumber ($number) | |
Validates integers. More... | |
dimensions ($width, $height) | |
Scales image dimensions. More... | |
processQueue () | |
Process action queue. More... | |
lock () | |
lock More... | |
unlock () | |
unlock More... | |
obtainFormat ($fileName) | |
Determines image format from file extension. More... | |
getQuality () | |
Returns quality-index for current image format. More... | |
bypassTest ($width, $height, $x=0, $y=0) | |
Tests if action would change current image. More... | |
bypass () | |
Runs bypass (copies file) More... | |
Protected Attributes | |
$input | |
Input filename. More... | |
$output | |
Output filename. More... | |
$format | |
Output format. More... | |
$outputLockFp = null | |
$otherRender = false | |
otherRender is set to true if another render process has already locked file More... | |
$queue = array() | |
Action queue array. More... | |
$size = array() | |
Image size array(width, height) More... | |
$background | |
Image background string. More... | |
$quality = '' | |
Image quality string. More... | |
$optimize | |
Optimize output images. More... | |
$optimizers | |
List of optimizer binaries. More... | |
$limits = [] | |
limits (mainly for imagemagick and graphicsmagick) More... | |
$inputFormat | |
Input image format. More... | |
$outputFormat | |
Output image format. More... | |
$bypass = true | |
Process bypass bool. More... | |
Constructor & Destructor Documentation
◆ __construct()
__construct | ( | $options = array() | ) |
graphics class constructor
- Parameters
-
array $options image processing parameters
Reimplemented in Imagemagick.
Definition at line 156 of file Graphics.php.
Member Function Documentation
◆ addBackground()
addBackground | ( | $background | ) |
Background "action".
Sets image background.
- Parameters
-
string $background image background
- Returns
- object $this
Definition at line 185 of file Graphics.php.
◆ addCrop()
addCrop | ( | $width, | |
$height, | |||
$x = 0 , |
|||
$y = 0 |
|||
) |
Adds crop action.
Adds crop action to action queue.
- Parameters
-
int $width output width int $height output height int $x crop x-offset int $y crop y-offset
- Returns
- object $this
Definition at line 202 of file Graphics.php.
◆ addResize()
addResize | ( | $width, | |
$height | |||
) |
Adds resize action.
Adds resize action to action queue.
- Parameters
-
int $width output width int $height output height
- Returns
- object $this
Definition at line 217 of file Graphics.php.
◆ addThumb()
addThumb | ( | $width, | |
$height | |||
) |
Adds thumb action.
Adds thumb action to action queue.
- Parameters
-
int $width output width int $height output height
- Returns
- object $this
Definition at line 232 of file Graphics.php.
◆ addThumbfill()
addThumbfill | ( | $width, | |
$height, | |||
$centerX = 50 , |
|||
$centerY = 50 |
|||
) |
Adds thumb-fill action.
Adds thumb-fill action to action queue.
- Parameters
-
int $width output width int $height output height int $centerX center of image from left in percent int $centerY center of image from top in percent
- Returns
- object $this
Definition at line 249 of file Graphics.php.
◆ bypass()
|
protected |
◆ bypassTest()
|
protected |
Tests if action would change current image.
- Parameters
-
int $width output width int $height output height int $x crop x-offset int $y crop y-offset
- Returns
- bool $bypass bypass current action
Definition at line 512 of file Graphics.php.
◆ dimensions()
|
protected |
Scales image dimensions.
If either width or height is not set, it calculates the other, preserving the ratio of the origіnal image.
- Parameters
-
int $width output width int $height output height
- Returns
- array of width and height
Definition at line 278 of file Graphics.php.
◆ escapeNumber()
|
protected |
Validates integers.
Tests integers, returns only integers or null.
- Parameters
-
int $number int to check
- Returns
- int number value
Definition at line 264 of file Graphics.php.
◆ factory()
|
static |
graphics object factory
Generates various graphics objects depending on extension type (default is PHP GD)
- Parameters
-
array $options image processing parameters
- Returns
- object graphics object
Definition at line 115 of file Graphics.php.
◆ getQuality()
|
protected |
Returns quality-index for current image format.
Checks plausibility of quality index for current image format. Returns default value if invalid. (PNG & JPG have different systems)
- Returns
- string $quality quality index
Reimplemented in Imagemagick.
Definition at line 463 of file Graphics.php.
◆ lock()
|
protected |
◆ obtainFormat()
|
protected |
Determines image format from file extension.
- Parameters
-
string $fileName filename/path
- Returns
- string $extension image format/filename extension
Definition at line 399 of file Graphics.php.
◆ optimizeImage()
optimizeImage | ( | $filename | ) |
Opimizes final image through one of the optimization programs.
- Parameters
-
string $file name of file to optimize
- Returns
- bool true if image has been optimized successfully
Definition at line 350 of file Graphics.php.
◆ processQueue()
|
protected |
Process action queue.
Calls extension specific action methods.
- Returns
- void
Definition at line 299 of file Graphics.php.
◆ render()
render | ( | $input, | |
$output = null |
|||
) |
Main method for image handling.
Starts actions, saves image, calls bypass if necessary.
- Parameters
-
string $input input filename string $output output filename
- Returns
- void
Reimplemented in Gd, Graphicsmagick, Imagemagick, and Imagick.
Definition at line 317 of file Graphics.php.
◆ renderFinished()
renderFinished | ( | ) |
Called after rendering has finished.
Resets ignore_user_abort
Definition at line 338 of file Graphics.php.
◆ setQuality()
setQuality | ( | $quality | ) |
Sets quality parameter.
Definition at line 451 of file Graphics.php.
◆ unlock()
|
protected |
◆ which()
|
static |
Executes "which" command.
Looks for path to binary in system.
- Parameters
-
string $binary filename of binary to look for
- Returns
- string $commandOutput[0] first line of output (path to binary)
Definition at line 438 of file Graphics.php.
Field Documentation
◆ $background
|
protected |
Image background string.
Definition at line 73 of file Graphics.php.
◆ $bypass
|
protected |
Process bypass bool.
Definition at line 101 of file Graphics.php.
◆ $format
|
protected |
Output format.
Definition at line 53 of file Graphics.php.
◆ $input
|
protected |
Input filename.
Definition at line 45 of file Graphics.php.
◆ $inputFormat
|
protected |
Input image format.
Definition at line 93 of file Graphics.php.
◆ $limits
|
protected |
limits (mainly for imagemagick and graphicsmagick)
Definition at line 89 of file Graphics.php.
◆ $optimize
|
protected |
Optimize output images.
Definition at line 81 of file Graphics.php.
◆ $optimizers
|
protected |
List of optimizer binaries.
Definition at line 85 of file Graphics.php.
◆ $otherRender
|
protected |
otherRender is set to true if another render process has already locked file
Definition at line 61 of file Graphics.php.
◆ $output
|
protected |
Output filename.
Definition at line 49 of file Graphics.php.
◆ $outputFormat
|
protected |
Output image format.
Definition at line 97 of file Graphics.php.
◆ $outputLockFp
|
protected |
Definition at line 57 of file Graphics.php.
◆ $quality
|
protected |
Image quality string.
Definition at line 77 of file Graphics.php.
◆ $queue
|
protected |
Action queue array.
Definition at line 65 of file Graphics.php.
◆ $size
|
protected |
Image size array(width, height)
Definition at line 69 of file Graphics.php.
The documentation for this class was generated from the following file: