ImageAnalysis: ezcImageAnalyzerImagemagickHandler
[ ]
[ ]
[ ]
[ ]
[ ]
Class: ezcImageAnalyzerImagemagickHandler
|
Class to retreive information about a given image file. [
source]
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).
Parents
ezcImageAnalyzerHandler
|
--ezcImageAnalyzerImagemagickHandler
Inherited Constants
From
ezcImageAnalyzerHandler:
Member Variables
|
protected string |
$binary
The ImageMagick binary to utilize. |
|
protected bool |
$isAvailable
Indicates if this handler is available. |
|
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', '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 examned. 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 absolutly 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:
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 void |
checkImagemagick(
)
|
|
public bool |
isAvailable(
)
Checks wether the GD handler is available on the system. |
|
protected int |
runCommand(
$parameters, &$stdOut, &$errOut, $stdOut, $errOut )
Run the binary registered in ezcImageAnalyzerImagemagickHandler::$binary. |
Inherited Methods
From
ezcImageAnalyzerHandler :
Methods
analyzeExif
Analyze Exif data contained in JPEG and TIFF images.
This method analyzes the Exif data contained inf JPEG and TIFF images, using ImageMagick's "identify" binary.
Parameters
| Name |
Type |
Description |
$data |
ezcImageAnalyzerData |
The data object to fill. |
$file |
string |
The file to analyze. |
analyzeImage
Analyze the image for detailed information.
Parameters
| Name |
Type |
Description |
$file |
string |
The file to analyze. |
Throws
| Class | Description |
ezcImageAnalyzerFileNotProcessableException |
If image file can not be processed. |
Redefinition of
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 lowecase letters (e.g. "image/jpeg") or false, if the images MIME type could not be determined.
Parameters
| Name |
Type |
Description |
$file |
string |
The file to analyze. |
Redefinition of
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
checkImagemagick
void checkImagemagick(
)
isAvailable
bool isAvailable(
)
Checks wether the GD handler is available on the system.
Redefinition of
runCommand
int runCommand(
string
$parameters,
&$stdOut,
&$errOut, 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. |
&$stdOut |
|
|
&$errOut |
|
|
Last updated: Thu, 31 Jan 2008