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

Detailed Description

The graphics_imagemagick class provides depage::graphics features using the ImageMagick library.

Todo

use ghostscript to convert pdf and eps files directly

or use poppler pdftoppm to convert pdf directly

Definition at line 22 of file Imagemagick.php.

Public Member Functions

 __construct ($options=array())
 graphics_graphicsmagick class constructor
 canRead ($ext)
 Checks if extension support reading file type.
 render ($input, $output=null)
 Main method for image handling.
Public Member Functions inherited from Graphics
 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.
 renderFinished ()
 Called after rendering has finished.
 optimizeImage ($filename)
 Opimizes final image through one of the optimization programs.
 setQuality ($quality)
 Sets quality parameter.
 getPageNumber ()
 getPageNumber

Protected Member Functions

 crop ($width, $height, $x=0, $y=0)
 Crop action.
 resize ($width, $height)
 Resize action.
 thumb ($width, $height)
 Thumb action.
 thumbfill ($width, $height, $centerX=50, $centerY=50)
 Thumb action.
 getImageSize ()
 Determine size of input image.
 execCommand ()
 Executes ImageMagick command.
 getBackground ()
 Generates background command.
 getQuality ()
 Generates quality command.
 getOptimize ()
 Generates optimization parameters.
 getResizeAction ($width, $height)
 Gets the resize action depending on target size.
Protected Member Functions inherited from Graphics
 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.
 bypassTest ($width, $height, $x=0, $y=0)
 Tests if action would change current image.
 bypass ()
 Runs bypass (copies file)

Protected Attributes

 $command = ''
 Imagemagick command string.
 $executable
 Imagemagick executable path.
 $timeout = 0
 timeout after which the image conversion will be canceled
Protected Attributes inherited from Graphics
 $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.

Additional Inherited Members

Static Public Member Functions inherited from Graphics
static factory ($options=array())
 graphics object factory
static which ($binary)
 Executes "which" command.

Constructor & Destructor Documentation

◆ __construct()

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

Reimplemented from Graphics.

Definition at line 41 of file Imagemagick.php.

Member Function Documentation

◆ canRead()

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

Reimplemented from Graphics.

Definition at line 55 of file Imagemagick.php.

◆ crop()

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

Adds crop command to command string.

Parameters
int$widthoutput width
int$heightoutput height
int$xcrop x-offset
int$ycrop y-offset
Returns
void

Reimplemented in Graphicsmagick.

Definition at line 71 of file Imagemagick.php.

◆ execCommand()

execCommand ( )
protected

Escapes $this->command and executes it.

Returns
void

Definition at line 238 of file Imagemagick.php.

◆ getBackground()

getBackground ( )
protected
Returns
string $background background part of the command string

Reimplemented in Graphicsmagick.

Definition at line 295 of file Imagemagick.php.

◆ getImageSize()

getImageSize ( )
protected
Returns
void

Reimplemented in Graphicsmagick.

Definition at line 162 of file Imagemagick.php.

◆ getOptimize()

getOptimize ( )
protected
Returns
string optimization part of the command string

Definition at line 335 of file Imagemagick.php.

◆ getQuality()

getQuality ( )
protected
Returns
string quality part of the command string

Reimplemented from Graphics.

Definition at line 318 of file Imagemagick.php.

◆ getResizeAction()

getResizeAction ( $width,
$height )
protected

this assumes that all images below 160px width or height will be thumbnails everything bigger gets resized slowly in better quality

Returns
string resize action as part of command string

Definition at line 357 of file Imagemagick.php.

◆ render()

render ( $input,
$output = null )

Starts actions, saves image, calls bypass if necessary.

Parameters
string$inputinput filename
string$outputoutput filename
Returns
void

Reimplemented from Graphics.

Reimplemented in Graphicsmagick.

Definition at line 196 of file Imagemagick.php.

◆ resize()

resize ( $width,
$height )
protected

Adds resize command to command string.

Parameters
int$widthoutput width
int$heightoutput height
Returns
void

Definition at line 91 of file Imagemagick.php.

◆ thumb()

thumb ( $width,
$height )
protected

Adds thumb command to command string.

Parameters
int$widthoutput width
int$heightoutput height
Returns
void

Definition at line 112 of file Imagemagick.php.

◆ thumbfill()

thumbfill ( $width,
$height,
$centerX = 50,
$centerY = 50 )
protected

Adds thumb command to command string.

Parameters
int$widthoutput width
int$heightoutput height
int$centerXcenter of image from left in percent
int$centerYcenter of image from top in percent
Returns
void

Definition at line 132 of file Imagemagick.php.

Field Documentation

◆ $command

$command = ''
protected

Definition at line 27 of file Imagemagick.php.

◆ $executable

$executable
protected

Definition at line 31 of file Imagemagick.php.

◆ $timeout

$timeout = 0
protected

Definition at line 35 of file Imagemagick.php.


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