depage-graphics
Loading...
Searching...
No Matches
Graphics Class Reference

Detailed Description

Contains graphics factory and tools. Collects actions with "add"-methods.

Definition at line 41 of file Graphics.php.

Public Member Functions

 __construct ($options=array())
 graphics class constructor
 canRead ($ext)
 Checks if extension support reading file type.
 canWrite ($ext)
 Checks if extension supports writing file type.
 addBackground ($background)
 Background "action".
 addCrop ($width, $height, $x=0, $y=0)
 Adds crop action.
 addResize ($width, $height)
 Adds resize action.
 addThumb ($width, $height)
 Adds thumb action.
 addThumbfill ($width, $height, $centerX=50, $centerY=50)
 Adds thumb-fill action.
 render ($input, $output=null)
 Main method for image handling.
 renderFinished ()
 Called after rendering has finished.
 optimizeImage ($filename)
 Opimizes final image through one of the optimization programs.
 setQuality ($quality)
 Sets quality parameter.
 getPageNumber ()
 getPageNumber

Static Public Member Functions

static factory ($options=array())
 graphics object factory
static which ($binary)
 Executes "which" command.

Protected Member Functions

 escapeNumber ($number)
 Validates integers.
 dimensions ($width, $height)
 Scales image dimensions.
 processQueue ()
 Process action queue.
 lock ()
 lock
 unlock ()
 unlock
 obtainFormat ($fileName)
 Determines image format from file extension.
 getQuality ()
 Returns quality-index for current image format.
 bypassTest ($width, $height, $x=0, $y=0)
 Tests if action would change current image.
 bypass ()
 Runs bypass (copies file)

Protected Attributes

 $input
 Input filename.
 $output
 Output filename.
 $format
 Output format.
 $outputLockFp = null
 $otherRender = false
 otherRender is set to true if another render process has already locked file
 $queue = array()
 Action queue array.
 $size = array()
 Image size array(width, height)
 $background
 Image background string.
 $quality = ''
 Image quality string.
 $optimize
 Optimize output images.
 $optimizers
 List of optimizer binaries.
 $limits = []
 limits (mainly for imagemagick and graphicsmagick)
 $inputFormat
 Input image format.
 $outputFormat
 Output image format.
 $bypass = true
 Process bypass bool.

Constructor & Destructor Documentation

◆ __construct()

__construct ( $options = array())
Parameters
array$optionsimage processing parameters

Reimplemented in Imagemagick.

Definition at line 157 of file Graphics.php.

Member Function Documentation

◆ addBackground()

addBackground ( $background)

Sets image background.

Parameters
string$backgroundimage background
Returns
object $this

Definition at line 208 of file Graphics.php.

◆ addCrop()

addCrop ( $width,
$height,
$x = 0,
$y = 0 )

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 225 of file Graphics.php.

◆ addResize()

addResize ( $width,
$height )

Adds resize action to action queue.

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

Definition at line 240 of file Graphics.php.

◆ addThumb()

addThumb ( $width,
$height )

Adds thumb action to action queue.

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

Definition at line 255 of file Graphics.php.

◆ addThumbfill()

addThumbfill ( $width,
$height,
$centerX = 50,
$centerY = 50 )

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 272 of file Graphics.php.

◆ bypass()

bypass ( )
protected
Returns
void

Definition at line 579 of file Graphics.php.

◆ bypassTest()

bypassTest ( $width,
$height,
$x = 0,
$y = 0 )
protected
Parameters
int$widthoutput width
int$heightoutput height
int$xcrop x-offset
int$ycrop y-offset
Returns
bool $bypass bypass current action

Definition at line 551 of file Graphics.php.

◆ canRead()

canRead ( $ext)
Parameters
string$extfile extension
Returns
bool true if image type can be read

Reimplemented in Imagemagick, and Imagick.

Definition at line 184 of file Graphics.php.

◆ canWrite()

canWrite ( $ext)
Parameters
string$extfile extension
Returns
bool true if image type can be read

Definition at line 194 of file Graphics.php.

◆ dimensions()

dimensions ( $width,
$height )
protected

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 301 of file Graphics.php.

◆ escapeNumber()

escapeNumber ( $number)
protected

Tests integers, returns only integers or null.

Parameters
int$numberint to check
Returns
int number value

Definition at line 287 of file Graphics.php.

◆ factory()

factory ( $options = array())
static

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

Parameters
array$optionsimage processing parameters
Returns
object graphics object

Definition at line 116 of file Graphics.php.

◆ getPageNumber()

getPageNumber ( )
Parameters
mixed
Returns
void

Definition at line 533 of file Graphics.php.

◆ getQuality()

getQuality ( )
protected

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 488 of file Graphics.php.

◆ lock()

lock ( )
protected
Returns
void

Definition at line 391 of file Graphics.php.

◆ obtainFormat()

obtainFormat ( $fileName)
protected
Parameters
string$fileNamefilename/path
Returns
string $extension image format/filename extension

Definition at line 424 of file Graphics.php.

◆ optimizeImage()

optimizeImage ( $filename)
Parameters
string$filename of file to optimize
Returns
bool true if image has been optimized successfully

Definition at line 375 of file Graphics.php.

◆ processQueue()

processQueue ( )
protected

Calls extension specific action methods.

Returns
void

Definition at line 322 of file Graphics.php.

◆ render()

render ( $input,
$output = null )

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 340 of file Graphics.php.

◆ renderFinished()

renderFinished ( )

Resets ignore_user_abort

Definition at line 363 of file Graphics.php.

◆ setQuality()

setQuality ( $quality)

Definition at line 476 of file Graphics.php.

◆ unlock()

unlock ( )
protected
Returns
void

Definition at line 407 of file Graphics.php.

◆ which()

which ( $binary)
static

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 463 of file Graphics.php.

Field Documentation

◆ $background

$background
protected

Definition at line 74 of file Graphics.php.

◆ $bypass

$bypass = true
protected

Definition at line 102 of file Graphics.php.

◆ $format

$format
protected

Definition at line 54 of file Graphics.php.

◆ $input

$input
protected

Definition at line 46 of file Graphics.php.

◆ $inputFormat

$inputFormat
protected

Definition at line 94 of file Graphics.php.

◆ $limits

$limits = []
protected

Definition at line 90 of file Graphics.php.

◆ $optimize

$optimize
protected

Definition at line 82 of file Graphics.php.

◆ $optimizers

$optimizers
protected

Definition at line 86 of file Graphics.php.

◆ $otherRender

$otherRender = false
protected

Definition at line 62 of file Graphics.php.

◆ $output

$output
protected

Definition at line 50 of file Graphics.php.

◆ $outputFormat

$outputFormat
protected

Definition at line 98 of file Graphics.php.

◆ $outputLockFp

$outputLockFp = null
protected

Definition at line 58 of file Graphics.php.

◆ $quality

$quality = ''
protected

Definition at line 78 of file Graphics.php.

◆ $queue

$queue = array()
protected

Definition at line 66 of file Graphics.php.

◆ $size

$size = array()
protected

Definition at line 70 of file Graphics.php.


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