Perforce image manipulation API.
More...
List of all members.
Public Member Functions |
| getData ($type=null) |
| Get the current data for the image including any pending transformations.
|
| getDriver () |
| Get the graphics library driver instance.
|
| getImageSize () |
| Return the resulting image dimensions after pending transforms have been applied.
|
| hasDriver () |
| Determine if an image driver has been set.
|
| isSupportedType ($type) |
| Check if the given image type is supported.
|
| setData ($data=null) |
| Set the data of the image.
|
| setDriver (P4Cms_Image_Driver_Interface $driver=null) |
| Set the graphics library to use.
|
| transform ($transform, $args=array()) |
| Push the given transformation on to the queue.
|
Protected Member Functions |
| _processQueue () |
| Process any pending transformations.
|
Protected Attributes |
| $_driver = null |
| $_transforms = null |
Detailed Description
Perforce image manipulation API.
The actual work is handled by implementations of P4Cms_Image_Driver_Interface.
- Copyright:
- 2011-2012 Perforce Software. All rights reserved
- License:
- Please see LICENSE.txt in top-level folder of this distribution.
- Version:
- 2012.2/486814
Member Function Documentation
P4Cms_Image::_processQueue |
( |
| ) |
[protected] |
Process any pending transformations.
{
$queue = $this->_transforms;
if ($queue) {
$driver = $this->getDriver();
while (!$queue->isEmpty()) {
$transform = $queue->dequeue();
call_user_func_array(array($driver, "transform"), $transform);
}
}
$this->_transforms = null;
}
P4Cms_Image::getData |
( |
$ |
type = null | ) |
|
Get the current data for the image including any pending transformations.
- Parameters:
-
string | $type | optional - the requested image format |
- Returns:
- string the binary image data
P4Cms_Image::getDriver |
( |
| ) |
|
Get the graphics library driver instance.
If there is no existing driver, function will try to create and set a default one.
P4Cms_Image::getImageSize |
( |
| ) |
|
Return the resulting image dimensions after pending transforms have been applied.
- Returns:
- array first element is width in pixels, second element is height in pixels
P4Cms_Image::hasDriver |
( |
| ) |
|
Determine if an image driver has been set.
- Returns:
- boolean true if we have a driver, false otherwise.
P4Cms_Image::isSupportedType |
( |
$ |
type | ) |
|
Check if the given image type is supported.
Result is dependent on the driver. Return false if unable to get a driver.
- Parameters:
-
string | $type | image type to check for |
- Returns:
- bool true if given image type is supported by the driver, false otherwise; also return false if unable to get a driver
- Exceptions:
-
InvalidArgumentException | if input $type is not a string |
{
if (!is_string($type)) {
throw new InvalidArgumentException("Type must be a string.");
}
try {
return $this->getDriver()->isSupportedType($type);
} catch (P4Cms_Image_Exception $e) {
return false;
}
}
P4Cms_Image::setData |
( |
$ |
data = null | ) |
|
Set the data of the image.
- Parameters:
-
string | null | $data | optional - the image data to use |
- Returns:
- P4Cms_Image provides fluent interface
{
if (isset($data) && !is_string($data)) {
throw new InvalidArgumentException(
'Data has to be a string or null.'
);
}
$this->getDriver()->setData($data);
return $this;
}
Set the graphics library to use.
- Parameters:
-
- Returns:
- P4Cms_Image provides fluent interface
- Exceptions:
-
{
if ($driver) {
$data = $this->hasDriver() ? $this->getData() : null;
$driver->setData($data);
}
$this->_driver = $driver;
}
P4Cms_Image::transform |
( |
$ |
transform, |
|
|
$ |
args = array() |
|
) |
| |
Push the given transformation on to the queue.
- Parameters:
-
string | $transform | name of the transformation |
array | $args | optional - transformation arguments |
- Exceptions:
-
- Returns:
- P4Cms_Image provides fluent interface
{
if (!$this->_transforms) {
$this->_transforms = new SplQueue();
}
$driver = $this->getDriver();
if (!$driver->isSupportedTransform($transform)) {
throw new P4Cms_Image_Exception(
'Transform "' . $transform . '" is not supported.'
);
}
$this->_transforms->enqueue(array($transform, $args));
return $this;
}
Member Data Documentation
P4Cms_Image::$_driver = null [protected] |
P4Cms_Image::$_transforms = null [protected] |
The documentation for this class was generated from the following file: