Apache Zeta Components Manual :: File Source for handler.php
Source for file handler.php
Documentation is available at handler.php
* This file contains the ezcImageHandler interface.
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* @package ImageConversion
* @version //autogentag//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* Driver interface to access different image manipulation backends of PHP.
* This interface has to be implemented by a handler class in order to be
* used with the ImageConversion package.
* @package ImageConversion
* @version //autogentag//
* Container to hold the properties
* @var array(string=>mixed)
* Settings of the handlers
* @var ezcImageHandlerSettings
* 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. When overwriting
* @param ezcImageHandlerSettings $settings
* Settings for the handler.
public function __construct( ezcImageHandlerSettings $settings )
$this->properties['name'] =
$settings->referenceName;
* Sets the property $name to $value.
* @throws ezcBasePropertyNotFoundException if the property does not exist.
* @throws ezcBasePropertyReadOnlyException if the property cannot be modified.
public function __set( $name, $value )
* Returns the property $name.
* @throws ezcBasePropertyNotFoundException if the property does not exist.
public function __get( $name )
* Checks if the property $name exist and returns the result.
public function __isset( $name )
* Checks a file name for illegal characters.
* Checks if a file name contains illegal characters, which are ", ' and $.
* @param string $file The file name to check.
* @throws ezcImageFileNameInvalidException
* If an invalid character (", ', $) is found in the file name.
if ( strpos( $file, "'" ) !==
false ||
strpos( $file, "'" ) !==
false ||
strpos( $file, '$' ) !==
false )
* Returns if a MIME conversion needs transparent color replacement.
* In case a transparency supporting MIME type (like image/png) is
* converted to one that does not support transparency, special steps need
* to be performed. This method returns if the given conversion from
* $inMime to $outMime is affected by this.
$transparencyMimes =
array(
&& isset
( $transparencyMimes[$inMime] )
&&
!isset
( $transparencyMimes[$outMime] )
* Loads an image file and returns a reference to it.
* For developers: The use of ezcImageHandler::loadCommon() is highly
* recommended for the implementation of this method!
* @param string $file File to load.
* @param string $mime The MIME type of the file.
* @return string Reference to the file in this handler.
abstract public function load( $file, $mime =
null );
* Saves a given open file. Can optionally save to a new file name.
* The image reference is not freed automatically, so you need to call
* the close() method explicitly to free the referenced data.
* @see ezcImageHandler::load()
* @see ezcImageHandler::close()
* @param string $image File reference created through.
* @param string $newFile Filename to save the image to.
* @param string $mime New MIME type, if differs from
* @param ezcImageSaveOptions $options Options for saving.
abstract public function save( $image, $newFile =
null, $mime =
null, ezcImageSaveOptions $options =
null );
* Close the file referenced by $image.
* Frees the image reference. You should call close() before.
* @see ezcImageHandler::load()
* @see ezcImageHandler::save()
* @param string $reference The image reference.
abstract public function close( $reference );
* Check wether a specific MIME type is allowed as input for this handler.
* @param string $mime MIME type to check if it's allowed.
* Checks wether a specific MIME type is allowed as output for this handler.
* @param string $mime MIME type to check if it's allowed.
* Checks if a given filter is available in this handler.
* @param string $name Name of the filter to check for.
* Returns a list of filters this handler provides.
* The list returned is in format:
* 0 => <string filtername>,
* 1 => <string filtername>,
* Applies a filter to a given image.
* @internal This method is the main one, which will dispatch the
* filter action to the specific function of the backend.
* @see ezcImageHandler::load()
* @see ezcImageHandler::save()
* @param string $image Image reference to apply the filter on.
* @param ezcImageFilter $filter Contains which filter operation to apply.
* @throws ezcImageFilterNotAvailableException
* If the desired filter does not exist.
* @throws ezcImageMissingFilterParameterException
* If a parameter for the filter is missing.
* @throws ezcImageFilterFailedException
* If the operation performed by the the filter failed.
* @throws ezcBaseValueException
* If a parameter was not within the expected range.
abstract public function applyFilter( $image, ezcImageFilter $filter );
* Converts an image to another MIME type.
* Use {@link ezcImageHandler::allowsOutput()} to determine,
* if the output MIME type is supported by this handler!
* @see ezcImageHandler::load()
* @see ezcImageHandler::save()
* @param string $image Image reference to convert.
* @param string $mime MIME type to convert to.
* @throws ezcImageMimeTypeUnsupportedException
* If the given MIME type is not supported by the filter.
abstract public function convert( $image, $mime );