Graphics Class Reference

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$optionsimage 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$backgroundimage 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$widthoutput width
int$heightoutput height
int$xcrop x-offset
int$ycrop 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$widthoutput width
int$heightoutput 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$widthoutput width
int$heightoutput 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$widthoutput width
int$heightoutput height
int$centerXcenter of image from left in percent
int$centerYcenter of image from top in percent
Returns
object $this

Definition at line 249 of file Graphics.php.

◆ bypass()

bypass ( )
protected

Runs bypass (copies file)

Returns
void

Definition at line 540 of file Graphics.php.

◆ bypassTest()

bypassTest (   $width,
  $height,
  $x = 0,
  $y = 0 
)
protected

Tests if action would change current image.

Parameters
int$widthoutput width
int$heightoutput height
int$xcrop x-offset
int$ycrop y-offset
Returns
bool $bypass bypass current action

Definition at line 512 of file Graphics.php.

◆ dimensions()

dimensions (   $width,
  $height 
)
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$widthoutput width
int$heightoutput height
Returns
array of width and height

Definition at line 278 of file Graphics.php.

◆ escapeNumber()

escapeNumber (   $number)
protected

Validates integers.

Tests integers, returns only integers or null.

Parameters
int$numberint to check
Returns
int number value

Definition at line 264 of file Graphics.php.

◆ factory()

static factory (   $options = array())
static

graphics object factory

Generates various graphics objects depending on extension type (default is PHP GD)

Parameters
array$optionsimage processing parameters
Returns
object graphics object

Definition at line 115 of file Graphics.php.

◆ getQuality()

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()

lock ( )
protected

lock

Returns
void

Definition at line 366 of file Graphics.php.

◆ obtainFormat()

obtainFormat (   $fileName)
protected

Determines image format from file extension.

Parameters
string$fileNamefilename/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$filename of file to optimize
Returns
bool true if image has been optimized successfully

Definition at line 350 of file Graphics.php.

◆ processQueue()

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$inputinput filename
string$outputoutput 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()

unlock ( )
protected

unlock

Returns
void

Definition at line 382 of file Graphics.php.

◆ which()

static which (   $binary)
static

Executes "which" command.

Looks for path to binary in system.

Parameters
string$binaryfilename 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

$background
protected

Image background string.

Definition at line 73 of file Graphics.php.

◆ $bypass

$bypass = true
protected

Process bypass bool.

Definition at line 101 of file Graphics.php.

◆ $format

$format
protected

Output format.

Definition at line 53 of file Graphics.php.

◆ $input

$input
protected

Input filename.

Definition at line 45 of file Graphics.php.

◆ $inputFormat

$inputFormat
protected

Input image format.

Definition at line 93 of file Graphics.php.

◆ $limits

$limits = []
protected

limits (mainly for imagemagick and graphicsmagick)

Definition at line 89 of file Graphics.php.

◆ $optimize

$optimize
protected

Optimize output images.

Definition at line 81 of file Graphics.php.

◆ $optimizers

$optimizers
protected

List of optimizer binaries.

Definition at line 85 of file Graphics.php.

◆ $otherRender

$otherRender = false
protected

otherRender is set to true if another render process has already locked file

Definition at line 61 of file Graphics.php.

◆ $output

$output
protected

Output filename.

Definition at line 49 of file Graphics.php.

◆ $outputFormat

$outputFormat
protected

Output image format.

Definition at line 97 of file Graphics.php.

◆ $outputLockFp

$outputLockFp = null
protected

Definition at line 57 of file Graphics.php.

◆ $quality

$quality = ''
protected

Image quality string.

Definition at line 77 of file Graphics.php.

◆ $queue

$queue = array()
protected

Action queue array.

Definition at line 65 of file Graphics.php.

◆ $size

$size = array()
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: