Source for file Imagick.php
Documentation is available at Imagick.php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
* Image Transformation interface using old ImageMagick extension
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
* @package Image_Transform
* @author Peter Bowyer <peter@mapledesign.co.uk>
* @copyright 2002-2005 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version CVS: $Id: Imagick.php,v 1.9 2007/04/19 16:36:09 dufuz Exp $
* @link http://pear.php.net/package/Image_Transform
require_once 'Image/Transform.php';
* Image Transformation interface using old ImageMagick extension
* DEPRECATED: current CVS/release imagick extension should use
* Handler of the imagick image ressource
* Handler of the image ressource before
* the last transformation
if (!PEAR ::loadExtension ('imagick')) {
return PEAR ::raiseError ('The imagick extension can not be found.', true );
include 'Image/Transform/Driver/Imagick/ImageTypes.php';
* @return mixed none or a PEAR error object on error
return PEAR ::raiseError ('Cannot initialize imagick image.', true );
return PEAR ::raiseError ('The image file ' . $image . ' does\'t exist', true );
if (PEAR ::isError ($result)) {
* @param int new_x new width
* @param int new_y new width
* @param mixed $options Optional parameters
function _resize($new_x, $new_y, $options = null )
if ($img2 = imagick_copy_resize ($this->imageHandle, $new_x, $new_y, IMAGICK_FILTER_CUBIC , 1 )){
return PEAR ::raiseError ("Cannot create a new imagick imagick image for the resize.", true );
* Note: color mask are currently not supported
* @param int Rotation angle in degree
* @param array No option are actually allowed
function rotate($angle,$options=null )
if ($img2 = imagick_copy_rotate ($this->imageHandle, $angle)){
$this->new_x = imagick_get_attribute ($img2,'width');
$this->new_y = imagick_get_attribute ($img2,'height');
return PEAR ::raiseError ("Cannot create a new imagick imagick image for the resize.", true );
* @param array options Array contains options
* 'text' The string to draw
* 'x' Horizontal position
* 'size' Size of the fonts in pixel
* 'resize_first' Tell if the image has to be resized
* before drawing the text
'text' => 'This is a Text',
'resize_first' => false // Carry out the scaling of the image before annotation?
"primitive" => " text $x,$y ". $text,
* @param $filename string the name of the file to write to
function save($filename, $type= '', $quality = 75 )
imagick_setcompressionquality ($this->imageHandle, $quality);
* Display image without saving and lose changes
* @param string type (JPG,PNG...);
function display($type = '', $quality = 75 )
header('Content-type: image/' . $type);
Documentation generated on Thu, 19 Apr 2007 13:30:13 -0400 by phpDocumentor 1.3.0. PEAR Logo Copyright © PHP Group 2004.
|