eZ publish Enterprise Component: ImageConversion, Design

Introduction

Find more info about the requirenments on which this design is based on in the requirenments.txt.

Design description

ezcImageManager

The main class of the component is the ezcImageManager, which implements a singleton pattern, because only 1 manager is needed for all actions performed. The ezcImageManager dispatches the actions performed on images, holds the ezcImageHandler's (which actually perform the actions) and manages / defines the ezcImageTransformations which hold conversions and ezcImageFilter's.

Since 1 filter/conversion can be performed by several ezcImageHandler's, the manager has a preference list, to determine, which ezcImageHandler to take for a conversion.

ezcImageHandler

This interface defines how the abstraction class for an image handler looks like. ezcImageHandler's utilize a given backend to perform conversion and filtering (using ezcImageFilter's). A ezcImageHandler knows by hisself, which filters he implements. The manager will ask it for supported filters to get an overview, which filters exist.

To avoid reopening an image file for every operation the ezcImageHandler has load()/save() methods. An image must be saved before another ezcImageHandler can perform his actions on it.

ezcImageFilter

This class implements a storage container for filters to keep them better consistant than an array could do. Filters are created by the ezcImageManager or directly through a ezcImageHandler. An ezcImageFilter knows, to which handler he belongs and dispatches itself to the right handler, when applied.

ezcImageTransformation

ezcImageTransformation's abstract MIME types to allow the easy combination of conversions and filters which are necessary to get a desired image type. For conversions only the target MIME type is necessary. Beside that, ezcImageTransformation's have a reference, which either points to another ezcImageTransformation or to the special reference __original__ which is the image itself.

If a ezcImageTransformation references another one, which does not exist, yet, it will be created, too. This enables one to create a chain of ezcImageTransformation's which will be processed.

ezcImageTransformation's will be created on the fly, when the user requests them and not during startup of the manager. A created ezcImageTransformation will be cached in the manager for possible later use. Same applies to the filters utilized by the ezcImageTransformation.

Example 1

Transformation: Preview
Reference: __original__
MIME:

image/JPEG

image/PNG

Filters: scale 400x400

Example 2

Transformation: Thumbnail
Reference: Preview
MIME:

image/JPEG

image/PNG

Filters:

scale 100x100

colorspace grey

Will scale down the image to 100x100 pixels and convert it to greyscale.

Example 3

Transformation: OldPhotos
Reference: original
MIME: image/JPEG
Filters:

colorspace grey

border 3

Will convert the inserted image to image/JPEG, reduce the colorspace to greyscale and add a border of 3 pixel.

^L

Local Variables: mode: rst indent-tabs-mode: nil sentence-end-double-space: t fill-column: 70 End: vim: et syn=rst tw=78 wrap