Path

ez components / documentation / api reference / 2009.2.1 / imageconversion


eZ Components 2009.2.1

ImageConversion: ezcImageGdBaseHandler

[ Tutorial ] [ Class tree ] [ Element index ] [ ChangeLog ] [ Credits ]

Class: ezcImageGdBaseHandler

ezcImageHandler implementation for the GD2 extension of PHP. [source]
This class only implements the base funtionality of handling GD images. If you want to manipulate images using ext/GD in your application, you should use the ezcImageGdHandler.
You can use this base class to implement your own filter set on basis of ext/GD, but you can also use ezcImageGdHandler for this and profit from its already implemented filters.

Parents

ezcImageMethodcallHandler
   |
   --ezcImageGdBaseHandler

Descendents

Child Class Description
ezcImageGdHandler ezcImageHandler implementation for the GD2 extension of PHP, including filters.

Method Summary

public ezcImageGdBaseHandler __construct( $settings )
Create a new image handler.
public void close( $image )
Close the file referenced by $image.
public static ezcImageHandlerSettings defaultSettings( )
Creates default settings for the handler and returns it.
public string load( $file, [$mime = null] )
Load an image file.
protected void replaceTransparency( $image, $color )
Replaces a transparent background with the given color.
public void save( $image, [$newFile = null], [$mime = null], [$options = null] )
Save an image file.

Methods

__construct

ezcImageGdBaseHandler __construct( ezcImageHandlerSettings $settings )
Create a new image handler.
Creates an image handler. This should never be done directly, but only through the manager for configuration reasons. One can get a direct reference through manager afterwards.

Parameters

Name Type Description
$settings ezcImageHandlerSettings Settings for the handler.

Throws

ClassDescription
ezcImageHandlerNotAvailableException If the precondition for the handler is not fulfilled.

close

void close( string $image )
Close the file referenced by $image.
Frees the image reference. You should call close() before.

Parameters

Name Type Description
$image string The image reference.

See also:

ezcImageHandler::load()ezcImageHandler::save().


defaultSettings

ezcImageHandlerSettings defaultSettings( )
Creates default settings for the handler and returns it.
The reference name will be set to 'GD'.

load

string load( string $file, [string $mime = null] )
Load an image file.
Loads an image file and returns a reference to it.

Parameters

Name Type Description
$file string File to load.
$mime string The MIME type of the file.

Throws

ClassDescription
ezcBaseFileNotFoundException If the given file does not exist.
ezcImageMimeTypeUnsupportedException If the type of the given file is not recognized
ezcImageFileNotProcessableException If the given file is not processable using this handler.
ezcImageFileNameInvalidException If an invalid character (", ', $) is found in the file name.

See also:

ezcImageAnalyzer.


replaceTransparency

void replaceTransparency( mixed $image, $color )
Replaces a transparent background with the given color.
This method is used to replace the transparent background of an image with an opaque color when converting from a transparency supporting MIME type (e.g. image/png) to a MIME type that does not support transparency.
The color

Parameters

Name Type Description
$image mixed  
$color mixed  

save

void save( string $image, [string $newFile = null], [string $mime = null], [ezcImageSaveOptions $options = null] )
Save an image file.
Saves a given open file. Can optionally save to a new file name.

Parameters

Name Type Description
$image string File reference created through load().
$newFile string Filename to save the image to.
$mime string New MIME type, if differs from initial one.
$options ezcImageSaveOptions Save options.

Throws

ClassDescription
ezcImageFileNotProcessableException If the given file could not be saved with the given MIME type.
ezcBaseFilePermissionException If the desired file exists and is not writeable.
ezcImageMimeTypeUnsupportedException If the desired MIME type is not recognized
ezcImageFileNameInvalidException If an invalid character (", ', $) is found in the file name.

See also:

ezcImageHandler::load().


Last updated: Tue, 23 Mar 2010