Class to retreive information about a given image file.
This class scans the specified image file and leaves the information available through the public property ezcImageAnalyzer::$data. The information available depends on the handlers used by the ezcImageAnalyzer and the type of image you select. In case the ezcImageAnalyzer does not find a suitable handler to analyze an image, it will throw a ezcImageAnalyzerFileNotProcessableException.
In this package the following handlers are available (in their priority order):
A simple example.
If you want to manipulate the handlers used by ezcImageAnalyzer, you can do this globally like this:
Or you can define your own handler classes to be used (beware, those must either be already loaded or load automatically on access).
Source for this file: /ImageAnalysis/src/analyzer.php
Version: | //autogentag// |
ezcImageAnalyzerData | read |
$data
Extended data about the image. |
string | read |
$mime
The MIME type of the image. |
protected static array |
$availableHandlers
Available handler classes and their options. |
protected static array(string=>mixed) |
$knownHandlers
Collection of known handler classes. Classes are ordered by priority. |
protected string |
$filePath
The path of the file to analyze. |
protected bool |
$isAnalyzed
Determines whether the image file has been analyzed or not. This is used internally. |
protected array(string=>mixed) |
$properties
Container to hold the properties |
public static array(string=>array(string=>string)) |
getHandlerClasses(
)
Returns an array of known handler classes. |
public static void |
setHandlerClasses(
$handlerClasses
)
Set the array of known handlers. |
public ezcImageAnalyzer |
__construct(
$file
)
Create an image analyzer for the specified file. |
public void |
analyzeImage(
)
Analyze the image file. |
public void |
analyzeType(
)
Analyze the image file's MIME type. |
protected void |
checkHandlers(
)
Check all known handlers for availability. |
Returns an array of known handler classes.
This method returns an array of available handler classes. The array is indexed by the handler names, which are assigned to an array of options set for this handler.
Set the array of known handlers.
Sets the available handlers. The array submitted must be indexed by the handler classes names (attention: handler classes must extend ezcImageAnalyzerHandler), assigned to an array of options for this handler. Most handlers don't have any options. Which options a handler may accept depends on the handler implementation.
Name | Type | Description |
---|---|---|
$handlerClasses |
array(string=>array(string=>string)) | Handlers and options. |
Create an image analyzer for the specified file.
Name | Type | Description |
---|---|---|
$file |
string | The file to analyze. |
Type | Description |
---|---|
ezcBaseFilePermissionException |
If image file is not readable. |
ezcBaseFileNotFoundException |
If image file does not exist. |
ezcImageAnalyzerFileNotProcessableException |
If the file could not be processed. |
Analyze the image file.
This method triggers a handler to analyze the given image file for more data.
Type | Description |
---|---|
ezcBaseFileIoException |
If an error occurs while the file is read. |
ezcImageAnalyzerFileNotProcessableException |
If the no handler is capable to analyze the given image file. |
Analyze the image file's MIME type.
This method triggers a handler to analyze the MIME type of the given image file.
Type | Description |
---|---|
ezcImageAnalyzerFileNotProcessableException |
If the no handler is capable to analyze the given image file. |
Check all known handlers for availability.
This method checks all registered handler classes for if the they are available (using ezcImageAnalyzerHandler::isAvailable()).
Type | Description |
---|---|
ezcImageAnalyzerInvalidHandlerException |
If a registered handler class does not exist or does not inherit from ezcImageAnalyzerHandler. |