Zeta Components - high quality PHP components

Zeta Components Manual :: Docs For Class ezcImageAnalyzerImagemagickHandler

ImageAnalysis::ezcImageAnalyzerImagemagickHandler

Class ezcImageAnalyzerImagemagickHandler

Class to retrieve information about a given image file.

This is an ezcImageAnalyzerHandler that utilizes ImageMagick to analyze image files.

This ezcImageAnalyzerHandler can be configured using the Option 'binary', which must be set to the full path of the ImageMagick "identify" binary. If this option is not submitted to the ezcImageAnalyzerHandler::__construct() method, the handler will use just the name of the binary ("identify" on Unix, "identify.exe" on Windows).

You can provide the options of the ezcImageAnalyzerImagemagickHandler to the ezcImageAnalyzer::setHandlerClasses().

Source for this file: /ImageAnalysis/src/handlers/imagemagick.php

ezcImageAnalyzerHandler
   |
   --ezcImageAnalyzerImagemagickHandler
Version:   //autogentag//

Inherited Constants

From ezcImageAnalyzerHandler:
ezcImageAnalyzerHandler::MODE_INDEXED    Image is built with a palette and consists of indexed values per pixel.
ezcImageAnalyzerHandler::MODE_TRUECOLOR    Image consists of RGB value per pixel.
ezcImageAnalyzerHandler::TRANSPARENCY_OPAQUE    No parts of image is transparent.
ezcImageAnalyzerHandler::TRANSPARENCY_TRANSLUCENT    Transparency determined pixel per pixel with a fuzzy value.
ezcImageAnalyzerHandler::TRANSPARENCY_TRANSPARENT

Member Variables

protected string $binary
The ImageMagick binary to utilize.

This variable is set during call to ezcImageAnalyzerImagemagickHandler::checkImagemagick().

protected bool $isAvailable
Indicates if this handler is available.

The first call to ezcImageAnalyzerImagemagickHandler::isAvailable() determines this variable, which is then used as a cache for the call to ezcImageAnalyzerImagemagickHandler::checkImagemagick().

protected array(string=>string) $mimeMap = array(
'bmp' => 'image/bmp',
'bmp2' => 'image/bmp',
'bmp3' => 'image/bmp',
'cur' => 'image/x-win-bitmap',
'dcx' => 'image/dcx',
'epdf' => 'application/pdf',
'epi' => 'application/postscript',
'eps' => 'application/postscript',
'eps2' => 'application/postscript',
'eps3' => 'application/postscript',
'epsf' => 'application/postscript',
'epsi' => 'application/postscript',
'ept' => 'application/postscript',
'ept2' => 'application/postscript',
'ept3' => 'application/postscript',
'fax' => 'image/g3fax',
'fits' => 'image/x-fits',
'g3' => 'image/g3fax',
'gif' => 'image/gif',
'gif87' => 'image/gif',
'icb' => 'application/x-icb',
'ico' => 'image/x-win-bitmap',
'icon' => 'image/x-win-bitmap',
'jng' => 'image/jng',
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'm2v' => 'video/mpeg2',
'miff' => 'application/x-mif',
'mng' => 'video/mng',
'mpeg' => 'video/mpeg',
'mpg' => 'video/mpeg',
'otb' => 'image/x-otb',
'p7' => 'image/x-xv',
'palm' => 'image/x-palm',
'pbm' => 'image/pbm',
'pcd' => 'image/pcd',
'pcds' => 'image/pcd',
'pcl' => 'application/pcl',
'pct' => 'image/pict',
'pcx' => 'image/x-pcx',
'pdb' => 'application/vnd.palm',
'pdf' => 'application/pdf',
'pgm' => 'image/x-pgm',
'picon' => 'image/xpm',
'pict' => 'image/pict',
'pjpeg' => 'image/pjpeg',
'png' => 'image/png',
'png24' => 'image/png',
'png32' => 'image/png',
'png8' => 'image/png',
'pnm' => 'image/pbm',
'ppm' => 'image/x-ppm',
'ps' => 'application/postscript',
'psd' => 'image/x-photoshop',
'ptif' => 'image/x-ptiff',
'ras' => 'image/ras',
'sgi' => 'image/sgi',
'sun' => 'image/ras',
'svg' => 'image/svg+xml',
'svgz' => 'image/svg',
'text' => 'text/plain',
'tga' => 'image/tga',
'tif' => 'image/tiff',
'tiff' => 'image/tiff',
'txt' => 'text/plain',
'vda' => 'image/vda',
'viff' => 'image/x-viff',
'vst' => 'image/vst',
'wbmp' => 'image/vnd.wap.wbmp',
'xbm' => 'image/x-xbitmap',
'xpm' => 'image/x-xbitmap',
'xv' => 'image/x-viff',
'xwd' => 'image/xwd',
)

Mapping between ImageMagick identification strings and MIME types.

ImageMagick's "identify" command returns an identification string to indicate the file type examined.

This map has been handcrafted, because ImageMagick misses the possibility to determine MIME types. It misses some identification strings (mostly for file types which are absolutely rare in use or which ImageMagick is only capable to read or write, but not both.).

protected array(string=>bool) $mimeTypes = array(
'application/pcl' => true,
'application/pdf' => true,
'application/postscript' => true,
'application/vnd.palm' => true,
'application/x-icb' => true,
'application/x-mif' => true,
'image/dcx' => true,
'image/g3fax' => true,
'image/gif' => true,
'image/jng' => true,
'image/jpeg' => true,
'image/pbm' => true,
'image/pcd' => true,
'image/pict' => true,
'image/pjpeg' => true,
'image/png' => true,
'image/ras' => true,
'image/sgi' => true,
'image/svg' => true,
'image/tga' => true,
'image/tiff' => true,
'image/vda' => true,
'image/vnd.wap.wbmp' => true,
'image/vst' => true,
'image/x-fits' => true,
'image/x-ms-bmp' => true,
'image/x-otb' => true,
'image/x-palm' => true,
'image/x-pcx' => true,
'image/x-pgm' => true,
'image/x-photoshop' => true,
'image/x-ppm' => true,
'image/x-ptiff' => true,
'image/x-viff' => true,
'image/x-win-bitmap' => true,
'image/x-xbitmap' => true,
'image/x-xv' => true,
'image/xpm' => true,
'image/xwd' => true,
'text/plain' => true,
'video/mng' => true,
'video/mpeg' => true,
'video/mpeg2' => true,
)

MIME types this handler is capable to read.

This array holds an extract of the ezcImageAnalyzerHandler::$mimeMap, listing all MIME types this handler is capable to analyze. The map is indexed by the MIME type, assigned to boolean true, to speed up hash lookups.

Inherited Member Variables

From ezcImageAnalyzerHandler
protected ezcImageAnalyzerHandler::$options

Method Summary

protected void analyzeExif( $data , $file )
Analyze Exif data contained in JPEG and TIFF images.
public ezcImageAnalyzerData analyzeImage( $file )
Analyze the image for detailed information.
public string|bool analyzeType( $file )
Analyzes the image type.
public bool canAnalyze( $mime )
Returns if the handler can analyze a given MIME type.
protected bool checkImagemagick( )
Checks the availability of ImageMagick on the system.
public bool isAvailable( )
Checks wether the GD handler is available on the system.
protected int runCommand( $parameters , &$stdOut , &$errOut , [ $stripNewlines = true] , $stdOut , $errOut )
Run the binary registered in ezcImageAnalyzerImagemagickHandler::$binary.

Inherited Methods

From ezcImageAnalyzerHandler
public ezcImageAnalyzerHandler ezcImageAnalyzerHandler::__construct()
Create an ezcImageAnalyzerHandler to analyze a file.
public abstract ezcImageAnalyzerData ezcImageAnalyzerHandler::analyzeImage()
Analyze the image for detailed information.
public abstract string|bool ezcImageAnalyzerHandler::analyzeType()
Analyzes the image type.
public abstract bool ezcImageAnalyzerHandler::canAnalyze()
Returns if the handler can analyze a given MIME type.
public abstract bool ezcImageAnalyzerHandler::isAvailable()
Checks wether the given handler is available for analyzing images.

Methods

analyzeExif

void analyzeExif( ezcImageAnalyzerData $data , string $file )

Analyze Exif data contained in JPEG and TIFF images.

This method analyzes the Exif data contained in JPEG and TIFF images, using ImageMagick's "identify" binary.

This method tries to provide the EXIF data in a format as close as possible to the format returned by ext/EXIF http://php.net/exif.

Parameters:
Name Type Description
$data ezcImageAnalyzerData The data object to fill.
$file string The file to analyze.

analyzeImage

ezcImageAnalyzerData analyzeImage( string $file )

Analyze the image for detailed information.

This may return various information about the image, depending on it's type. All information is collected in the struct ezcImageAnalyzerData. At least the ezcImageAnalyzerData::$mime attribute is always available, if the image type can be analyzed at all. Additionally this handler will always set the ezcImageAnalyzerData::$width, ezcImageAnalyzerData::$height and ezcImageAnalyzerData::$size attributes. For detailes information on the additional data returned, see ezcImageAnalyzerImagemagickHandler.

Parameters:
Name Type Description
$file string The file to analyze.
Exceptions:
Type Description
ezcImageAnalyzerFileNotProcessableException If image file can not be processed.
Redefinition of:
Method Description
ezcImageAnalyzerHandler::analyzeImage() Analyze the image for detailed information.

analyzeType

string|bool analyzeType( string $file )

Analyzes the image type.

This method analyzes image data to determine the MIME type. This method returns the MIME type of the file to analyze in lowercase letters (e.g. "image/jpeg") or false, if the images MIME type could not be determined.

For a list of image types this handler will be able to analyze, see ezcImageAnalyzerImagemagickHandler.

Parameters:
Name Type Description
$file string The file to analyze.
Redefinition of:
Method Description
ezcImageAnalyzerHandler::analyzeType() Analyzes the image type.

canAnalyze

bool canAnalyze( string $mime )

Returns if the handler can analyze a given MIME type.

This method returns if the driver is capable of analyzing a given MIME type. This method should be called before trying to actually analyze an image using the drivers ezcImageAnalyzerHandler::analyzeImage() method.

Parameters:
Name Type Description
$mime string The MIME type to check for.
Redefinition of:
Method Description
ezcImageAnalyzerHandler::canAnalyze() Returns if the handler can analyze a given MIME type.

checkImagemagick

bool checkImagemagick( )

Checks the availability of ImageMagick on the system.

isAvailable

bool isAvailable( )

Checks wether the GD handler is available on the system.

Returns if PHP's http://www.php.net/getimagesize function is available.

Redefinition of:
Method Description
ezcImageAnalyzerHandler::isAvailable() Checks wether the given handler is available for analyzing images.

runCommand

int runCommand( string $parameters , &$stdOut , &$errOut , [bool $stripNewlines = true] , string $stdOut , string $errOut )

Run the binary registered in ezcImageAnalyzerImagemagickHandler::$binary.

This method executes the ImageMagick binary using the applied parameter string. It returns the return value of the command. The output printed to STDOUT and ERROUT is available through the $stdOut and $errOut parameters.

Parameters:
Name Type Description
$parameters string The parameters for the binary to execute.
$stdOut string The standard output.
$errOut string The error output.
$stripNewlines bool Wether to strip the newlines from STDOUT.
&$stdOut
&$errOut
Documentation generated by phpDocumentor 1.4.3