Manages image operations using delegates to do the work.
More...
List of all members.
|
Public Methods |
| eZImageManager () |
| setOutputTypes ($mimes) |
| setRules ($rules,$defrule) |
| registerType ($name,&$type) |
| ruleFor ($from) |
| isDisplayType ($type) |
& | createMIMEType ($mime,$match,$suffix) |
| setMIMETypes ($types) |
| mimeTypeFor ($file,$as_obj=false) |
& | convertRules ($from,$scale=false) |
| addScaleRule (&$rules,$scale) |
| addFilterRule (&$rules,$filter) |
| convert ($file,$dest,$scale=false,$filters=false,$mime=false) |
& | createRule ($from,$to,$type,$scale,$filter) |
& | instance () |
Private Methods |
| compressRules (&$rules,$scale) |
Detailed Description
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 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 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>",
"modify/scale" ),
eZImageShell::createRule( "-colorspace GRAY",
"colorspace/gray" ) ) ) );
$img->registerType( "gd", new eZImageGD() );
$img->setOutputTypes( array( "image/jpeg",
"image/png" ) );
$rules = array( $img->createRule( "image/jpeg", "image/jpeg", "GD", true, false ),
$img->createRule( "image/gif", "image/png", "convert", true, false ) );
$img->setRules( $rules, $img->createRule( "*", "image/png", "convert", true, false ) );
$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 );
$img1 = $img->convert( "image1.gif", "cache/" );
$img1 = $img->convert( "image1.png", "cache/",
array( "width" => 200, "height" => 200 ),
array( array( "rule-type" => "colorspace/gray" ) ) );
Definition at line ezimagemanager.php.
Constructor & Destructor Documentation
eZImageManager::eZImageManager |
( |
|
) |
|
|
Member Function Documentation
eZImageManager::addFilterRule |
( |
&$ |
rules, |
|
|
$ |
filter |
|
) |
|
|
eZImageManager::addScaleRule |
( |
&$ |
rules, |
|
|
$ |
scale |
|
) |
|
|
eZImageManager::compressRules |
( |
&$ |
rules, |
|
|
$ |
scale |
|
) |
[private] |
|
|
Compresses the rules $rules so that a minimum number of conversion is required. The scale $rule is taken into account.
Definition at line ezimagemanager.php.
Referenced by convertRules(). |
eZImageManager::convert |
( |
$ |
file, |
|
|
$ |
dest, |
|
|
$ |
scale = false, |
|
|
$ |
filters = false, |
|
|
$ |
mime = false |
|
) |
|
|
|
Converst the image file $file to an output format and places it in $dest. Scaling is handled with $scale and filters with $filters. If $mime is false then the mimetype i fetched from the $file.
Definition at line ezimagemanager.php.
References mimeTypeFor(). |
& eZImageManager::convertRules |
( |
$ |
from, |
|
|
$ |
scale = false |
|
) |
|
|
|
Returns the conversion rules which is required for transforming the mimetype $from to an output format. If scale is supplied the scaling is taking into account when compressing rules.
Definition at line ezimagemanager.php.
References isDisplayType().
Referenced by convert(). |
& eZImageManager::createMIMEType |
( |
$ |
mime, |
|
|
$ |
match, |
|
|
$ |
suffix |
|
) |
|
|
|
Creates a MIME type structure. $mime is the mimetype name, $match is the regex file match, $suffix is the filename suffix which is append to the converted filename.
Definition at line ezimagemanager.php.
Referenced by eZImageManager(). |
& eZImageManager::createRule |
( |
$ |
from, |
|
|
$ |
to, |
|
|
$ |
type, |
|
|
$ |
scale, |
|
|
$ |
filter |
|
) |
|
|
|
Creates a new conversion rule and returns it. $from the source mimetype, $to the destination mimetype, $type the image conversion type must be registered, $scale true if the rule can scale the image, $filter true if the rule can perform filters.
Definition at line ezimagemanager.php. |
& eZImageManager::instance |
( |
|
) |
|
|
eZImageManager::isDisplayType |
( |
$ |
type |
) |
|
|
eZImageManager::mimeTypeFor |
( |
$ |
file, |
|
|
$ |
as_obj = false |
|
) |
|
|
|
Returns the mimetype for the file $file. If $as_obj is true the whole mimetype structure is returned.
Definition at line ezimagemanager.php.
Referenced by convert(). |
eZImageManager::registerType |
( |
$ |
name, |
|
|
&$ |
type |
|
) |
|
|
|
Registers a new conversion type which can handle conversion and image operations. The name $name represents the conversion name which is used in the conversion rules. $type is the conversion object.
Definition at line ezimagemanager.php. |
eZImageManager::ruleFor |
( |
$ |
from |
) |
|
|
eZImageManager::setMIMETypes |
( |
$ |
types |
) |
|
|
eZImageManager::setOutputTypes |
( |
$ |
mimes |
) |
|
|
|
Sets which output types are allowed, this is an array of mimetype names.
Definition at line ezimagemanager.php. |
eZImageManager::setRules |
( |
$ |
rules, |
|
|
$ |
defrule |
|
) |
|
|
|
Sets the conversion rules to $rule and the default rule to $defrule.
Definition at line ezimagemanager.php. |
The documentation for this class was generated from the following file:
|