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)
 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...
 
 $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...
 
 $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

Definition at line 146 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 163 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 180 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 195 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 210 of file Graphics.php.

◆ addThumbfill()

addThumbfill (   $width,
  $height 
)

Adds thumb-fill action.

Adds thumb-fill action to action queue.

Parameters
int$widthoutput width
int$heightoutput height
Returns
object $this

Definition at line 225 of file Graphics.php.

◆ bypass()

bypass ( )
protected

Runs bypass (copies file)

Returns
void

Definition at line 504 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 476 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 254 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 240 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 107 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

Definition at line 437 of file Graphics.php.

◆ lock()

lock ( )
protected

lock

Returns
void

Definition at line 342 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 373 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 326 of file Graphics.php.

◆ processQueue()

processQueue ( )
protected

Process action queue.

Calls extension specific action methods.

Returns
void

Definition at line 275 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

Definition at line 293 of file Graphics.php.

◆ renderFinished()

renderFinished ( )

Called after rendering has finished.

Resets ignore_user_abort

Definition at line 314 of file Graphics.php.

◆ setQuality()

setQuality (   $quality)

Sets quality parameter.

Definition at line 425 of file Graphics.php.

◆ unlock()

unlock ( )
protected

unlock

Returns
void

Definition at line 358 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 412 of file Graphics.php.

Field Documentation

◆ $background

$background
protected

Image background string.

Definition at line 69 of file Graphics.php.

◆ $bypass

$bypass = true
protected

Process bypass bool.

Definition at line 93 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 85 of file Graphics.php.

◆ $optimize

$optimize
protected

Optimize output images.

Definition at line 77 of file Graphics.php.

◆ $optimizers

$optimizers
protected

List of optimizer binaries.

Definition at line 81 of file Graphics.php.

◆ $otherRender

$otherRender = false
protected

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

Definition at line 57 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 89 of file Graphics.php.

◆ $outputLockFp

$outputLockFp = null
protected

Definition at line 53 of file Graphics.php.

◆ $quality

$quality = ''
protected

Image quality string.

Definition at line 73 of file Graphics.php.

◆ $queue

$queue = array()
protected

Action queue array.

Definition at line 61 of file Graphics.php.

◆ $size

$size = array()
protected

Image size array(width, height)

Definition at line 65 of file Graphics.php.


The documentation for this class was generated from the following file: