|
eZ Publish
[trunk]
|
Manages image operations using delegates to do the work. More...
Public Member Functions | |
| alias ($aliasName) | |
| aliasList () | |
| appendConversionRule ($conversionRule) | |
| appendImageAlias ($alias) | |
| appendImageHandler ($handler) | |
| appendMIMETypeSetting ($settings) | |
| appendQualityValue ($mimeType, $qualityValue) | |
| appendSupportedFormat ($mimeName) | |
| conversionRules () | |
| convert ($sourceMimeData, &$destinationMimeData, $aliasName=false, $parameters=array()) | |
| Converts the source image $sourceMimeData into the destination image $destinationMimeData. | |
| createAliasFromINI ($iniGroup) | |
| createFilterDataFromINI ($filterText) | |
| createImageAlias ($aliasName, &$existingAliasList, $parameters=array()) | |
| Creates the image alias $aliasName if it's not already part of the existing aliases. | |
| createImageAliasKey ($alias) | |
| eZImageManager () | |
| Singleton instance of eZImageManager used by eZImageManager::instance() Reset with eZImageManager::resetInstance(). | |
| factoryFor ($factoryName, $iniFile=false, $converterName=false) | |
| hasAlias ($aliasName) | |
| hasMIMETypeSetting ($mimeData) | |
| imageAliasInfo ($mimeData, $aliasName, $isAliasNew=false) | |
| Image information for $aliasName. | |
| isFilterAllowed ($filterName, $mimeData) | |
| isFilterSupported ($filterName) | |
| isImageAliasValid ($alias) | |
| isImageTimestampValid ($timestamp) | |
| mimeTypeFilters ($mimeData) | |
| mimeTypeOverride ($mimeData) | |
| mimeTypeSetting ($mimeData) | |
| qualityValue ($mimeType) | |
| readConversionRuleSettingsFromINI ($iniFile=false) | |
| readImageAliasesFromINI ($iniFile=false) | |
| readImageHandlersFromINI ($iniFile=false) | |
| readINISettings () | |
| readMIMETypeQualitySettingFromINI ($iniFile=false) | |
| readMIMETypeSettingFromINI ($mimeGroup, $iniFile=false) | |
| readMIMETypeSettingsFromINI ($iniFile=false) | |
| readSupportedFormatsFromINI ($iniFile=false) | |
| setSupportedFormats ($mimeList) | |
| temporaryImageDirPath () | |
Static Public Member Functions | |
| static | analyzeImage (&$mimeData, $parameters=array()) |
| static | factory () |
| Returns a shared instance of the eZImageManager class and makes it ready for use. | |
| static | instance () |
| Returns a shared instance of the eZImageManager class. | |
| static | resetInstance () |
| Reset a shared instance of the eZImageManager class and factory variable. | |
| static | wildcardToRegexp ($wildcard, $separatorCharacter=false) |
Public Attributes | |
| $DefaultRule | |
| $ImageHandlers | |
| $MIMETypes | |
| $OutputMIME | |
| $OutputMIMEMap | |
| $RuleMap | |
| $Rules | |
| $Types = array() | |
Static Protected Attributes | |
| static | $factory = false |
| static | $instance |
Manages image operations using delegates to do the work.
The manager allows for transparent conversion of one image format to another. The conversion may be done in one step if the required conversion type is available or it may build a tree of conversion rules which is needed to reach the desired end format.
It's also possible to run operations on images. It's up to each conversion rule to report whether or not the operation is supported, the manager will then distribute the operations on the available rules which can handle them. Examples of operations are scaling and grayscale.
The scale operation is special and is known to the manager directly while the other operations must be recognized by the converter.
In determing what image rules to be used the manager must first know which output types are allowed, this is set with setOutputTypes(). It takes an array of mimetypes which are allowed.
The manager must then be fed conversion rules, these tell which conversion type is used for converting from the source mimetype to the destination mimetype. The rules are set with setRules() which accepts an array of rules and a default rule as paremeter. The default rule is used when no other mimetype match is found. To create a rule you should use the createRule() function, it takes the source and destination mimetype as well as the conversion type name. Optionally it can specified whether the rule can scale or run operations.
The last thing that needs to be done is to specify the mimetypes. The manager uses mimetypes internally to know what type of image it's working on. To go from a filename to a mimetype a set of matches must be setup. The matches are created with createMIMEType() which takes the mimetype, regex filename match and suffix as parameter. The mimetypes are then registered with setMIMETypes().
See www.iana.org for information on MIME types.
Now the manager is ready and you can convert images with convert().
Example:
$img = eZImageManager::instance(); $img->registerType( "convert", new eZImageShell( '', "convert", array(), array(), array( eZImageShell::createRule( "-geometry %wx%h>", // Scale rule "modify/scale" ), eZImageShell::createRule( "-colorspace GRAY", // Grayscale rule "colorspace/gray" ) ) ) ); // Register shell program convert $img->registerType( "gd", new eZImageGD() ); // Register PHP converter GD $img->setOutputTypes( array( "image/jpeg", "image/png" ) ); // We only want jpeg and png, gif is not recommended due to licencing issues. $rules = array( $img->createRule( "image/jpeg", "image/jpeg", "GD", true, false ), // Required for scaling jpeg images $img->createRule( "image/gif", "image/png", "convert", true, false ) ); // Convert GIF to png $img->setRules( $rules, $img->createRule( "*", "image/png", "convert", true, false ) ); // Convert all other images to PNG with convert $mime_rules = array( $img->createMIMEType( "image/jpeg", "\.jpe?g$", "jpg" ), $img->createMIMEType( "image/png", "\.png$", "png" ), $img->createMIMEType( "image/gif", "\.gif$", "gif" ) ); $img->setMIMETypes( $mime_rules ); // Register mimetypes $img1 = $img->convert( "image1.gif", "cache/" ); // Convert GIF and places it in cache dir $img1 = $img->convert( "image1.png", "cache/", // Scale PNG image and place in cache dir array( "width" => 200, "height" => 200 ), // Scale parameter array( array( "rule-type" => "colorspace/gray" ) ) ); // Gray scale conversion
Definition at line 84 of file ezimagemanager.php.
| eZImageManager::alias | ( | $ | aliasName | ) |
Definition at line 200 of file ezimagemanager.php.
Referenced by createImageAliasKey().
Returns a list of defined image aliases in the image system. Each entry in the list is an associative array with the following keys:
false if no referencefalse if not defined.Definition at line 173 of file ezimagemanager.php.
Referenced by alias(), convert(), createImageAlias(), hasAlias(), and imageAliasInfo().
| static eZImageManager::analyzeImage | ( | &$ | mimeData, |
| $ | parameters = array() |
||
| ) | [static] |
Analyzes the image in the MIME structure $mimeData and fills in extra information if found.
true if the image was succesfully analyzed, false otherwise. true if there is no analyzer for the image type. Definition at line 993 of file ezimagemanager.php.
Referenced by convert(), and imageAliasInfo().
| eZImageManager::appendConversionRule | ( | $ | conversionRule | ) |
Appends a new global conversion rule.
Definition at line 592 of file ezimagemanager.php.
Referenced by readConversionRuleSettingsFromINI().
| eZImageManager::appendImageAlias | ( | $ | alias | ) |
Appends the image alias $alias to the list of defined aliases.
Definition at line 211 of file ezimagemanager.php.
Referenced by readImageAliasesFromINI().
| eZImageManager::appendImageHandler | ( | $ | handler | ) |
Appends the image handler $handler to the list of known handlers in the image system. Onces it is added the supported image filters for that handler is extracted.
Definition at line 143 of file ezimagemanager.php.
Referenced by readImageHandlersFromINI().
| eZImageManager::appendMIMETypeSetting | ( | $ | settings | ) |
Appends the MIME-Type setting $settings to the image system.
Definition at line 498 of file ezimagemanager.php.
Referenced by readMIMETypeSettingsFromINI().
| eZImageManager::appendQualityValue | ( | $ | mimeType, |
| $ | qualityValue | ||
| ) |
Binds the quality value $qualityValue to the MIME-Type $mimeType.
Definition at line 477 of file ezimagemanager.php.
Referenced by readMIMETypeQualitySettingFromINI().
| eZImageManager::appendSupportedFormat | ( | $ | mimeName | ) |
Sets which MIME-Types are allowed to use for destination format, this is an array of MIME-Type names. e.g.
$manager->setOutputTypes( array( 'image/jpeg', 'image/gif' ) );
Definition at line 131 of file ezimagemanager.php.
Referenced by readSupportedFormatsFromINI().
Definition at line 600 of file ezimagemanager.php.
| eZImageManager::convert | ( | $ | sourceMimeData, |
| &$ | destinationMimeData, | ||
| $ | aliasName = false, |
||
| $ | parameters = array() |
||
| ) |
Converts the source image $sourceMimeData into the destination image $destinationMimeData.
| mixed | $sourceMimeData | Source image, either a mimedata array or the source image path |
| mixed | $destinationMimeData | Either a mimedata array or the target image path |
| mixed | $aliasName | Target alias (small, medium, large...) |
| array | $parameters | Optional parameters. Known ones so far: (basename) |
Definition at line 1028 of file ezimagemanager.php.
Referenced by createImageAlias().
| eZImageManager::createAliasFromINI | ( | $ | iniGroup | ) |
Parses the INI group $iniGroup and creates an Image Alias from it.
Definition at line 741 of file ezimagemanager.php.
Referenced by readImageAliasesFromINI().
| eZImageManager::createFilterDataFromINI | ( | $ | filterText | ) |
Parses the filter text $filterText which is taken from an INI file and returns a filter data structure for it.
Definition at line 721 of file ezimagemanager.php.
Referenced by createAliasFromINI(), and readMIMETypeSettingFromINI().
| eZImageManager::createImageAlias | ( | $ | aliasName, |
| &$ | existingAliasList, | ||
| $ | parameters = array() |
||
| ) |
Creates the image alias $aliasName if it's not already part of the existing aliases.
| string | $aliasName | Name of the alias to create |
| array | $existingAliasList | Reference to the current alias list. The created alias will be added to the list. |
| array | $parameters | Optional array that can be used to specify the image's basename |
at first, destinationMimeData (mimedata for the alias we're generating) is the same as sourceMimeData. It will evolve as alias generation goes on
Concurrency protection startCacheGeneration will return true if the file is not already being generated by another process. If it is, it will return the maximum time before the generating process enters generation timeout
At this point, we consider that the image exists and destinationMimeData has been filled with the proper information
If we were locked during alias generation, we need to recreate this structure so that the image can actually be used, but ONLY if it was the same alias... sounds like a HUGE mess.
Can we reload the alias list somehow ?
we may want to fetch a unique name here, since we won't use the data for anything else
Definition at line 784 of file ezimagemanager.php.
| eZImageManager::createImageAliasKey | ( | $ | alias | ) |
Creates a unique key for the image alias and returns it.
Definition at line 223 of file ezimagemanager.php.
Referenced by aliasList(), and appendImageAlias().
| null eZImageManager::eZImageManager | ( | ) |
Singleton instance of eZImageManager used by eZImageManager::instance() Reset with eZImageManager::resetInstance().
Initializes the manager by registering a application/octet-stream mimetype which is applied for all unknown files.
Definition at line 90 of file ezimagemanager.php.
| static eZImageManager::factory | ( | ) | [static] |
Returns a shared instance of the eZImageManager class and makes it ready for use.
As in calls self::readINISettings() and eZImageAnalyzer::readAnalyzerSettingsFromINI()
Definition at line 1362 of file ezimagemanager.php.
Referenced by eZImageAliasHandler\aliasList(), eZImageAliasHandler\attributes(), eZPDFTable\callImage(), eZImageAliasHandler\generateXMLData(), eZImageAliasHandler\hasAttribute(), eZImageAliasHandler\imageAlias(), imageInit(), eZImageAliasHandler\initialize(), and eZImageAliasHandler\recreateDOMTree().
| eZImageManager::factoryFor | ( | $ | factoryName, |
| $ | iniFile = false, |
||
| $ | converterName = false |
||
| ) |
Finds the image handler factory with the name $factoryName and returns it.
| $iniFile | The INI file to read from or if false use 'image.ini' |
Definition at line 693 of file ezimagemanager.php.
Referenced by readImageHandlersFromINI().
| eZImageManager::hasAlias | ( | $ | aliasName | ) |
true if the image alias $aliasName exists. Definition at line 191 of file ezimagemanager.php.
Referenced by createImageAlias().
| eZImageManager::hasMIMETypeSetting | ( | $ | mimeData | ) |
true if the MIME-Type defined in $mimeData exists in the image system. Definition at line 353 of file ezimagemanager.php.
Referenced by isFilterAllowed(), mimeTypeFilters(), and mimeTypeOverride().
| eZImageManager::imageAliasInfo | ( | $ | mimeData, |
| $ | aliasName, | ||
| $ | isAliasNew = false |
||
| ) |
Image information for $aliasName.
This is the information which normally would be provided during generation of aliasName. This so that requests not holding the lock will provide meaningful information.
| mixed | $mimeData | |
| string | $aliasName |
Definition at line 1304 of file ezimagemanager.php.
| static eZImageManager::instance | ( | ) | [static] |
Returns a shared instance of the eZImageManager class.
Note: In most cases you'd want to use self:factory() instead.
Definition at line 1346 of file ezimagemanager.php.
Referenced by convert(), createAliasFromINI(), createImageAlias(), eZImageManager(), factory(), isImageTimestampValid(), readConversionRuleSettingsFromINI(), readImageAliasesFromINI(), readImageHandlersFromINI(), readMIMETypeQualitySettingFromINI(), readMIMETypeSettingFromINI(), readMIMETypeSettingsFromINI(), and readSupportedFormatsFromINI().
| eZImageManager::isFilterAllowed | ( | $ | filterName, |
| $ | mimeData | ||
| ) |
true if the filtername $filtername is allowed to be used on the type defined in $mimeData. Definition at line 438 of file ezimagemanager.php.
Referenced by convert().
| eZImageManager::isFilterSupported | ( | $ | filterName | ) |
true if the filtername $filtername is supported by any of the image handlers. Definition at line 158 of file ezimagemanager.php.
Referenced by convert().
| eZImageManager::isImageAliasValid | ( | $ | alias | ) |
true if the Image Alias $alias is valid for use. This is tested by checking the key against the key for current Image Alias settings. Definition at line 251 of file ezimagemanager.php.
| eZImageManager::isImageTimestampValid | ( | $ | timestamp | ) |
true if the timestamp $timestamp is newer than the image alias expiry timestamp. The image alias expiry timestamp will be set whenever the image aliases must be recreated.Definition at line 276 of file ezimagemanager.php.
Referenced by isImageAliasValid().
| eZImageManager::mimeTypeFilters | ( | $ | mimeData | ) |
false if no filters. Definition at line 422 of file ezimagemanager.php.
Referenced by convert().
| eZImageManager::mimeTypeOverride | ( | $ | mimeData | ) |
false if no override. Definition at line 405 of file ezimagemanager.php.
Referenced by convert().
| eZImageManager::mimeTypeSetting | ( | $ | mimeData | ) |
Definition at line 361 of file ezimagemanager.php.
Referenced by isFilterAllowed(), mimeTypeFilters(), and mimeTypeOverride().
| eZImageManager::qualityValue | ( | $ | mimeType | ) |
false if none exists. Definition at line 488 of file ezimagemanager.php.
| eZImageManager::readConversionRuleSettingsFromINI | ( | $ | iniFile = false | ) |
Reads in global conversion rules from INI file.
Definition at line 552 of file ezimagemanager.php.
Referenced by readINISettings().
| eZImageManager::readImageAliasesFromINI | ( | $ | iniFile = false | ) |
Reads all image aliases from the INI file 'image.ini' and appends them to the image system.
| $iniFile | The INI file to read from or if false use 'image.ini' |
Definition at line 293 of file ezimagemanager.php.
Referenced by readINISettings().
| eZImageManager::readImageHandlersFromINI | ( | $ | iniFile = false | ) |
Reads all settings for image handlers from the INI file 'image.ini' and appends them to the image system.
| $iniFile | The INI file to read from or if false use 'image.ini' |
Definition at line 654 of file ezimagemanager.php.
Referenced by readINISettings().
Will read in all required INI settings.
Definition at line 579 of file ezimagemanager.php.
| eZImageManager::readMIMETypeQualitySettingFromINI | ( | $ | iniFile = false | ) |
Reads MIME-Type quality settings and appends them.
Definition at line 530 of file ezimagemanager.php.
Referenced by readINISettings().
| eZImageManager::readMIMETypeSettingFromINI | ( | $ | mimeGroup, |
| $ | iniFile = false |
||
| ) |
Reads a single MIME-Type setting from the INI file 'image.ini' and appends them to the image system.
| $mimeGroup | Which INI group to read settings from. |
| $iniFile | The INI file to read from or if false use 'image.ini' |
Definition at line 612 of file ezimagemanager.php.
Referenced by readMIMETypeSettingsFromINI().
| eZImageManager::readMIMETypeSettingsFromINI | ( | $ | iniFile = false | ) |
Reads all MIME-Type settings from the INI file 'image.ini' and appends them to the image system.
| $iniFile | The INI file to read from or if false use 'image.ini' |
Definition at line 511 of file ezimagemanager.php.
Referenced by readINISettings().
| eZImageManager::readSupportedFormatsFromINI | ( | $ | iniFile = false | ) |
Reads all supported image formats from the INI file 'image.ini' and appends them to the image system.
| $iniFile | The INI file to read from or if false use 'image.ini' |
Definition at line 336 of file ezimagemanager.php.
Referenced by readINISettings().
| static eZImageManager::resetInstance | ( | ) | [static] |
Reset a shared instance of the eZImageManager class and factory variable.
As used by eZImageManager::instance() and eZImageManager::factory()
Definition at line 1379 of file ezimagemanager.php.
| eZImageManager::setSupportedFormats | ( | $ | mimeList | ) |
Sets which MIME-Types are allowed to use for destination format, this is an array of MIME-Type names. e.g.
$manager->setOutputTypes( array( 'image/jpeg', 'image/gif' ) );
Definition at line 114 of file ezimagemanager.php.
Definition at line 1335 of file ezimagemanager.php.
Referenced by convert().
| static eZImageManager::wildcardToRegexp | ( | $ | wildcard, |
| $ | separatorCharacter = false |
||
| ) | [static] |
Calls eZImageHandler::wildcardToRegexp() to generate a regular expression out of the wilcard and return it.
Definition at line 397 of file ezimagemanager.php.
Referenced by isFilterAllowed().
| eZImageManager::$DefaultRule |
Definition at line 1391 of file ezimagemanager.php.
Definition at line 1410 of file ezimagemanager.php.
Referenced by factoryFor(), and readImageHandlersFromINI().
| eZImageManager::$ImageHandlers |
Definition at line 1387 of file ezimagemanager.php.
eZImageManager::$instance [static, protected] |
Definition at line 1402 of file ezimagemanager.php.
Referenced by instance().
| eZImageManager::$MIMETypes |
Definition at line 1393 of file ezimagemanager.php.
| eZImageManager::$OutputMIME |
Definition at line 1388 of file ezimagemanager.php.
| eZImageManager::$OutputMIMEMap |
Definition at line 1389 of file ezimagemanager.php.
| eZImageManager::$RuleMap |
Definition at line 1392 of file ezimagemanager.php.
| eZImageManager::$Rules |
Definition at line 1390 of file ezimagemanager.php.
| eZImageManager::$Types = array() |
Definition at line 1394 of file ezimagemanager.php.