Perforce Chronicle 2012.2/486814
API Documentation
|
Abstract class for image drivers. More...
Public Member Functions | |
__construct () | |
Deny creating an instance if required extension (if set) is not loaded. | |
getImageSize () | |
Return the image dimensions. | |
transform ($transform, $args=array()) | |
Apply the given transformation. | |
Static Public Member Functions | |
static | getRequiredExtension () |
Return php extension that must be installed to make the driver work or null if no extension is needed. | |
static | getSupportedTransforms () |
Return list of supported transformations. | |
static | isSupportedTransform ($transform) |
Determine if the given transformation is supported by this driver. | |
Protected Member Functions | |
_getImageHeight () | |
Return image height in pixels. | |
_getImageWidth () | |
Return image width in pixels. | |
Static Protected Attributes | |
static | $_requiredExtension = null |
static | $_supportedTransforms = array() |
Abstract class for image drivers.
P4Cms_Image_Driver_Abstract::__construct | ( | ) |
Deny creating an instance if required extension (if set) is not loaded.
P4Cms_Image_Exception | if the required extension is not loaded |
{ $extension = static::$_requiredExtension; if ($extension && !extension_loaded($extension)) { throw new P4Cms_Image_Exception( "Cannot create image driver: required extension '" . $extension . "' is not loaded." ); } }
P4Cms_Image_Driver_Abstract::_getImageHeight | ( | ) | [abstract, protected] |
Return image height in pixels.
Reimplemented in P4Cms_Image_Driver_Gd, and P4Cms_Image_Driver_Imagick.
P4Cms_Image_Driver_Abstract::_getImageWidth | ( | ) | [abstract, protected] |
Return image width in pixels.
Reimplemented in P4Cms_Image_Driver_Gd, and P4Cms_Image_Driver_Imagick.
P4Cms_Image_Driver_Abstract::getImageSize | ( | ) |
Return the image dimensions.
Implements P4Cms_Image_Driver_Interface.
{ // cannot get image size if there are no image data if (!$this->hasData()) { throw new P4Cms_Image_Exception( "Can not get image size: no image data were set." ); } return array( 'width' => $this->_getImageWidth(), 'height' => $this->_getImageheight() ); }
static P4Cms_Image_Driver_Abstract::getRequiredExtension | ( | ) | [static] |
Return php extension that must be installed to make the driver work or null if no extension is needed.
{ return static::$_requiredExtension; }
static P4Cms_Image_Driver_Abstract::getSupportedTransforms | ( | ) | [static] |
Return list of supported transformations.
Implements P4Cms_Image_Driver_Interface.
{ return static::$_supportedTransforms; }
static P4Cms_Image_Driver_Abstract::isSupportedTransform | ( | $ | transform | ) | [static] |
Determine if the given transformation is supported by this driver.
string | $transform | the transformation to check for |
Implements P4Cms_Image_Driver_Interface.
{
return in_array($transform, static::getSupportedTransforms());
}
P4Cms_Image_Driver_Abstract::transform | ( | $ | transform, |
$ | args = array() |
||
) |
Apply the given transformation.
string | $transform | name of the transformation |
array | $args | optional - transformation arguments |
P4Cms_Image_Exception | if given transformation is not supported |
Implements P4Cms_Image_Driver_Interface.
{ // throw an exception if transformation is not supported if (!static::isSupportedTransform($transform)) { throw new P4Cms_Image_Exception("Transformation '$transform' is not supported."); } // cannot transform if there are no image data if (!$this->hasData()) { throw new P4Cms_Image_Exception( "Cannot do '" . $transform . "': image contains no data." ); } // assemble callback function to apply given transform on the image data $callback = array('static', '_' . strtolower($transform)); if (!is_callable($callback)) { throw new P4Cms_Image_Exception("Transform '$transform' is not implemented."); } call_user_func_array($callback, $args); }
P4Cms_Image_Driver_Abstract::$_requiredExtension = null [static, protected] |
Reimplemented in P4Cms_Image_Driver_Gd, and P4Cms_Image_Driver_Imagick.
P4Cms_Image_Driver_Abstract::$_supportedTransforms = array() [static, protected] |
Reimplemented in P4Cms_Image_Driver_Gd, and P4Cms_Image_Driver_Imagick.