From 554ef5d326dc5fd3d8aeb037a94e2ef0a4e15ea8 Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Tue, 26 May 2009 13:42:52 -0400 Subject: [PATCH] Horde 4-ify Horde_Image and associated changes to affected hatchery apps --- folks/lib/Driver.php | 7 +- framework/Image/Image/Effect.php | 80 ++ framework/Image/Image/Effect/border.php | 53 + framework/Image/Image/Effect/gd/drop_shadow.php | 133 +++ framework/Image/Image/Effect/gd/round_corners.php | 137 +++ framework/Image/Image/Effect/gd/text_watermark.php | 128 +++ framework/Image/Image/Effect/gd/unsharp_mask.php | 136 +++ framework/Image/Image/Effect/im/border.php | 49 + framework/Image/Image/Effect/im/composite.php | 88 ++ framework/Image/Image/Effect/im/drop_shadow.php | 83 ++ framework/Image/Image/Effect/im/photo_stack.php | 331 ++++++ framework/Image/Image/Effect/im/polaroid_image.php | 87 ++ framework/Image/Image/Effect/im/round_corners.php | 104 ++ framework/Image/Image/Effect/im/text_watermark.php | 74 ++ framework/Image/Image/gd.php | 1092 ++++++++++++++++++++ framework/Image/Image/im.php | 784 ++++++++++++++ framework/Image/Image/imagick.php | 452 ++++++++ framework/Image/Image/png.php | 246 +++++ framework/Image/Image/rgb.php | 446 ++++++++ framework/Image/Image/svg.php | 354 +++++++ framework/Image/Image/swf.php | 532 ++++++++++ framework/Image/lib/Horde/Image.php | 664 ++++++++++++ framework/Image/lib/Horde/Image/Effect.php | 91 ++ framework/Image/lib/Horde/Image/Effect/border.php | 53 + .../lib/Horde/Image/Effect/gd/drop_shadow.php | 124 +++ .../lib/Horde/Image/Effect/gd/round_corners.php | 135 +++ .../lib/Horde/Image/Effect/gd/text_watermark.php | 122 +++ .../lib/Horde/Image/Effect/gd/unsharp_mask.php | 134 +++ .../Image/lib/Horde/Image/Effect/im/border.php | 48 + .../Image/lib/Horde/Image/Effect/im/composite.php | 83 ++ .../lib/Horde/Image/Effect/im/drop_shadow.php | 84 ++ .../lib/Horde/Image/Effect/im/photo_stack.php | 328 ++++++ .../lib/Horde/Image/Effect/im/polaroid_image.php | 86 ++ .../lib/Horde/Image/Effect/im/round_corners.php | 105 ++ .../lib/Horde/Image/Effect/im/text_watermark.php | 73 ++ framework/Image/lib/Horde/Image/gd.php | 971 +++++++++++++++++ framework/Image/lib/Horde/Image/im.php | 768 ++++++++++++++ framework/Image/lib/Horde/Image/imagick.php | 446 ++++++++ framework/Image/lib/Horde/Image/png.php | 243 +++++ framework/Image/lib/Horde/Image/rgb.php | 446 ++++++++ framework/Image/lib/Horde/Image/svg.php | 338 ++++++ framework/Image/lib/Horde/Image/swf.php | 532 ++++++++++ framework/Image/package.xml | 146 +++ framework/Image/tests/.htaccess | 1 + framework/Image/tests/gd.php | 24 + framework/Image/tests/im.php | 337 ++++++ framework/Image/tests/img1.jpg | Bin 0 -> 33427 bytes framework/Image/tests/img2.jpg | Bin 0 -> 29123 bytes framework/Image/tests/img3.jpg | Bin 0 -> 29123 bytes framework/Image/tests/runtest.php | 44 + framework/Image/tests/svg.php | 24 + framework/Image/tests/swf.php | 24 + imp/lib/Mime/Viewer/Images.php | 9 +- imp/lib/Mime/Viewer/Pdf.php | 3 +- 54 files changed, 11875 insertions(+), 7 deletions(-) create mode 100644 framework/Image/Image/Effect.php create mode 100644 framework/Image/Image/Effect/border.php create mode 100644 framework/Image/Image/Effect/gd/drop_shadow.php create mode 100644 framework/Image/Image/Effect/gd/round_corners.php create mode 100644 framework/Image/Image/Effect/gd/text_watermark.php create mode 100644 framework/Image/Image/Effect/gd/unsharp_mask.php create mode 100755 framework/Image/Image/Effect/im/border.php create mode 100755 framework/Image/Image/Effect/im/composite.php create mode 100644 framework/Image/Image/Effect/im/drop_shadow.php create mode 100644 framework/Image/Image/Effect/im/photo_stack.php create mode 100755 framework/Image/Image/Effect/im/polaroid_image.php create mode 100644 framework/Image/Image/Effect/im/round_corners.php create mode 100644 framework/Image/Image/Effect/im/text_watermark.php create mode 100644 framework/Image/Image/gd.php create mode 100644 framework/Image/Image/im.php create mode 100644 framework/Image/Image/imagick.php create mode 100644 framework/Image/Image/png.php create mode 100644 framework/Image/Image/rgb.php create mode 100644 framework/Image/Image/svg.php create mode 100644 framework/Image/Image/swf.php create mode 100644 framework/Image/lib/Horde/Image.php create mode 100644 framework/Image/lib/Horde/Image/Effect.php create mode 100644 framework/Image/lib/Horde/Image/Effect/border.php create mode 100644 framework/Image/lib/Horde/Image/Effect/gd/drop_shadow.php create mode 100644 framework/Image/lib/Horde/Image/Effect/gd/round_corners.php create mode 100644 framework/Image/lib/Horde/Image/Effect/gd/text_watermark.php create mode 100644 framework/Image/lib/Horde/Image/Effect/gd/unsharp_mask.php create mode 100755 framework/Image/lib/Horde/Image/Effect/im/border.php create mode 100755 framework/Image/lib/Horde/Image/Effect/im/composite.php create mode 100644 framework/Image/lib/Horde/Image/Effect/im/drop_shadow.php create mode 100644 framework/Image/lib/Horde/Image/Effect/im/photo_stack.php create mode 100755 framework/Image/lib/Horde/Image/Effect/im/polaroid_image.php create mode 100644 framework/Image/lib/Horde/Image/Effect/im/round_corners.php create mode 100644 framework/Image/lib/Horde/Image/Effect/im/text_watermark.php create mode 100644 framework/Image/lib/Horde/Image/gd.php create mode 100644 framework/Image/lib/Horde/Image/im.php create mode 100644 framework/Image/lib/Horde/Image/imagick.php create mode 100644 framework/Image/lib/Horde/Image/png.php create mode 100644 framework/Image/lib/Horde/Image/rgb.php create mode 100644 framework/Image/lib/Horde/Image/svg.php create mode 100644 framework/Image/lib/Horde/Image/swf.php create mode 100644 framework/Image/package.xml create mode 100644 framework/Image/tests/.htaccess create mode 100644 framework/Image/tests/gd.php create mode 100644 framework/Image/tests/im.php create mode 100644 framework/Image/tests/img1.jpg create mode 100644 framework/Image/tests/img2.jpg create mode 100644 framework/Image/tests/img3.jpg create mode 100644 framework/Image/tests/runtest.php create mode 100644 framework/Image/tests/svg.php create mode 100644 framework/Image/tests/swf.php diff --git a/folks/lib/Driver.php b/folks/lib/Driver.php index fbbe840af..c2f8744ae 100644 --- a/folks/lib/Driver.php +++ b/folks/lib/Driver.php @@ -91,11 +91,14 @@ class Folks_Driver { $p = hash('md5', $user); $vfspath = Folks::VFS_PATH . '/' . substr(str_pad($p, 2, 0, STR_PAD_LEFT), -2) . '/'; $vfs_name = $p . '.' . $conf['images']['image_type']; - $driver = empty($conf['image']['convert']) ? 'gd' : 'im'; + $context = array('tmpdir' => Horde::getTempDir()); + if (!empty($conf['image']['convert'])) { + $context['convert'] = $conf['image']['convert']; + } $img = Horde_Image::factory($driver, array('type' => $conf['images']['image_type'], - 'temp' => Horde::getTempDir())); + 'context' => $context)); $result = $img->loadFile($file); if ($result instanceof PEAR_Error) { diff --git a/framework/Image/Image/Effect.php b/framework/Image/Image/Effect.php new file mode 100644 index 000000000..414356565 --- /dev/null +++ b/framework/Image/Image/Effect.php @@ -0,0 +1,80 @@ + + * @author Michael J. Rubinsky + * @since Horde 3.2 + * @package Horde_Image + */ +class Horde_Image_Effect { + + /** + * Effect parameters. + * + * @var array + */ + var $_params = array(); + + var $_image = null; + + /** + * Effect constructor. + * + * @param array $params Any parameters for the effect. Parameters are + * documented in each subclass. + */ + function Horde_Image_Effect($params = array()) + { + foreach ($params as $key => $val) { + $this->_params[$key] = $val; + } + } + + function _setImageObject(&$image) + { + $this->_image = &$image; + } + + function factory($type, $driver, $params) + { + if (is_array($type)) { + list($app, $type) = $type; + } + + // First check for a driver specific effect, if we can't find one, + // assume there is a vanilla effect object around. + $class = 'Horde_Image_Effect_' . $driver . '_' . $type; + $vclass = 'Horde_Image_Effect_' . $type; + if (!class_exists($class) && !class_exists($vclass)) { + if (!empty($app)) { + $path = $GLOBALS['registry']->get('fileroot', $app) . '/lib/Image/Effect/' . $driver . '/' . $type . '.php'; + } else { + $path = 'Horde/Image/Effect/' . $driver . '/' . $type . '.php'; + } + + @include_once $path; + if (!class_exists($class)) { + if (!empty($app)) { + $path = $GLOBALS['registry']->get('fileroot', $app) . '/lib/Image/Effect/' . $type . '.php'; + } else { + $path = 'Horde/Image/Effect/' . $type . '.php'; + } + $class = $vclass; + @include_once $path; + } + } + if (class_exists($class)) { + $effect = new $class($params); + } else { + $effect = PEAR::raiseError(sprintf("Horde_Image_Effect %s for %s driver not found.", $type, $driver)); + } + + return $effect; + } + + +} diff --git a/framework/Image/Image/Effect/border.php b/framework/Image/Image/Effect/border.php new file mode 100644 index 000000000..dbc91d11d --- /dev/null +++ b/framework/Image/Image/Effect/border.php @@ -0,0 +1,53 @@ + + * @package Horde_Image + */ +class Horde_Image_Effect_border extends Horde_Image_Effect { + + /** + * Valid parameters for border decorators: + * + * padding - Pixels from the image edge that the border will start. + * borderColor - Border color. Defaults to black. + * fillColor - Color to fill the border with. Defaults to white. + * lineWidth - Border thickness, defaults to 1 pixel. + * roundWidth - Width of the corner rounding. Defaults to none. + * + * @var array + */ + var $_params = array('padding' => 0, + 'borderColor' => 'black', + 'fillColor' => 'white', + 'lineWidth' => 1, + 'roundWidth' => 0); + + /** + * Draw the border. + * + * This draws the configured border to the provided image. Beware, + * that every pixel inside the border clipping will be overwritten + * with the background color. + */ + function apply() + { + $o = $this->_params; + + $d = $this->_image->getDimensions(); + $x = $o['padding']; + $y = $o['padding']; + $width = $d['width'] - (2 * $o['padding']); + $height = $d['height'] - (2 * $o['padding']); + + if ($o['roundWidth'] > 0) { + $this->_image->roundedRectangle($x, $y, $width, $height, $o['roundWidth'], $o['borderColor'], $o['fillColor']); + } else { + $this->_image->rectangle($x, $y, $width, $height, $o['borderColor'], $o['fillColor']); + } + } + +} diff --git a/framework/Image/Image/Effect/gd/drop_shadow.php b/framework/Image/Image/Effect/gd/drop_shadow.php new file mode 100644 index 000000000..46619dfe0 --- /dev/null +++ b/framework/Image/Image/Effect/gd/drop_shadow.php @@ -0,0 +1,133 @@ +. Modifications made to the code + * to fit it within the Horde framework and to adjust for our coding standards. + * + * @author Michael J. Rubinsky + * @since Horde 3.2 + * @package Horde_Image + */ +class Horde_Image_Effect_gd_drop_shadow extends Horde_Image_Effect { + + /** + * Valid parameters: + * + * @TODO + * + * @var array + */ + var $_params = array('distance' => 5, + 'width' => 2, + 'hexcolor' => '000000', + 'angle' => 215, + 'fade' => 10); + + /** + * Apply the drop_shadow effect. + * + * @return mixed true | PEAR_Error + */ + function apply() + { + $distance = $this->_params['distance']; + $width = $this->_params['width']; + $hexcolor = $this->_params['hexcolor']; + $angle = $this->_params['angle']; + $fade = $this->_params['fade']; + + $width_shadow = cos(deg2rad($angle)) * ($distance + $width); + $height_shadow = sin(deg2rad($angle)) * ($distance + $width); + $gdimg = $this->_image->_im; + $imgX = $this->_image->_call('imageSX', array($gdimg)); + $imgY = $this->_image->_call('imageSY', array($gdimg)); + + $offset['x'] = cos(deg2rad($angle)) * ($distance + $width - 1); + $offset['y'] = sin(deg2rad($angle)) * ($distance + $width - 1); + + $tempImageWidth = $imgX + abs($offset['x']); + $tempImageHeight = $imgY + abs($offset['y']); + $gdimg_dropshadow_temp = $this->_image->_create($tempImageWidth, + $tempImageHeight); + if (!is_a($gdimg_dropshadow_temp, 'PEAR_Error')) { + $this->_image->_call('imageAlphaBlending', + array($gdimg_dropshadow_temp, false)); + + $this->_image->_call('imageSaveAlpha', + array($gdimg_dropshadow_temp, true)); + + $transparent1 = $this->_image->_allocateColorAlpha($gdimg_dropshadow_temp, + 0, 0, 0, 127); + + if (is_a($transparent1, 'PEAR_Error')) { + return $transparent1; + } + + $this->_image->_call('imageFill', + array($gdimg_dropshadow_temp, 0, 0, $transparent1)); + + for ($x = 0; $x < $imgX; $x++) { + for ($y = 0; $y < $imgY; $y++) { + $colorat = $this->_image->_call('imageColorAt', array($gdimg, $x, $y)); + $PixelMap[$x][$y] = $this->_image->_call('imageColorsForIndex', + array($gdimg, $colorat)); + } + } + + /* Creates the shadow */ + $r = hexdec(substr($hexcolor, 0, 2)); + $g = hexdec(substr($hexcolor, 2, 2)); + $b = hexdec(substr($hexcolor, 4, 2)); + + /* Essentially masks the original image and creates the shadow */ + for ($x = 0; $x < $tempImageWidth; $x++) { + for ($y = 0; $y < $tempImageHeight; $y++) { + if (!isset($PixelMap[$x][$y]['alpha']) || + ($PixelMap[$x][$y]['alpha'] > 0)) { + if (isset($PixelMap[$x + $offset['x']][$y + $offset['y']]['alpha']) && ($PixelMap[$x + $offset['x']][$y + $offset['y']]['alpha'] < 127)) { + $thisColor = $this->_image->_allocateColorAlpha($gdimg_dropshadow_temp, $r, $g, $b, $PixelMap[$x + $offset['x']][$y + $offset['y']]['alpha']); + $this->_image->_call('imageSetPixel', + array($gdimg_dropshadow_temp, $x, $y, $thisColor)); + } + } + } + } + /* Overlays the original image */ + $this->_image->_call('imageAlphaBlending', + array($gdimg_dropshadow_temp, true)); + + for ($x = 0; $x < $imgX; $x++) { + for ($y = 0; $y < $imgY; $y++) { + if ($PixelMap[$x][$y]['alpha'] < 127) { + $thisColor = $this->_image->_allocateColorAlpha($gdimg_dropshadow_temp, $PixelMap[$x][$y]['red'], $PixelMap[$x][$y]['green'], $PixelMap[$x][$y]['blue'], $PixelMap[$x][$y]['alpha']); + $this->_image->_call('imageSetPixel', + array($gdimg_dropshadow_temp, $x, $y, $thisColor)); + } + } + } + + $this->_image->_call('imageSaveAlpha', + array($gdimg, true)); + $this->_image->_call('imageAlphaBlending', + array($gdimg, false)); + + // Why are we flood filling with alpha on the original?///// + //$transparent2 = $this->_image->_allocateColorAlpha($gdimg, 0, 0, 0, 127); + //$this->_image->_call('imageFilledRectangle', + // array($gdimg, 0, 0, $imgX, $imgY, $transparent2)); + + // Merge the shadow and the original into the original. + $this->_image->_call('imageCopyResampled', + array($gdimg, $gdimg_dropshadow_temp, 0, 0, 0, 0, $imgX, $imgY, $this->_image->_call('imageSX', array($gdimg_dropshadow_temp)), $this->_image->_call('imageSY', array($gdimg_dropshadow_temp)))); + + $this->_image->_call('imageDestroy', array($gdimg_dropshadow_temp)); + } + return true; + } + +} diff --git a/framework/Image/Image/Effect/gd/round_corners.php b/framework/Image/Image/Effect/gd/round_corners.php new file mode 100644 index 000000000..70a27e79c --- /dev/null +++ b/framework/Image/Image/Effect/gd/round_corners.php @@ -0,0 +1,137 @@ +. Modifications made to the code + * to fit it within the Horde framework and to adjust for our coding standards. + * + * @author Michael J. Rubinsky + * @since Horde 3.2 + * @package Horde_Image + */ +class Horde_Image_Effect_gd_round_corners extends Horde_Image_Effect { + + /** + * Valid parameters: + * + * radius - Radius of rounded corners. + * + * @var array + */ + var $_params = array('radius' => 10); + + /** + * Apply the round_corners effect. + * + * @return mixed true | PEAR_Error + */ + function apply() + { + // Original comments from phpThumb projet: + // generate mask at twice desired resolution and downsample afterwards + // for easy antialiasing mask is generated as a white double-size + // elipse on a triple-size black background and copy-paste-resampled + // onto a correct-size mask image as 4 corners due to errors when the + // entire mask is resampled at once (gray edges) + $radius_x = $radius_y = $this->_params['radius']; + $gdimg = $this->_image->_im; + $imgX = round($this->_image->_call('imageSX', array($gdimg))); + $imgY = round($this->_image->_call('imageSY', array($gdimg))); + + $gdimg_cornermask_triple = $this->_image->_create(round($radius_x * 6), + round($radius_y * 6)); + if (!is_a($gdimg_cornermask_triple, 'PEAR_Error')) { + + $gdimg_cornermask = $this->_image->_create($imgX, $imgY); + if (!is_a($gdimg_cornermask, 'PEAR_Error')) { + $color_transparent = $this->_image->_call('imageColorAllocate', + array($gdimg_cornermask_triple, + 255, + 255, + 255)); + + $this->_image->_call('imageFilledEllipse', + array($gdimg_cornermask_triple, + $radius_x * 3, + $radius_y * 3, + $radius_x * 4, + $radius_y * 4, + $color_transparent)); + + $this->_image->_call('imageFilledRectangle', + array($gdimg_cornermask, + 0, + 0, + $imgX, + $imgY, + $color_transparent)); + + $this->_image->_call('imageCopyResampled', + array($gdimg_cornermask, + $gdimg_cornermask_triple, + 0, + 0, + $radius_x, + $radius_y, + $radius_x, + $radius_y, + $radius_x * 2, + $radius_y * 2)); + + $this->_image->_call('imageCopyResampled', + array($gdimg_cornermask, + $gdimg_cornermask_triple, + 0, + $imgY - $radius_y, + $radius_x, + $radius_y * 3, + $radius_x, + $radius_y, + $radius_x * 2, + $radius_y * 2)); + + $this->_image->_call('imageCopyResampled', + array($gdimg_cornermask, + $gdimg_cornermask_triple, + $imgX - $radius_x, + $imgY - $radius_y, + $radius_x * 3, + $radius_y * 3, + $radius_x, + $radius_y, + $radius_x * 2, + $radius_y * 2)); + + $this->_image->_call('imageCopyResampled', + array($gdimg_cornermask, + $gdimg_cornermask_triple, + $imgX - $radius_x, + 0, + $radius_x * 3, + $radius_y, + $radius_x, + $radius_y, + $radius_x * 2, + $radius_y * 2)); + + $result = $this->_image->_applyMask($gdimg_cornermask); + if (is_a($result, 'PEAR_Error')) { + return $result; + } + $this->_image->_call('imageDestroy', array($gdimg_cornermask)); + return true; + } else { + return $gdimg_cornermas; // PEAR_Error + } + $this->_image->_call('imageDestroy', + array($gdimg_cornermask_triple)); + } else { + return $gdimg_cornermas_triple; // PEAR_Error + } + } + +} diff --git a/framework/Image/Image/Effect/gd/text_watermark.php b/framework/Image/Image/Effect/gd/text_watermark.php new file mode 100644 index 000000000..320a38d2e --- /dev/null +++ b/framework/Image/Image/Effect/gd/text_watermark.php @@ -0,0 +1,128 @@ + + * @package Horde_Image + */ +class Horde_Image_Effect_gd_text_watermark extends Horde_Image_Effect { + + /** + * Valid parameters for watermark effects: + * + * text (required) - The text of the watermark. + * halign - The horizontal placement + * valign - The vertical placement + * font - The font name or family to use + * fontsize - The size of the font to use + * (small, medium, large, giant) + * + * @var array + */ + var $_params = array('halign' => 'right', + 'valign' => 'bottom', + 'font' => 'courier', + 'fontsize' => 'small'); + + /** + * Add the watermark + */ + function apply() + { + $color = $this->_image->_call('imageColorClosest', + array($this->_image->_im, 255, 255, 255)); + if (is_a($color, 'PEAR_Error')) { + return $color; + } + $shadow = $this->_image->_call('imageColorClosest', + array($this->_image->_im, 0, 0, 0)); + if (is_a($shadow, 'PEAR_Error')) { + return $shadow; + } + + // Shadow offset in pixels. + $drop = 1; + + // Maximum text width. + $maxwidth = 200; + + // Amount of space to leave between the text and the image + // border. + $padding = 10; + + $f = $this->_image->getFont($this->_params['fontsize']); + $fontwidth = $this->_image->_call('imageFontWidth', array($f)); + if (is_a($fontwidth, 'PEAR_Error')) { + return $fontwidth; + } + $fontheight = $this->_image->_call('imageFontHeight', array($f)); + if (is_a($fontheight, 'PEAR_Error')) { + return $fontheight; + } + + // So that shadow is not off the image with right align and + // bottom valign. + $margin = floor($padding + $drop) / 2; + + if ($maxwidth) { + $maxcharsperline = floor(($maxwidth - ($margin * 2)) / $fontwidth); + $text = wordwrap($this->_params['text'], $maxcharsperline, "\n", 1); + } + + // Split $text into individual lines. + $lines = explode("\n", $text); + + switch ($this->_params['valign']) { + case 'center': + $y = ($this->_image->_call('imageSY', array($this->_image->_im)) - ($fontheight * count($lines))) / 2; + break; + + case 'bottom': + $y = $this->_image->_call('imageSY', array($this->_image->_im)) - (($fontheight * count($lines)) + $margin); + break; + + default: + $y = $margin; + break; + } + + switch ($this->_params['halign']) { + case 'right': + foreach ($lines as $line) { + if (is_a($result = $this->_image->_call('imageString', array($this->_image->_im, $f, ($this->_image->_call('imageSX', array($this->_image->_im)) - $fontwidth * strlen($line)) - $margin + $drop, ($y + $drop), $line, $shadow)), 'PEAR_Error')) { + return $result; + } + $result = $this->_image->_call('imageString', array($this->_image->_im, $f, ($this->_image->_call('imageSX', array($this->_image->_im)) - $fontwidth * strlen($line)) - $margin, $y, $line, $color)); + $y += $fontheight; + } + break; + + case 'center': + foreach ($lines as $line) { + if (is_a($result = $this->_image->_call('imageString', array($this->_image->_im, $f, floor(($this->_image->_call('imageSX', array($this->_image->_im)) - $fontwidth * strlen($line)) / 2) + $drop, ($y + $drop), $line, $shadow)), 'PEAR_Error')) { + return $result; + } + $result = $this->_image->_call('imageString', array($this->_image->_im, $f, floor(($this->_image->_call('imageSX', array($this->_image->_im)) - $fontwidth * strlen($line)) / 2), $y, $line, $color)); + $y += $fontheight; + } + break; + + default: + foreach ($lines as $line) { + if (is_a($result = $this->_image->_call('imageString', array($this->_image->_im, $f, $margin + $drop, ($y + $drop), $line, $shadow)), 'PEAR_Error')) { + return $result; + } + $result = $this->_image->_call('imageString', array($this->_image->_im, $f, $margin, $y, $line, $color)); + $y += $fontheight; + } + break; + } + + if (is_a($result, 'PEAR_Error')) { + return $result; + } + } + +} diff --git a/framework/Image/Image/Effect/gd/unsharp_mask.php b/framework/Image/Image/Effect/gd/unsharp_mask.php new file mode 100644 index 000000000..269f465eb --- /dev/null +++ b/framework/Image/Image/Effect/gd/unsharp_mask.php @@ -0,0 +1,136 @@ + + * From: http://www.vikjavev.com/hovudsida/umtestside.php + * + * @package Horde_Image + */ +class Horde_Image_Effect_gd_unsharp_mask extends Horde_Image_Effect { + + /** + * Valid parameters: + * + * @TODO + * + * @var array + */ + var $_params = array('amount' => 0, + 'radius' => 0, + 'threshold' => 0); + + /** + * Apply the unsharp_mask effect. + * + * @return mixed true | PEAR_Error + */ + function apply() + { + $amount = $this->_params['amount']; + $radius = $this->_params['radius']; + $threshold = $this->_params['threshold']; + + // Attempt to calibrate the parameters to Photoshop: + $amount = min($amount, 500); + $amount = $amount * 0.016; + if ($amount == 0) { + return true; + } + + $radius = min($radius, 50); + $radius = $radius * 2; + + $threshold = min($threshold, 255); + + $radius = abs(round($radius)); // Only integers make sense. + if ($radius == 0) { + return true; + } + + $img = $this->_image->_im; + $w = ImageSX($img); + $h = ImageSY($img); + $imgCanvas = ImageCreateTrueColor($w, $h); + $imgCanvas2 = ImageCreateTrueColor($w, $h); + $imgBlur = ImageCreateTrueColor($w, $h); + $imgBlur2 = ImageCreateTrueColor($w, $h); + ImageCopy($imgCanvas, $img, 0, 0, 0, 0, $w, $h); + ImageCopy($imgCanvas2, $img, 0, 0, 0, 0, $w, $h); + + // Gaussian blur matrix: + // + // 1 2 1 + // 2 4 2 + // 1 2 1 + // + ////////////////////////////////////////////////// + + // Move copies of the image around one pixel at the time and merge them with weight + // according to the matrix. The same matrix is simply repeated for higher radii. + for ($i = 0; $i < $radius; $i++) { + ImageCopy ($imgBlur, $imgCanvas, 0, 0, 1, 1, $w - 1, $h - 1); // up left + ImageCopyMerge($imgBlur, $imgCanvas, 1, 1, 0, 0, $w, $h, 50); // down right + ImageCopyMerge($imgBlur, $imgCanvas, 0, 1, 1, 0, $w - 1, $h, 33.33333); // down left + ImageCopyMerge($imgBlur, $imgCanvas, 1, 0, 0, 1, $w, $h - 1, 25); // up right + ImageCopyMerge($imgBlur, $imgCanvas, 0, 0, 1, 0, $w - 1, $h, 33.33333); // left + ImageCopyMerge($imgBlur, $imgCanvas, 1, 0, 0, 0, $w, $h, 25); // right + ImageCopyMerge($imgBlur, $imgCanvas, 0, 0, 0, 1, $w, $h - 1, 20 ); // up + ImageCopyMerge($imgBlur, $imgCanvas, 0, 1, 0, 0, $w, $h, 16.666667); // down + ImageCopyMerge($imgBlur, $imgCanvas, 0, 0, 0, 0, $w, $h, 50); // center + ImageCopy ($imgCanvas, $imgBlur, 0, 0, 0, 0, $w, $h); + + // During the loop above the blurred copy darkens, possibly due to a roundoff + // error. Therefore the sharp picture has to go through the same loop to + // produce a similar image for comparison. This is not a good thing, as processing + // time increases heavily. + ImageCopy ($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h); + ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 50); + ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 33.33333); + ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 25); + ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 33.33333); + ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 25); + ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 20 ); + ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 16.666667); + ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 50); + ImageCopy ($imgCanvas2, $imgBlur2, 0, 0, 0, 0, $w, $h); + } + + // Calculate the difference between the blurred pixels and the original + // and set the pixels + for ($x = 0; $x < $w; $x++) { // each row + for ($y = 0; $y < $h; $y++) { // each pixel + + $rgbOrig = ImageColorAt($imgCanvas2, $x, $y); + $rOrig = (($rgbOrig >> 16) & 0xFF); + $gOrig = (($rgbOrig >> 8) & 0xFF); + $bOrig = ($rgbOrig & 0xFF); + + $rgbBlur = ImageColorAt($imgCanvas, $x, $y); + $rBlur = (($rgbBlur >> 16) & 0xFF); + $gBlur = (($rgbBlur >> 8) & 0xFF); + $bBlur = ($rgbBlur & 0xFF); + + // When the masked pixels differ less from the original + // than the threshold specifies, they are set to their original value. + $rNew = (abs($rOrig - $rBlur) >= $threshold) ? max(0, min(255, ($amount * ($rOrig - $rBlur)) + $rOrig)) : $rOrig; + $gNew = (abs($gOrig - $gBlur) >= $threshold) ? max(0, min(255, ($amount * ($gOrig - $gBlur)) + $gOrig)) : $gOrig; + $bNew = (abs($bOrig - $bBlur) >= $threshold) ? max(0, min(255, ($amount * ($bOrig - $bBlur)) + $bOrig)) : $bOrig; + + if (($rOrig != $rNew) || ($gOrig != $gNew) || ($bOrig != $bNew)) { + $pixCol = ImageColorAllocate($img, $rNew, $gNew, $bNew); + ImageSetPixel($img, $x, $y, $pixCol); + } + } + } + ImageDestroy($imgCanvas); + ImageDestroy($imgCanvas2); + ImageDestroy($imgBlur); + ImageDestroy($imgBlur2); + + return true; + } + +} diff --git a/framework/Image/Image/Effect/im/border.php b/framework/Image/Image/Effect/im/border.php new file mode 100755 index 000000000..e668edd3a --- /dev/null +++ b/framework/Image/Image/Effect/im/border.php @@ -0,0 +1,49 @@ + + * @package Horde_Image + */ +class Horde_Image_Effect_im_border extends Horde_Image_Effect { + + /** + * Valid parameters for border effects: + * + * bordercolor - Border color. Defaults to black. + * borderwidth - Border thickness, defaults to 1 pixel. + * preserve - Preserves the alpha transparency layer (if present) + * + * @var array + */ + var $_params = array('bordercolor' => 'black', + 'borderwidth' => 1, + 'preserve' => true); + + /** + * Draw the border. + * + * This draws the configured border to the provided image. Beware, + * that every pixel inside the border clipping will be overwritten + * with the background color. + */ + function apply() + { + if (!is_null($this->_image->_imagick)) { + $this->_image->_imagick->borderImage( + $this->_params['bordercolor'], + $this->_params['borderwidth'], + $this->_params['borderwidth']); + } else { + $this->_image->_postSrcOperations[] = sprintf( + " -bordercolor \"%s\" %s -border %s", + $this->_params['bordercolor'], + (!empty($this->_params['preserve']) ? '-compose Copy' : ''), + $this->_params['borderwidth']); + } + return true; + } + +} diff --git a/framework/Image/Image/Effect/im/composite.php b/framework/Image/Image/Effect/im/composite.php new file mode 100755 index 000000000..f49fabb4e --- /dev/null +++ b/framework/Image/Image/Effect/im/composite.php @@ -0,0 +1,88 @@ + + * @package Horde_Image + */ +class Horde_Image_Effect_im_composite extends Horde_Image_Effect { + + /** + * Valid parameters for border effects: + * + * 'images' - an array of Horde_Image objects to overlay. + * + * ...and ONE of the following. If both are provided, the behaviour is + * undefined. + * + * 'gravity' - the ImageMagick gravity constant describing placement + * (IM driver only so far, not imagick) + * + * 'x' and 'y' - coordinates for the overlay placement. + * + * @var array + */ + var $_params = array(); + + /** + * Draw the border. + * + * This draws the configured border to the provided image. Beware, + * that every pixel inside the border clipping will be overwritten + * with the background color. + */ + function apply() + { + $this->_image->_imagick = null; + if (!is_null($this->_image->_imagick)) { + foreach ($this->_params['images'] as $image) { + $topimg = new Horde_Image_ImagickProxy(); + $topimg->clear(); + $topimg->readImageBlob($image->raw()); + + /* Calculate center for composite (gravity center)*/ + $geometry = $this->_image->_imagick->getImageGeometry(); + $x = $geometry['width'] / 2; + $y = $geometry['height'] / 2; + + if (isset($this->_params['x']) && isset($this->_params['y'])) { + $x = $this->_params['x']; + $y = $this->_params['y']; + } + $this->_image->_imagick->compositeImage($topimg, constant('Imagick::COMPOSITE_OVER'), $x, $y); + } + } else { + $ops = $geometry = $gravity = ''; + if (isset($this->_params['gravity'])) { + $gravity = ' -gravity ' . $this->_params['gravity']; + } + + if (isset($this->_params['x']) && isset($this->_params['y'])) { + $geometry = ' -geometry +' . $this->_params['x'] . '+' . $this->_params['y'] . ' '; + } + if (isset($this->_params['compose'])) { + // The -matte ensures that the destination (background) image + // has an alpha channel - to avoid black holes in the image. + $compose = ' -compose ' . $this->_params['compose'] . ' -matte'; + } + + foreach($this->_params['images'] as $image) { + $temp = $image->toFile(); + $this->_image->_toClean[] = $temp; + $ops .= ' ' . $temp . $gravity . $compose . ' -composite'; + } + $this->_image->_operations[] = $geometry; + $this->_image->_postSrcOperations[] = $ops; + } + return true; + } + +} + + + diff --git a/framework/Image/Image/Effect/im/drop_shadow.php b/framework/Image/Image/Effect/im/drop_shadow.php new file mode 100644 index 000000000..20b8d0ae7 --- /dev/null +++ b/framework/Image/Image/Effect/im/drop_shadow.php @@ -0,0 +1,83 @@ + + * @since Horde 3.2 + * @package Horde_Image + */ +class Horde_Image_Effect_im_drop_shadow extends Horde_Image_Effect { + + /** + * Valid parameters: Most are currently ignored for the im version + * of this effect. + * + * @TODO + * + * @var array + */ + var $_params = array('distance' => 5, // This is used as the x and y offset + 'width' => 2, + 'hexcolor' => '000000', + 'angle' => 215, + 'fade' => 3, // Sigma value + 'padding' => 0, + 'background' => 'none'); + + /** + * Apply the effect. + * + * @return mixed true | PEAR_Error + */ + function apply() + { + if (!is_null($this->_image->_imagick)) { + // $shadow is_a ImagickProxy object + $shadow = $this->_image->_imagick->cloneIM(); + $shadow->setImageBackgroundColor('black'); + $shadow->shadowImage(80, $this->_params['fade'], + $this->_params['distance'], + $this->_params['distance']); + + + // If we have an actual background color, we need to explicitly + // create a new background image with that color to be sure there + // *is* a background color. + if ($this->_params['background'] != 'none') { + $size = $shadow->getImageGeometry(); + $new = new Horde_Image_ImagickProxy($size['width'], + $size['height'], + $this->_params['background'], + $this->_image->_type); + + $new->compositeImage($shadow, + constant('Imagick::COMPOSITE_OVER'), 0, 0); + $shadow->clear(); + $shadow->addImage($new); + $new->destroy(); + } + + if ($this->_params['padding']) { + $shadow->borderImage($this->_params['background'], + $this->_params['padding'], + $this->_params['padding']); + } + $shadow->compositeImage($this->_image->_imagick, + constant('Imagick::COMPOSITE_OVER'), + 0, 0); + $this->_image->_imagick->clear(); + $this->_image->_imagick->addImage($shadow); + $shadow->destroy(); + } else { + $size = $this->_image->getDimensions(); + $this->_image->_postSrcOperations[] = '\( +clone -background black -shadow 80x' . $this->_params['fade'] . '+' . $this->_params['distance'] . '+' . $this->_params['distance'] . ' \) +swap -background none -flatten +repage -bordercolor ' . $this->_params['background'] . ' -border ' . $this->_params['padding'] ; + } + $this->_image->_width = 0; + $this->_image->_height = 0; + + return true; + } + +} diff --git a/framework/Image/Image/Effect/im/photo_stack.php b/framework/Image/Image/Effect/im/photo_stack.php new file mode 100644 index 000000000..6d93b5334 --- /dev/null +++ b/framework/Image/Image/Effect/im/photo_stack.php @@ -0,0 +1,331 @@ + + * @since Horde 3.2 + * @package Horde_Image + */ +class Horde_Image_Effect_im_photo_stack extends Horde_Image_Effect { + + /** + * Valid parameters for the stack effect + * + * images - An array of Horde_Image objects to stack. Images + * are stacked in a FIFO manner, so that the top-most + * image is the last one in this array. + * + * type - Determines the style for the composition. + * 'plain' or 'polaroid' are supported. + * + * resize_height - The height that each individual thumbnail + * should be resized to before composing on the image. + * + * padding - How much padding should we ensure is left around + * the active image area? + * + * background - The background canvas color - this is used as the + * color to set any padding to. + * + * bordercolor - If using type 'plain' this sets the color of the + * border that each individual thumbnail gets. + * + * borderwidth - If using type 'plain' this sets the width of the + * border on each individual thumbnail. + * + * offset - If using type 'plain' this determines the amount of + * x and y offset to give each successive image when + * it is placed on the top of the stack. + * + * @var array + */ + var $_params = array('type' => 'plain', + 'resize_height' => '150', + 'padding' => 0, + 'background' => 'none', + 'bordercolor' => '#333', + 'borderwidth' => 1, + 'borderrounding' => 10, + 'offset' => 5 + ); + + /** + * Create the photo_stack + * + */ + function apply() + { + $i = 1; + $cnt = count($this->_params['images']); + if ($cnt <=0) { + return PEAR::raiseError('No images provided'); + } + if (!is_null($this->_image->_imagick) && + $this->_image->_imagick->methodExists('polaroidImage') && + $this->_image->_imagick->methodExists('trimImage')) { + + $imgs = array(); + $length = 0; + + switch ($this->_params['type']) { + case 'plain': + case 'rounded': + $haveBottom = false; + // First, we need to resize the top image to get the dimensions + // for the rest of the stack. + $topimg = new Horde_Image_ImagickProxy(); + $topimg->clear(); + $topimg->readImageBlob($this->_params['images'][$cnt - 1]->raw()); + $topimg->thumbnailImage( + $this->_params['resize_height'], + $this->_params['resize_height'], + true); + if ($this->_params['type'] == 'rounded') { + $topimg = $this->_roundBorder($topimg); + } + + $size = $topimg->getImageGeometry(); + foreach ($this->_params['images'] as $image) { + $imgk= new Horde_Image_ImagickProxy(); + $imgk->clear(); + $imgk->readImageBlob($image->raw()); + if ($i++ <= $cnt) { + $imgk->thumbnailImage($size['width'], $size['height'], + false); + } else { + $imgk->destroy(); + $imgk = $topimg->cloneIM(); + } + + if ($this->_params['type'] == 'rounded') { + $imgk = $this->_roundBorder($imgk); + } else { + $imgk->borderImage($this->_params['bordercolor'], 1, 1); + } + // Only shadow the bottom image for 'plain' stacks + if (!$haveBottom) { + $shad = $imgk->cloneIM(); + $shad->setImageBackgroundColor('black'); + $shad->shadowImage(80, 4, 0, 0); + $shad->compositeImage($imgk, + constant('Imagick::COMPOSITE_OVER'), + 0, 0); + $imgk->clear(); + $imgk->addImage($shad); + $shad->destroy(); + $haveBottom = true; + } + // Get the geometry of the image and remember the largest. + $geo = $imgk->getImageGeometry(); + $length = max( + $length, + sqrt(pow($geo['height'], 2) + pow($geo['width'], 2))); + + $imgs[] = $imgk; + } + break; + case 'polaroid': + foreach ($this->_params['images'] as $image) { + $imgk= new Horde_Image_ImagickProxy(); + $imgk->clear(); + $imgk->readImageBlob($image->raw()); + $imgk->thumbnailImage($this->_params['resize_height'], + $this->_params['resize_height'], + true); + $imgk->setImageBackgroundColor('black'); + if ($i++ == $cnt) { + $angle = 0; + } else { + $angle = mt_rand(1, 45); + if (mt_rand(1, 2) % 2 === 0) { + $angle = $angle * -1; + } + } + $result = $imgk->polaroidImage($angle); + if (is_a($result, 'PEAR_Error')) { + return $result; + } + // Get the geometry of the image and remember the largest. + $geo = $imgk->getImageGeometry(); + $length = max( + $length, + sqrt(pow($geo['height'], 2) + pow($geo['width'], 2))); + + $imgs[] = $imgk; + } + break; + } + + // Make sure the background canvas is large enough to hold it all. + $this->_image->_imagick->thumbnailImage($length * 1.5 + 20, + $length * 1.5 + 20); + + // x and y offsets. + $xo = $yo = (count($imgs) + 1) * $this->_params['offset']; + foreach ($imgs as $image) { + if ($this->_params['type'] == 'polaroid') { + $xo = mt_rand(1, $this->_params['resize_height'] / 2); + $yo = mt_rand(1, $this->_params['resize_height'] / 2); + } elseif ($this->_params['type'] == 'plain' || + $this->_params['type'] == 'rounded') { + $xo -= $this->_params['offset']; + $yo -= $this->_params['offset']; + } + + $this->_image->_imagick->compositeImage( + $image, constant('Imagick::COMPOSITE_OVER'), $xo, $yo); + $image->removeImage(); + $image->destroy(); + } + // If we have a background other than 'none' we need to + // compose two images together to make sure we *have* a background. + if ($this->_params['background'] != 'none') { + $size = $this->_image->getDimensions(); + $new = new Horde_Image_ImagickProxy($length * 1.5 + 20, + $length * 1.5 + 20, + $this->_params['background'], + $this->_image->_type); + + + + $new->compositeImage($this->_image->_imagick, + constant('Imagick::COMPOSITE_OVER'), 0, 0); + $this->_image->_imagick->clear(); + $this->_image->_imagick->addImage($new); + $new->destroy(); + } + // Trim the canvas before resizing to keep the thumbnails as large + // as possible. + $this->_image->_imagick->trimImage(0); + if ($this->_params['padding']) { + $this->_image->_imagick->borderImage($this->_params['background'], + $this->_params['padding'], + $this->_params['padding']); + } + + } else { + // No Imagick installed - use im, but make sure we don't mix imagick + // and convert. + $this->_image->_imagick = null; + $this->_image->raw(); + + switch ($this->_params['type']) { + case 'plain': + case 'rounded': + // Get top image dimensions, then force each bottom image to the + // same dimensions. + $this->_params['images'][$cnt - 1]->resize($this->_params['resize_height'], + $this->_params['resize_height'], + true); + $size = $this->_params['images'][$cnt - 1]->getDimensions(); + //$this->_image->resize(2 * $this->_params['resize_height'], 2 * $this->_params['resize_height']); + for ($i = 0; $i < $cnt; $i++) { + $this->_params['images'][$i]->resize($size['height'], $size['width'], false); + } + $xo = $yo = (count($this->_params['images']) + 1) * $this->_params['offset']; + $ops = ''; + $haveBottom = false; + foreach ($this->_params['images'] as $image) { + $xo -= $this->_params['offset']; + $yo -= $this->_params['offset']; + + if ($this->_params['type'] == 'rounded') { + $temp = $this->_roundBorder($image); + } else { + $temp = $image->toFile(); + } + $this->_image->_toClean[] = $temp; + $ops .= ' \( ' . $temp . ' -background none -thumbnail ' . $size['width'] . 'x' . $size['height'] . '! -repage +' . $xo . '+' . $yo . ($this->_params['type'] == 'plain' ? ' -bordercolor "#333" -border 1 ' : ' ' ) . ((!$haveBottom) ? '\( +clone -shadow 80x4+0+0 \) +swap -mosaic' : '') . ' \) '; + $haveBottom = true; + } + + // The first -background none option below is only honored in + // convert versions before 6.4 it seems. Without it specified as + // none here, all stacks come out with a white background. + $this->_image->_postSrcOperations[] = $ops . ' -background ' . $this->_params['background'] . ' -mosaic -bordercolor ' . $this->_params['background'] . ' -border ' . $this->_params['padding']; + + break; + + case 'polaroid': + // Check for im version > 6.3.2 + $ver = $this->_image->_getIMVersion(); + if (is_array($ver) && version_compare($ver[0], '6.3.2') >= 0) { + $ops = ''; + foreach ($this->_params['images'] as $image) { + $temp = $image->toFile(); + // Remember the temp files so we can nuke them later. + $this->_image->_toClean[] = $temp; + + // Don't rotate the top image. + if ($i++ == $cnt) { + $angle = 0; + } else { + $angle = mt_rand(1, 45); + if (mt_rand(1, 2) % 2 === 0) { + $angle = $angle * -1; + } + } + $ops .= ' \( ' . $temp . ' -geometry +' . mt_rand(1, $this->_params['resize_height']) . '+' . mt_rand(1, $this->_params['resize_height']) . ' -thumbnail \'' . $this->_params['resize_height'] . 'x' . $this->_params['resize_height'] . '>\' -bordercolor Snow -border 1 -polaroid ' . $angle . ' \) '; + } + $this->_image->_postSrcOperations[] = '-background none' . $ops . '-mosaic -bordercolor ' . $this->_params['background'] . ' -border ' . $this->_params['padding']; + } else { + // An attempt at a -polaroid command free version of this + // effect based on various examples and ideas at + // http://imagemagick.org + $ops = ''; + foreach ($this->_params['images'] as $image) { + $temp = $image->toFile(); + $this->_image->_toClean[] = $temp; + if ($i++ == $cnt) { + $angle = 0; + } else { + $angle = mt_rand(1, 45); + if (mt_rand(1, 2) % 2 === 0) { + $angle = $angle * -1; + } + } + $ops .= '\( ' . $temp . ' -thumbnail \'' . $this->_params['resize_height'] . 'x' . $this->_params['resize_height']. '>\' -bordercolor "#eee" -border 4 -bordercolor grey90 -border 1 -bordercolor none -background none -rotate ' . $angle . ' -background none \( +clone -shadow 60x4+4+4 \) +swap -background none -flatten \) '; + } + $this->_image->_postSrcOperations[] = '-background none ' . $ops . '-mosaic -trim +repage -bordercolor ' . $this->_params['background'] . ' -border ' . $this->_params['padding']; + } + break; + } + } + + return true; + } + + function _roundBorder($image) + { + if (!is_null($this->_image->_imagick)) { + $size = $image->getImageGeometry(); + $params = array('temp' => $this->_image->_tmpdir); + $new = Horde_Image::factory('im', $params); + $new->loadString('somestring', $image->getImageBlob()); + $image->destroy(); + $new->addEffect('round_corners', array('border' => 2, 'bordercolor' => '#111')); + $new->applyEffects(); + $return = new Horde_Image_ImagickProxy($size['width'] + $this->_params['borderwidth'], + $size['height'] + $this->_params['borderwidth'], + $this->_params['bordercolor'], + $this->_image->_type); + $return->clear(); + $return->readImageBlob($new->raw()); + return $return; + } else { + $size = $image->getDimensions(); + $params = array('temp' => $this->_image->_tmpdir, + 'data' => $image->raw()); + $new = Horde_Image::factory('im', $params); + $new->addEffect('round_corners', array('border' => 2, 'bordercolor' => '#111', 'background' => 'none')); + $new->applyEffects(); + return $new->toFile(); + } + } + +} diff --git a/framework/Image/Image/Effect/im/polaroid_image.php b/framework/Image/Image/Effect/im/polaroid_image.php new file mode 100755 index 000000000..3dc017b2f --- /dev/null +++ b/framework/Image/Image/Effect/im/polaroid_image.php @@ -0,0 +1,87 @@ + + * @since Horde 3.2 + * @package Horde_Image + */ +class Horde_Image_Effect_im_polaroid_image extends Horde_Image_Effect { + + /** + * Valid parameters for the polaroid effect + * + * resize_height - The height that each individual thumbnail + * should be resized to before composing on the image. + * + * background - The color of the image background. + * + * angle - Angle to rotate the image. + * + * shadowcolor - The color of the image shadow. + */ + + /** + * @var array + */ + var $_params = array('background' => 'none', + 'angle' => 0, + 'shadowcolor' => 'black' + ); + + /** + * Create the effect + * + */ + function apply() + { + if (!is_null($this->_image->_imagick) && + $this->_image->_imagick->methodExists('polaroidImage') && + $this->_image->_imagick->methodExists('trimImage')) { + + // This determines the color of the underlying shadow. + $this->_image->_imagick->setImageBackgroundColor($this->_params['shadowcolor']); + + $result = $this->_image->_imagick->polaroidImage($this->_params['angle']); + if (is_a($result, 'PEAR_Error')) { + return $result; + } + + // We need to create a new image to composite the polaroid over. + // (yes, even if it's a transparent background evidently) + $size = $this->_image->getDimensions(); + $imk = new Horde_Image_ImagickProxy($size['width'], + $size['height'], + $this->_params['background'], + $this->_image->_type); + + $result = $imk->compositeImage($this->_image->_imagick, + constant('Imagick::COMPOSITE_OVER'), + 0, 0); + if (is_a($result, 'PEAR_Error')) { + return $result; + } + $this->_image->_imagick->clear(); + $this->_image->_imagick->addImage($imk); + $imk->destroy(); + + + } else { + // Check for im version > 6.3.2 + $this->_image->_imagick = null; + $ver = $this->_image->_getIMVersion(); + if (is_array($ver) && version_compare($ver[0], '6.3.2') >= 0) { + $this->_image->_postSrcOperations[] = sprintf("-bordercolor \"#eee\" -background none -polaroid %s \( +clone -fill %s -draw 'color 0,0 reset' \) +swap +flatten", + $this->_params['angle'], $this->_params['background']); + } else { + $size = $this->_image->getDimensions(); + $this->_image->_postSrcOperations[] = sprintf("-bordercolor \"#eee\" -border 8 bordercolor grey90 -border 1 -bordercolor none -background none -rotate %s \( +clone -shadow 60x1.5+1+1 -rotate 90 -wave 1x%s -rotate 90 \) +swap -rotate 90 -wave 1x%s -rotate -90 -flatten \( +clone -fill %s -draw 'color 0,0 reset ' \) +swap -flatten", + $this->_params['angle'], $size['height'] * 2, $size['height'] * 2, $this->_params['background']); + } + return true; + } + } + +} diff --git a/framework/Image/Image/Effect/im/round_corners.php b/framework/Image/Image/Effect/im/round_corners.php new file mode 100644 index 000000000..7f2d73a35 --- /dev/null +++ b/framework/Image/Image/Effect/im/round_corners.php @@ -0,0 +1,104 @@ + + * @since Horde 3.2 + * @package Horde_Image + */ +class Horde_Image_Effect_im_round_corners extends Horde_Image_Effect { + + /** + * Valid parameters: + * + * radius - Radius of rounded corners. + * + * @var array + */ + var $_params = array('radius' => 10, + 'background' => 'none', + 'border' => 0, + 'bordercolor' => 'none'); + + function apply() + { + /* Use imagick extension if available */ + $round = $this->_params['radius']; + // Apparently roundCorners() requires imagick to be compiled against + // IM > 6.2.8. + if (!is_null($this->_image->_imagick) && + $this->_image->_imagick->methodExists('roundCorners')) { + $result = $this->_image->_imagick->roundCorners($round, $round); + if (is_a($result, 'PEAR_Error')) { + return $result; + } + + // Using a border? + if ($this->_params['bordercolor'] != 'none' && + $this->_params['border'] > 0) { + + $size = $this->_image->getDimensions(); + + $new = new Horde_Image_ImagickProxy($size['width'] + $this->_params['border'], + $size['height'] + $this->_params['border'], + $this->_params['bordercolor'], + $this->_image->_type); + + $result = $new->roundCorners($round, $round); + if (is_a($result, 'PEAR_Error')) { + return $result; + } + $new->compositeImage($this->_image->_imagick, + constant('Imagick::COMPOSITE_OVER'), 1, 1); + $this->_image->_imagick->clear(); + $this->_image->_imagick->addImage($new); + $new->destroy(); + } + + // If we have a background other than 'none' we need to + // compose two images together to make sure we *have* a background. + if ($this->_params['background'] != 'none') { + $size = $this->_image->getDimensions(); + $new = new Horde_Image_ImagickProxy($size['width'], + $size['height'], + $this->_params['background'], + $this->_image->_type); + + + + $new->compositeImage($this->_image->_imagick, + constant('Imagick::COMPOSITE_OVER'), 0, 0); + $this->_image->_imagick->clear(); + $this->_image->_imagick->addImage($new); + $new->destroy(); + } + } else { + // Get image dimensions + $dimensions = $this->_image->getDimensions(); + $height = $dimensions['height']; + $width = $dimensions['width']; + + // Make sure we don't attempt to use Imagick for any other effects + // to make sure we do them in the proper order. + $this->_image->_imagick = null; + + $this->_image->_operations[] = "-size {$width}x{$height} xc:{$this->_params['background']} " + . "-fill {$this->_params['background']} -draw \"matte 0,0 reset\" -tile"; + + $this->_image->roundedRectangle(round($round / 2), + round($round / 2), + $width - round($round / 2) - 2, + $height - round($round / 2) - 2, + $round + 2, + 'none', + 'white'); + } + + // Reset width/height since these might have changed + $this->_image->_width = 0; + $this->_image->_height = 0; + return true; + } +} diff --git a/framework/Image/Image/Effect/im/text_watermark.php b/framework/Image/Image/Effect/im/text_watermark.php new file mode 100644 index 000000000..5ddfe9444 --- /dev/null +++ b/framework/Image/Image/Effect/im/text_watermark.php @@ -0,0 +1,74 @@ + + * @since Horde 3.2 + * @package Horde_Image + */ +class Horde_Image_Effect_im_text_watermark extends Horde_Image_Effect { + + /** + * Valid parameters for watermark effects: + * + * text (required) - The text of the watermark. + * halign - The horizontal placement + * valign - The vertical placement + * font - The font name or family to use + * fontsize - The size of the font to use + * (small, medium, large, giant) + * + * @var array + */ + var $_params = array('halign' => 'right', + 'valign' => 'bottom', + 'font' => 'courier', + 'fontsize' => 'small'); + + /** + * Add the watermark + * + */ + function apply() + { + /* Determine placement on image */ + switch ($this->_params['valign']) { + case 'bottom': + $v = 'south'; + break; + case 'center': + $v = 'center'; + break; + default: + $v = 'north'; + } + + switch ($this->_params['halign']) { + case 'right': + $h = 'east'; + break; + case 'center': + $h = 'center'; + break; + default: + $h = 'west'; + + } + if (($v == 'center' && $h != 'center') || + ($v == 'center' && $h == 'center')) { + $gravity = $h; + } elseif ($h == 'center' && $v != 'center') { + $gravity = $v; + } else { + $gravity = $v . $h; + } + /* Determine font point size */ + $point = $this->_image->_getFontSize($this->_params['fontsize']); + $this->_image->raw(); + $this->_image->_postSrcOperations[] = ' -font ' . $this->_params['font'] . ' -pointsize ' . $point . ' \( +clone -resize 1x1 -fx 1-intensity -threshold 50% -scale 32x32 -write mpr:color +delete \) -tile mpr:color -gravity ' . $gravity . ' -annotate +20+10 "' . $this->_params['text'] . '"'; + $this->_image->raw(); + } + +} diff --git a/framework/Image/Image/gd.php b/framework/Image/Image/gd.php new file mode 100644 index 000000000..f9b22c927 --- /dev/null +++ b/framework/Image/Image/gd.php @@ -0,0 +1,1092 @@ + + * @since Horde 3.0 + * @package Horde_Image + */ +class Horde_Image_gd extends Horde_Image { + + /** + * Capabilites of this driver. + * + * @var array + */ + var $_capabilities = array('resize', + 'crop', + 'rotate', + 'flip', + 'mirror', + 'grayscale', + 'sepia', + 'yellowize', + 'canvas', + ); + + /** + * GD Image resource for the current image data. + * + * @var resource + */ + var $_im; + + /** + * String identifier of the current image. New image data will not be + * loaded if the same id is already loaded. + * + * @var string + */ + var $_id = ''; + + function Horde_Image_gd($params) + { + parent::Horde_Image($params); + if (!empty($params['type'])) { + $this->_type = $params['type']; + } + + if (!empty($params['width'])) { + $this->_im = &$this->_create($this->_width, $this->_height); + if (is_a($this->_im, 'PEAR_Error')) { + return $this->_im; + } + if (is_resource($this->_im)) { + $this->_call('imageFill', array($this->_im, 0, 0, $this->_allocateColor($this->_background))); + } + } + } + + function getContentType() + { + return 'image/' . $this->_type; + } + + /** + * Display the current image. + */ + function display() + { + $this->headers(); + return $this->_call('image' . $this->_type, array($this->_im)); + } + + /** + * Returns the raw data for this image. + * + * @param boolean $convert If true, the image data will be returned in the + * target format, independently from any image + * operations. + * + * @return string The raw image data. + */ + function raw($convert = false) + { + if (!is_resource($this->_im)) { + return ''; + } + return Util::bufferOutput('image' . $this->_type, $this->_im); + } + + /** + * Reset the image data. + */ + function reset() + { + parent::reset(); + if (is_resource($this->_im)) { + return $this->_call('imageDestroy', array($this->_im)); + } + return true; + } + + /** + * Get the height and width of the current image. + * + * @return array An hash with 'width' containing the width, + * 'height' containing the height of the image. + */ + function getDimensions() + { + if (is_a($this->_im, 'PEAR_Error')) { + return $this->_im; + } elseif (is_resource($this->_im) && + $this->_width == 0 && + $this->_height ==0) { + + $this->_width = $this->_call('imageSX', array($this->_im)); + $this->_height = $this->_call('imageSY', array($this->_im)); + return array('width' => $this->_width, + 'height' => $this->_height); + } else { + return array('width' => $this->_width, + 'height' => $this->_height); + } + } + + /** + * Creates a color that can be accessed in this object. When a + * color is set, the integer resource of it is returned. + * + * @param string $name The name of the color. + * + * @return integer The resource of the color that can be passed to GD. + */ + function _allocateColor($name) + { + static $colors = array(); + + if (empty($colors[$name])) { + list($r, $g, $b) = $this->getRGB($name); + $colors[$name] = $this->_call('imageColorAllocate', array($this->_im, $r, $g, $b)); + } + + return $colors[$name]; + } + + function getFont($font) + { + switch ($font) { + case 'tiny': + return 1; + + case 'medium': + return 3; + + case 'large': + return 4; + + case 'giant': + return 5; + + case 'small': + default: + return 2; + } + } + + /** + * Load the image data from a string. + * + * @param string $id An arbitrary id for the image. + * @param string $image_data The data to use for the image. + */ + function loadString($id, $image_data) + { + if ($id != $this->_id) { + if ($this->_im) { + if (is_a($result = $this->reset(), 'PEAR_Error')) { + return $result; + } + } + $this->_im = &$this->_call('imageCreateFromString', array($image_data)); + $this->_id = $id; + if (is_a($this->_im, 'PEAR_Error')) { + return $this->_im; + } + } + } + + /** + * Load the image data from a file. + * + * @param string $filename The full path and filename to the file to load + * the image data from. The filename will also be + * used for the image id. + * + * @return mixed PEAR Error if file does not exist or could not be loaded + * otherwise NULL if successful or already loaded. + */ + function loadFile($filename) + { + if (is_a($result = $this->reset(), 'PEAR_Error')) { + return $result; + } + + if (is_a($info = $this->_call('getimagesize', array($filename)), 'PEAR_Error')) { + return $info; + } + + if (is_array($info)) { + switch ($info[2]) { + case 1: + if (function_exists('imagecreatefromgif')) { + $this->_im = &$this->_call('imagecreatefromgif', array($filename)); + } + break; + case 2: + $this->_im = &$this->_call('imagecreatefromjpeg', array($filename)); + break; + case 3: + $this->_im = &$this->_call('imagecreatefrompng', array($filename)); + break; + case 15: + if (function_exists('imagecreatefromgwbmp')) { + $this->_im = &$this->_call('imagecreatefromgwbmp', array($filename)); + } + break; + case 16: + $this->_im = &$this->_call('imagecreatefromxbm', array($filename)); + break; + } + } + + if (is_a($this->_im, 'PEAR_Error')) { + return $this->_im; + } + + if (is_resource($this->_im)) { + return; + } + + $result = parent::loadFile($filename); + if (is_a($result, 'PEAR_Error')) { + return $result; + } + return $this->_im = &$this->_call('imageCreateFromString', array($this->_data)); + } + + /** + * Resize the current image. + * + * @param integer $width The new width. + * @param integer $height The new height. + * @param boolean $ratio Maintain original aspect ratio. + * + * @return PEAR_Error on failure + */ + function resize($width, $height, $ratio = true) + { + /* Abort if we're asked to divide by zero, truncate the image + * completely in either direction, or there is no image data. */ + if (!$width || !$height || !is_resource($this->_im)) { + return; + } + + if ($ratio) { + if ($width / $height > $this->_call('imageSX', array($this->_im)) / $this->_call('imageSY', array($this->_im))) { + $width = $height * $this->_call('imageSX', array($this->_im)) / $this->_call('imageSY', array($this->_im)); + } else { + $height = $width * $this->_call('imageSY', array($this->_im)) / $this->_call('imageSX', array($this->_im)); + } + } + + $im = $this->_im; + $this->_im = &$this->_create($width, $height); + + /* Reset geometry since it will change */ + $this->_width = 0; + $this->_height = 0; + + if (is_a($this->_im, 'PEAR_Error')) { + return $this->_im; + } + if (is_a($result = $this->_call('imageFill', array($this->_im, 0, 0, $this->_call('imageColorAllocate', array($this->_im, 255, 255, 255)))), 'PEAR_Error')) { + return $result; + } + if (is_a($this->_call('imageCopyResampled', array($this->_im, $im, 0, 0, 0, 0, $width, $height, $this->_call('imageSX', array($im)), $this->_call('imageSY', array($im)))), 'PEAR_Error')) { + return $this->_call('imageCopyResized', array($this->_im, $im, 0, 0, 0, 0, $width, $height, $this->_call('imageSX', array($im)), $this->_call('imageSY', array($im)))); + } + } + + /** + * Crop the current image. + * + * @param integer $x1 The top left corner of the cropped image. + * @param integer $y1 The top right corner of the cropped image. + * @param integer $x2 The bottom left corner of the cropped image. + * @param integer $y2 The bottom right corner of the cropped image. + */ + function crop($x1, $y1, $x2, $y2) + { + $im = $this->_im; + $this->_im = &$this->_create($x2 - $x1, $y2 - $y1); + if (is_a($this->_im, 'PEAR_Error')) { + return $this->_im; + } + $this->_width = 0; + $this->_height = 0; + return $this->_call('imageCopy', array($this->_im, $im, 0, 0, $x1, $y1, $x2 - $x1, $y2 - $y1)); + } + + /** + * Rotate the current image. + * + * @param integer $angle The angle to rotate the image by, + * in the clockwise direction + * @param integer $background The background color to fill any triangles + */ + function rotate($angle, $background = 'white') + { + if (!function_exists('imagerotate')) { + return; + } + + $background = $this->_allocateColor($background); + if (is_a($background, 'PEAR_Error')) { + return $background; + } + + $this->_width = 0; + $this->_height = 0; + + switch ($angle) { + case '90': + $x = $this->_call('imageSX', array($this->_im)); + $y = $this->_call('imageSY', array($this->_im)); + $xymax = max($x, $y); + + $im = &$this->_create($xymax, $xymax); + if (is_a($im, 'PEAR_Error')) { + return $im; + } + if (is_a($result = $this->_call('imageCopy', array($im, $this->_im, 0, 0, 0, 0, $x, $y)), 'PEAR_Error')) { + return $result; + } + $im = &$this->_call('imageRotate', array($im, 270, $background)); + if (is_a($im, 'PEAR_Error')) { + return $im; + } + $this->_im = $im; + $im = &$this->_create($y, $x); + if (is_a($im, 'PEAR_Error')) { + return $im; + } + if ($x < $y) { + if (is_a($result = $this->_call('imageCopy', array($im, $this->_im, 0, 0, 0, 0, $xymax, $xymax)), 'PEAR_Error')) { + return $result; + } + } elseif ($x > $y) { + if (is_a($result = $this->_call('imageCopy', array($im, $this->_im, 0, 0, $xymax - $y, $xymax - $x, $xymax, $xymax)), 'PEAR_Error')) { + return $result; + } + } + $this->_im = $im; + break; + + default: + $this->_im = &$this->_call('imageRotate', array($this->_im, 360 - $angle, $background)); + if (is_a($this->_im, 'PEAR_Error')) { + return $this->_im; + } + break; + } + } + + /** + * Flip the current image. + */ + function flip() + { + $x = $this->_call('imageSX', array($this->_im)); + $y = $this->_call('imageSY', array($this->_im)); + + $im = &$this->_create($x, $y); + if (is_a($im, 'PEAR_Error')) { + return $im; + } + for ($curY = 0; $curY < $y; $curY++) { + if (is_a($result = $this->_call('imageCopy', array($im, $this->_im, 0, $y - ($curY + 1), 0, $curY, $x, 1)), 'PEAR_Error')) { + return $result; + } + } + + $this->_im = $im; + } + + /** + * Mirror the current image. + */ + function mirror() + { + $x = $this->_call('imageSX', array($this->_im)); + $y = $this->_call('imageSY', array($this->_im)); + + $im = &$this->_create($x, $y); + if (is_a($im, 'PEAR_Error')) { + return $im; + } + for ($curX = 0; $curX < $x; $curX++) { + if (is_a($result = $this->_call('imageCopy', array($im, $this->_im, $x - ($curX + 1), 0, $curX, 0, 1, $y)), 'PEAR_Error')) { + return $result; + } + } + + $this->_im = $im; + } + + /** + * Convert the current image to grayscale. + */ + function grayscale() + { + $rateR = .229; + $rateG = .587; + $rateB = .114; + $whiteness = 3; + + if (function_exists('imageistruecolor') && $this->_call('imageIsTrueColor', array($this->_im)) === true) { + if (is_a($result = $this->_call('imageTrueColorToPalette', array($this->_im, true, 256)), 'PEAR_Error')) { + return $result; + } + } + + $colors = min(256, $this->_call('imageColorsTotal', array($this->_im))); + for ($x = 0; $x < $colors; $x++) { + $src = $this->_call('imageColorsForIndex', array($this->_im, $x)); + if (is_a($src, 'PEAR_Error')) { + return $src; + } + $new = min(255, abs($src['red'] * $rateR + $src['green'] * $rateG + $src['blue'] * $rateB) + $whiteness); + if (is_a($result = $this->_call('imageColorSet', array($this->_im, $x, $new, $new, $new)), 'PEAR_Error')) { + return $result; + } + } + } + + /** + * Sepia filter. + * + * Basically turns the image to grayscale and then adds some + * defined tint on it (R += 30, G += 43, B += -23) so it will + * appear to be a very old picture. + */ + function sepia() + { + $tintR = 80; + $tintG = 43; + $tintB = -23; + $rateR = .229; + $rateG = .587; + $rateB = .114; + $whiteness = 3; + + if ($this->_call('imageIsTrueColor', array($this->_im)) === true) { + if (is_a($result = $this->_call('imageTrueColorToPalette', array($this->_im, true, 256)), 'PEAR_Error')) { + return $result; + } + } + + $colors = max(256, $this->_call('imageColorsTotal', array($this->_im))); + for ($x = 0; $x < $colors; $x++) { + $src = $this->_call('imageColorsForIndex', array($this->_im, $x)); + if (is_a($src, 'PEAR_Error')) { + return $src; + } + $new = min(255, abs($src['red'] * $rateR + $src['green'] * $rateG + $src['blue'] * $rateB) + $whiteness); + $r = min(255, $new + $tintR); + $g = min(255, $new + $tintG); + $b = min(255, $new + $tintB); + if (is_a($result = $this->_call('imageColorSet', array($this->_im, $x, $r, $g, $b)), 'PEAR_Error')) { + return $result; + } + } + } + + /** + * Yellowize filter. + * + * Adds a layer of yellow that can be transparent or solid. If + * $intensityA is 255 the image will be 0% transparent (solid). + * + * @param integer $intensityY How strong should the yellow (red and green) be? (0-255) + * @param integer $intensityB How weak should the blue be? (>= 2, in the positive limit it will be make BLUE 0) + */ + function yellowize($intensityY = 50, $intensityB = 3) + { + if ($this->_call('imageIsTrueColor', array($this->_im)) === true) { + if (is_a($result = $this->_call('imageTrueColorToPalette', array($this->_im, true, 256)), 'PEAR_Error')) { + return $result; + } + } + + $colors = max(256, $this->_call('imageColorsTotal', array($this->_im))); + for ($x = 0; $x < $colors; $x++) { + $src = $this->_call('imageColorsForIndex', array($this->_im, $x)); + if (is_a($src, 'PEAR_Error')) { + return $src; + } + $r = min($src['red'] + $intensityY, 255); + $g = min($src['green'] + $intensityY, 255); + $b = max(($r + $g) / max($intensityB, 2), 0); + if (is_a($result = $this->_call('imageColorSet', array($this->_im, $x, $r, $g, $b)), 'PEAR_Error')) { + return $result; + } + } + } + + /** + * Draws a text string on the image in a specified location, with + * the specified style information. + * + * @param string $text The text to draw. + * @param integer $x The left x coordinate of the start of the + * text string. + * @param integer $y The top y coordinate of the start of the text + * string. + * @param string $font The font identifier you want to use for the + * text. + * @param string $color The color that you want the text displayed in. + * @param integer $direction An integer that specifies the orientation of + * the text. + */ + function text($string, $x, $y, $font = 'monospace', $color = 'black', $direction = 0, $fontsize = 'small') + { + $c = $this->_allocateColor($color); + if (is_a($c, 'PEAR_Error')) { + return $c; + } + $f = $this->getFont($font); + switch ($direction) { + case -90: + case 270: + $result = $this->_call('imageStringUp', array($this->_im, $f, $x, $y, $string, $c)); + break; + + case 0: + default: + $result = $this->_call('imageString', array($this->_im, $f, $x, $y, $string, $c)); + } + + return $result; + } + + /** + * Draw a circle. + * + * @param integer $x The x co-ordinate of the centre. + * @param integer $y The y co-ordinate of the centre. + * @param integer $r The radius of the circle. + * @param string $color The line color of the circle. + * @param string $fill The color to fill the circle. + */ + function circle($x, $y, $r, $color, $fill = null) + { + $c = $this->_allocateColor($color); + if (is_a($c, 'PEAR_Error')) { + return $c; + } + if (is_null($fill)) { + $result = $this->_call('imageEllipse', array($this->_im, $x, $y, $r * 2, $r * 2, $c)); + } else { + if ($fill !== $color) { + $fillColor = $this->_allocateColor($fill); + if (is_a($fillColor, 'PEAR_Error')) { + return $fillColor; + } + if (is_a($result = $this->_call('imageFilledEllipse', array($this->_im, $x, $y, $r * 2, $r * 2, $fillColor)), 'PEAR_Error')) { + return $result; + } + $result = $this->_call('imageEllipse', array($this->_im, $x, $y, $r * 2, $r * 2, $c)); + } else { + $result = $this->_call('imageFilledEllipse', array($this->_im, $x, $y, $r * 2, $r * 2, $c)); + } + } + if (is_a($result, 'PEAR_Error')) { + return $result; + } + } + + /** + * Draw a polygon based on a set of vertices. + * + * @param array $vertices An array of x and y labeled arrays + * (eg. $vertices[0]['x'], $vertices[0]['y'], ...). + * @param string $color The color you want to draw the polygon with. + * @param string $fill The color to fill the polygon. + */ + function polygon($verts, $color, $fill = 'none') + { + $vertices = array(); + foreach ($verts as $vert) { + $vertices[] = $vert['x']; + $vertices[] = $vert['y']; + } + + if ($fill != 'none') { + $f = $this->_allocateColor($fill); + if (is_a($f, 'PEAR_Error')) { + return $f; + } + if (is_a($result = $this->_call('imageFilledPolygon', array($this->_im, $vertices, count($verts), $f)), 'PEAR_Error')) { + return $result; + } + } + + if ($fill == 'none' || $fill != $color) { + $c = $this->_allocateColor($color); + if (is_a($c, 'PEAR_Error')) { + return $c; + } + if (is_a($result = $this->_call('imagePolygon', array($this->_im, $vertices, count($verts), $c)), 'PEAR_Error')) { + return $result; + } + } + } + + /** + * Draw a rectangle. + * + * @param integer $x The left x-coordinate of the rectangle. + * @param integer $y The top y-coordinate of the rectangle. + * @param integer $width The width of the rectangle. + * @param integer $height The height of the rectangle. + * @param string $color The line color of the rectangle. + * @param string $fill The color to fill the rectangle with. + */ + function rectangle($x, $y, $width, $height, $color = 'black', $fill = 'none') + { + if ($fill != 'none') { + $f = $this->_allocateColor($fill); + if (is_a($f, 'PEAR_Error')) { + return $f; + } + if (is_a($result = $this->_call('imageFilledRectangle', array($this->_im, $x, $y, $x + $width, $y + $height, $f)), 'PEAR_Error')) { + return $result; + } + } + + if ($fill == 'none' || $fill != $color) { + $c = $this->_allocateColor($color); + if (is_a($c, 'PEAR_Error')) { + return $c; + } + if (is_a($result = $this->_call('imageRectangle', array($this->_im, $x, $y, $x + $width, $y + $height, $c)), 'PEAR_Error')) { + return $result; + } + } + } + + /** + * Draw a rounded rectangle. + * + * @param integer $x The left x-coordinate of the rectangle. + * @param integer $y The top y-coordinate of the rectangle. + * @param integer $width The width of the rectangle. + * @param integer $height The height of the rectangle. + * @param integer $round The width of the corner rounding. + * @param string $color The line color of the rectangle. + * @param string $fill The color to fill the rounded rectangle with. + */ + function roundedRectangle($x, $y, $width, $height, $round, $color = 'black', $fill = 'none') + { + if ($round <= 0) { + // Optimize out any calls with no corner rounding. + return $this->rectangle($x, $y, $width, $height, $color, $fill); + } + + $c = $this->_allocateColor($color); + if (is_a($c, 'PEAR_Error')) { + return $c; + } + + // Set corner points to avoid lots of redundant math. + $x1 = $x + $round; + $y1 = $y + $round; + + $x2 = $x + $width - $round; + $y2 = $y + $round; + + $x3 = $x + $width - $round; + $y3 = $y + $height - $round; + + $x4 = $x + $round; + $y4 = $y + $height - $round; + + $r = $round * 2; + + // Calculate the upper left arc. + $p1 = $this->_arcPoints($round, 180, 225); + $p2 = $this->_arcPoints($round, 225, 270); + + // Calculate the upper right arc. + $p3 = $this->_arcPoints($round, 270, 315); + $p4 = $this->_arcPoints($round, 315, 360); + + // Calculate the lower right arc. + $p5 = $this->_arcPoints($round, 0, 45); + $p6 = $this->_arcPoints($round, 45, 90); + + // Calculate the lower left arc. + $p7 = $this->_arcPoints($round, 90, 135); + $p8 = $this->_arcPoints($round, 135, 180); + + // Draw the corners - upper left, upper right, lower right, + // lower left. + if (is_a($result = $this->_call('imageArc', array($this->_im, $x1, $y1, $r, $r, 180, 270, $c)), 'PEAR_Error')) { + return $result; + } + if (is_a($result = $this->_call('imageArc', array($this->_im, $x2, $y2, $r, $r, 270, 360, $c)), 'PEAR_Error')) { + return $result; + } + if (is_a($result = $this->_call('imageArc', array($this->_im, $x3, $y3, $r, $r, 0, 90, $c)), 'PEAR_Error')) { + return $result; + } + if (is_a($result = $this->_call('imageArc', array($this->_im, $x4, $y4, $r, $r, 90, 180, $c)), 'PEAR_Error')) { + return $result; + } + + // Draw the connecting sides - top, right, bottom, left. + if (is_a($result = $this->_call('imageLine', array($this->_im, $x1 + $p2['x2'], $y1 + $p2['y2'], $x2 + $p3['x1'], $y2 + $p3['y1'], $c)), 'PEAR_Error')) { + return $result; + } + if (is_a($result = $this->_call('imageLine', array($this->_im, $x2 + $p4['x2'], $y2 + $p4['y2'], $x3 + $p5['x1'], $y3 + $p5['y1'], $c)), 'PEAR_Error')) { + return $result; + } + if (is_a($result = $this->_call('imageLine', array($this->_im, $x3 + $p6['x2'], $y3 + $p6['y2'], $x4 + $p7['x1'], $y4 + $p7['y1'], $c)), 'PEAR_Error')) { + return $result; + } + if (is_a($result = $this->_call('imageLine', array($this->_im, $x4 + $p8['x2'], $y4 + $p8['y2'], $x1 + $p1['x1'], $y1 + $p1['y1'], $c)), 'PEAR_Error')) { + return $result; + } + + if ($fill != 'none') { + $f = $this->_allocateColor($fill); + if (is_a($f, 'PEAR_Error')) { + return $f; + } + if (is_a($result = $this->_call('imageFillToBorder', array($this->_im, $x + ($width / 2), $y + ($height / 2), $c, $f)), 'PEAR_Error')) { + return $result; + } + } + } + + /** + * Draw a line. + * + * @param integer $x0 The x co-ordinate of the start. + * @param integer $y0 The y co-ordinate of the start. + * @param integer $x1 The x co-ordinate of the end. + * @param integer $y1 The y co-ordinate of the end. + * @param string $color The line color. + * @param string $width The width of the line. + */ + function line($x1, $y1, $x2, $y2, $color = 'black', $width = 1) + { + $c = $this->_allocateColor($color); + if (is_a($c, 'PEAR_Error')) { + return $c; + } + + // Don't need to do anything special for single-width lines. + if ($width == 1) { + $result = $this->_call('imageLine', array($this->_im, $x1, $y1, $x2, $y2, $c)); + } elseif ($x1 == $x2) { + // For vertical lines, we can just draw a vertical + // rectangle. + $left = $x1 - floor(($width - 1) / 2); + $right = $x1 + floor($width / 2); + $result = $this->_call('imageFilledRectangle', array($this->_im, $left, $y1, $right, $y2, $c)); + } elseif ($y1 == $y2) { + // For horizontal lines, we can just draw a horizontal + // filled rectangle. + $top = $y1 - floor($width / 2); + $bottom = $y1 + floor(($width - 1) / 2); + $result = $this->_call('imageFilledRectangle', array($this->_im, $x1, $top, $x2, $bottom, $c)); + } else { + // Angled lines. + + // Make sure that the end points of the line are + // perpendicular to the line itself. + $a = atan2($y1 - $y2, $x2 - $x1); + $dx = (sin($a) * $width / 2); + $dy = (cos($a) * $width / 2); + + $verts = array($x2 + $dx, $y2 + $dy, $x2 - $dx, $y2 - $dy, $x1 - $dx, $y1 - $dy, $x1 + $dx, $y1 + $dy); + $result = $this->_call('imageFilledPolygon', array($this->_im, $verts, count($verts) / 2, $c)); + } + + return $result; + } + + /** + * Draw a dashed line. + * + * @param integer $x0 The x co-ordinate of the start. + * @param integer $y0 The y co-ordinate of the start. + * @param integer $x1 The x co-ordinate of the end. + * @param integer $y1 The y co-ordinate of the end. + * @param string $color The line color. + * @param string $width The width of the line. + * @param integer $dash_length The length of a dash on the dashed line + * @param integer $dash_space The length of a space in the dashed line + */ + function dashedLine($x0, $y0, $x1, $y1, $color = 'black', $width = 1, $dash_length = 2, $dash_space = 2) + { + $c = $this->_allocateColor($color); + if (is_a($c, 'PEAR_Error')) { + return $c; + } + $w = $this->_allocateColor('white'); + if (is_a($w, 'PEAR_Error')) { + return $w; + } + + // Set up the style array according to the $dash_* parameters. + $style = array(); + for ($i = 0; $i < $dash_length; $i++) { + $style[] = $c; + } + for ($i = 0; $i < $dash_space; $i++) { + $style[] = $w; + } + + if (is_a($result = $this->_call('imageSetStyle', array($this->_im, $style)), 'PEAR_Error')) { + return $result; + } + if (is_a($result = $this->_call('imageSetThickness', array($this->_im, $width)), 'PEAR_Error')) { + return $result; + } + return $this->_call('imageLine', array($this->_im, $x0, $y0, $x1, $y1, IMG_COLOR_STYLED)); + } + + /** + * Draw a polyline (a non-closed, non-filled polygon) based on a + * set of vertices. + * + * @param array $vertices An array of x and y labeled arrays + * (eg. $vertices[0]['x'], $vertices[0]['y'], ...). + * @param string $color The color you want to draw the line with. + * @param string $width The width of the line. + */ + function polyline($verts, $color, $width = 1) + { + $first = true; + foreach ($verts as $vert) { + if (!$first) { + if (is_a($result = $this->line($lastX, $lastY, $vert['x'], $vert['y'], $color, $width), 'PEAR_Error')) { + return $result; + } + } else { + $first = false; + } + $lastX = $vert['x']; + $lastY = $vert['y']; + } + } + + /** + * Draw an arc. + * + * @param integer $x The x co-ordinate of the centre. + * @param integer $y The y co-ordinate of the centre. + * @param integer $r The radius of the arc. + * @param integer $start The start angle of the arc. + * @param integer $end The end angle of the arc. + * @param string $color The line color of the arc. + * @param string $fill The fill color of the arc (defaults to none). + */ + function arc($x, $y, $r, $start, $end, $color = 'black', $fill = null) + { + $c = $this->_allocateColor($color); + if (is_a($c, 'PEAR_Error')) { + return $c; + } + if (is_null($fill)) { + $result = $this->_call('imageArc', array($this->_im, $x, $y, $r * 2, $r * 2, $start, $end, $c)); + } else { + if ($fill !== $color) { + $f = $this->_allocateColor($fill); + if (is_a($f, 'PEAR_Error')) { + return $f; + } + if (is_a($result = $this->_call('imageFilledArc', array($this->_im, $x, $y, $r * 2, $r * 2, $start, $end, $f, IMG_ARC_PIE)), 'PEAR_Error')) { + return $result; + } + $result = $this->_call('imageFilledArc', array($this->_im, $x, $y, $r * 2, $r * 2, $start, $end, $c, IMG_ARC_EDGED | IMG_ARC_NOFILL)); + } else { + $result = $this->_call('imageFilledArc', array($this->_im, $x, $y, $r * 2, $r * 2, $start, $end, $c, IMG_ARC_PIE)); + } + } + return $result; + } + + /** + * Applies the specified mask to the image. + * + * @param resource $gdimg_mask The gd image resource representing the mask + * + * @return mixed true | PEAR_Error + */ + function _applyMask($gdimg_mask) { + $imgX = round($this->_call('imageSX', array($this->_im))); + $imgY = round($this->_call('imageSY', array($this->_im))); + + $gdimg_mask_resized = $this->_create($imgX, $imgY); + if (!is_a($gdimg_mask_resized, 'PEAR_Error')) { + $result = $this->_call('imageCopyResampled', + array($gdimg_mask_resized, + $gdimg_mask, + 0, 0, 0, 0, + $imgX, + $imgY, + $this->_call('imageSX', array($gdimg_mask)), + $this->_call('imageSY', array($gdimg_mask)))); + if (is_a($result, 'PEAR_Error')) { + return $result; + } + + $gdimg_mask_blendtemp = $this->_create($imgX, $imgY); + if (is_a($gdimg_mask_blendtemp, 'PEAR_Error')) { + return $gdimg_mask_blendtemp; + } + $mbtX = $this->_call('imageSX', array($gdimg_mask_blendtemp)); + $mbtY = $this->_call('imageSY', array($gdimg_mask_blendtemp)); + + if (!is_a($gdimg_mask_blendtemp, 'PEAR_Error')) { + $color_background = $this->_call('imageColorAllocate', + array($gdimg_mask_blendtemp, 0, 0, 0)); + + $this->_call('imageFilledRectangle', array($gdimg_mask_blendtemp, + 0, + 0, + $mbtX, + $mbtY, + $color_background)); + + $this->_call('imageAlphaBlending', + array($gdimg_mask_blendtemp, false)); + + $this->_call('imageSaveAlpha', + array($gdimg_mask_blendtemp, true)); + + for ($x = 0; $x < $imgX; $x++) { + for ($y = 0; $y < $imgY; $y++) { + $colorat = $this->_call('imageColorAt', + array($this->_im, $x, $y)); + + if (is_a($colorat, 'PEAR_Error')) { + return $colorat; + } + + $realPixel = $this->_call('imageColorsForIndex', + array($this->_im, $colorat)); + + $colorat = $this->_call('imageColorAt', + array($gdimg_mask_resized, $x, $y)); + + if (is_a($colorat, 'PEAR_Error')) { + return $colorat; + } + + $maskPixel = $this->_grayscalePixel($this->_call('imageColorsForIndex', + array($gdimg_mask_resized, $colorat))); + + $maskAlpha = 127 - (floor($maskPixel['red'] / 2) * (1 - ($realPixel['alpha'] / 127))); + $newcolor = $this->_allocateColorAlpha($gdimg_mask_blendtemp, + $realPixel['red'], + $realPixel['green'], + $realPixel['blue'], + intval($maskAlpha)); + $this->_call('imageSetPixel', + array($gdimg_mask_blendtemp, $x, $y, $newcolor)); + } + } + $this->_call('imageAlphaBlending', array($this->_im, false)); + $this->_call('imageSaveAlpha', array($this->_im, true)); + $this->_call('imageCopy', array($this->_im, + $gdimg_mask_blendtemp, + 0, 0, 0, 0, + $mbtX, + $mbtY)); + + $this->_call('imageDestroy', array($gdimg_mask_blendtemp)); + + } else { + return $gdimg_mask_blendtemp; // PEAR_Error + } + $this->_call('imageDestroy', array($gdimg_mask_resized)); + } else { + return $gdimg_mask_resized; // PEAR_Error + } + return true; + } + + /** + * @TODO + */ + function _grayscaleValue($r, $g, $b) { + return round(($r * 0.30) + ($g * 0.59) + ($b * 0.11)); + } + + /** + * @TODO + */ + function _grayscalePixel($OriginalPixel) { + $gray = $this->_grayscaleValue($OriginalPixel['red'], $OriginalPixel['green'], $OriginalPixel['blue']); + return array('red'=>$gray, 'green'=>$gray, 'blue'=>$gray); + } + + /** + * Creates an image of the given size. + * If possible the function returns a true color image. + * + * @param integer $width The image width. + * @param integer $height The image height. + * + * @return resource|object PEAR Error The image handler or a PEAR_Error + * on error. + */ + function &_create($width, $height) + { + $result = &$this->_call('imageCreateTrueColor', array($width, $height)); + if (!is_resource($result)) { + $result = &$this->_call('imageCreate', array($width, $height)); + } + return $result; + } + + function _allocateColorAlpha($gdimg_hexcolorallocate, $r, $g, $b , $alpha = false) { + $result = $this->_call('imageColorAllocateAlpha', + array($gdimg_hexcolorallocate, $r, $g, $b, intval($alpha))); + if (is_a($result, 'PEAR_Error')) { + $result = $this->_call('imageColorAllocate', + array($gdimg_hexcolorallocate, $r, $g, $b)); + } + return $result; + } + + + /** + * Wraps a call to a function of the gd extension. + * If the call produces an error, a PEAR_Error is returned, the function + * result otherwise. + * + * @param string $function The name of the function to wrap. + * @param array $params An array with all parameters for that function. + * + * @return mixed Either the function result or a PEAR_Error if an error + * occured when executing the function. + */ + function &_call($function, $params = null) + { + unset($php_errormsg); + $track = ini_set('track_errors', 1); + $error_mask = E_ALL & ~E_WARNING & ~E_NOTICE; + error_reporting($error_mask); + $result = call_user_func_array($function, $params); + if ($track !== false) { + ini_set('track_errors', $track); + } + error_reporting($GLOBALS['conf']['debug_level']); + if (!empty($php_errormsg)) { + $error_msg = $php_errormsg; + require_once 'PEAR.php'; + $result = PEAR::raiseError($function . ': ' . $error_msg); + } + return $result; + } + +} diff --git a/framework/Image/Image/im.php b/framework/Image/Image/im.php new file mode 100644 index 000000000..fe7c2ccd5 --- /dev/null +++ b/framework/Image/Image/im.php @@ -0,0 +1,784 @@ + + * 'type' - What type of image should be generated. + * + * + * $Horde: framework/Image/Image/im.php,v 1.132 2009/05/07 14:27:55 mrubinsk Exp $ + * + * Copyright 2002-2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @author Chuck Hagenbuch + * @author Mike Cochrane + * @author Michael J. Rubinsky + * + * @since Horde 3.0 + * @package Horde_Image + */ +class Horde_Image_im extends Horde_Image { + + /** + * Capabilites of this driver. + * + * @var array + */ + var $_capabilities = array('resize', + 'crop', + 'rotate', + 'grayscale', + 'flip', + 'mirror', + 'sepia', + 'canvas' + ); + + /** + * Operations to be performed. These are added before the source filename + * is specified on the command line. + * + * @var array + */ + var $_operations = array(); + + /** + * Operations to be added after the source filename is specified on the + * command line. + * + * @var array + */ + var $_postSrcOperations = array(); + + /** + * Current stroke color; cached so we don't issue more -stroke commands + * than necessary. + * + * @var string + */ + var $_strokeColor = null; + + /** + * Current stroke width; cached so we don't issue more -strokewidth + * commands than necessary. + * + * @var string + */ + var $_strokeWidth = null; + + /** + * Current fill color; cached so we don't issue more -fill commands than + * necessary. + * + * @var string + */ + var $_fillColor = null; + + /** + * Reference to an Horde_Image_ImagickProxy object. + * + * @var Imagick + */ + var $_imagick = null; + + /** + * TODO + * + * @var array + */ + var $_toClean = array(); + + /** + * Constructor. + */ + function Horde_Image_im($params) + { + parent::Horde_Image($params); + + if (!empty($params['type'])) { + $this->_type = $params['type']; + } + + // Imagick library doesn't play nice with outputting data for 0x0 + // images, so use 1x1 for our default if needed. + if (Util::loadExtension('imagick')) { + ini_set('imagick.locale_fix', 1); + require_once 'Horde/Image/imagick.php'; + $this->_width = max(array($this->_width, 1)); + $this->_height = max(array($this->_height, 1)); + // Use a proxy for the Imagick calls to keep exception catching + // code out of PHP4 compliant code. + $this->_imagick = new Horde_Image_ImagickProxy($this->_width, + $this->_height, + $this->_background, + $this->_type); + // Yea, it's wasteful to create the proxy (which creates a blank + // image) then overwrite it if we're passing in an image, but this + // will be fixed in Horde 4 when imagick is broken out into it's own + // proper driver. + if (!empty($params['filename'])) { + $this->loadFile($params['filename']); + } elseif(!empty($params['data'])) { + $this->loadString(md5($params['data']), $params['data']); + } else { + $this->_data = $this->_imagick->getImageBlob(); + } + + $this->_imagick->setImageFormat($this->_type); + } else { + if (!empty($params['filename'])) { + $this->loadFile($params['filename']); + } elseif (!empty($params['data'])) { + $this->loadString(md5($params['data']), $params['data']); + } else { + $cmd = "-size {$this->_width}x{$this->_height} xc:{$this->_background} +profile \"*\" {$this->_type}:__FILEOUT__"; + $this->executeConvertCmd($cmd); + } + } + } + + /** + * Load the image data from a string. Need to override this method + * in order to load the imagick object if we need to. + * + * @param string $id An arbitrary id for the image. + * @param string $image_data The data to use for the image. + */ + function loadString($id, $image_data) + { + parent::loadString($id, $image_data); + if (!is_null($this->_imagick)) { + $this->_imagick->clear(); + $this->_imagick->readImageBlob($image_data); + $this->_imagick->setFormat($this->_type); + $this->_imagick->setIteratorIndex(0); + } + } + + /** + * Load the image data from a file. Need to override this method + * in order to load the imagick object if we need to. + * + * @param string $filename The full path and filename to the file to load + * the image data from. The filename will also be + * used for the image id. + * + * @return mixed PEAR Error if file does not exist or could not be loaded + * otherwise NULL if successful or already loaded. + */ + function loadFile($filename) + { + parent::loadFile($filename); + if (!is_null($this->_imagick)) { + $this->_imagick->clear(); + $this->_imagick->readImageBlob($this->_data); + $this->_imagick->setIteratorIndex(0); + } + } + + + /** + * Return the content type for this image. + * + * @return string The content type for this image. + */ + function getContentType() + { + return 'image/' . $this->_type; + } + + /** + * Returns the raw data for this image. + * + * @param boolean $convert If true, the image data will be returned in the + * target format, independently from any image + * operations. + * + * @return string The raw image data. + */ + function raw($convert = false) + { + global $conf; + + // Make sure _data is sync'd with imagick object + if (!is_null($this->_imagick)) { + $this->_data = $this->_imagick->getImageBlob(); + } + + if (!empty($this->_data)) { + // If there are no operations, and we already have data, don't + // bother writing out files, just return the current data. + if (!$convert && + !count($this->_operations) && + !count($this->_postSrcOperations)) { + return $this->_data; + } + + $tmpin = $this->toFile($this->_data); + } + + // Perform convert command if needed + if (count($this->_operations) || count($this->_postSrcOperations) || $convert) { + $tmpout = Util::getTempFile('img', false, $this->_tmpdir); + $command = $conf['image']['convert'] + . ' ' . implode(' ', $this->_operations) + . ' "' . $tmpin . '"\'[0]\' ' + . implode(' ', $this->_postSrcOperations) + . ' +profile "*" ' . $this->_type . ':"' . $tmpout . '" 2>&1'; + Horde::logMessage('convert command executed by Horde_Image_im::raw(): ' . $command, __FILE__, __LINE__, PEAR_LOG_DEBUG); + exec($command, $output, $retval); + if ($retval) { + Horde::logMessage('Error running command: ' . $command . "\n" . implode("\n", $output), __FILE__, __LINE__, PEAR_LOG_WARNING); + } + + /* Empty the operations queue */ + $this->_operations = array(); + $this->_postSrcOperations = array(); + + /* Load the result */ + $this->_data = file_get_contents($tmpout); + + // Keep imagick object in sync if we need to. + // @TODO: Might be able to stop doing this once all operations + // are doable through imagick api. + if (!is_null($this->_imagick)) { + $this->_imagick->clear(); + $this->_imagick->readImageBlob($this->_data); + } + } + + @unlink($tmpin); + @unlink($tmpout); + + return $this->_data; + } + + /** + * Reset the image data. + */ + function reset() + { + parent::reset(); + $this->_operations = array(); + $this->_postSrcOperations = array(); + if (is_object($this->_imagick)) { + $this->_imagick->clear(); + } + $this->_width = 0; + $this->_height = 0; + } + + /** + * Resize the current image. This operation takes place immediately. + * + * @param integer $width The new width. + * @param integer $height The new height. + * @param boolean $ratio Maintain original aspect ratio. + * @param boolean $keepProfile Keep the image meta data. + */ + function resize($width, $height, $ratio = true, $keepProfile = false) + { + if (!is_null($this->_imagick)) { + $this->_imagick->thumbnailImage($width, $height, $ratio); + } else { + $resWidth = $width * 2; + $resHeight = $height * 2; + $this->_operations[] = "-size {$resWidth}x{$resHeight}"; + if ($ratio) { + $this->_postSrcOperations[] = (($keepProfile) ? "-resize" : "-thumbnail") . " {$width}x{$height}"; + } else { + $this->_postSrcOperations[] = (($keepProfile) ? "-resize" : "-thumbnail") . " {$width}x{$height}!"; + } + } + // Reset the width and height instance variables since after resize + // we don't know the *exact* dimensions yet (especially if we maintained + // aspect ratio. + // Refresh the data + $this->raw(); + $this->_width = 0; + $this->_height = 0; + } + + /** + * More efficient way of getting size if using imagick library. + * *ALWAYS* use getDimensions() to get image geometry...instance + * variables only cache geometry until it changes, then they go + * to zero. + * + */ + function getDimensions() + { + if (!is_null($this->_imagick)) { + if ($this->_height == 0 && $this->_width == 0) { + $size = $this->_imagick->getImageGeometry(); + if (is_a($size, 'PEAR_Error')) { + return $size; + } + $this->_height = $size['height']; + $this->_width = $size['width']; + } + return array('width' => $this->_width, + 'height' => $this->_height); + } else { + return parent::getDimensions(); + } + } + + /** + * Crop the current image. + * + * @param integer $x1 x for the top left corner + * @param integer $y1 y for the top left corner + * @param integer $x2 x for the bottom right corner of the cropped image. + * @param integer $y2 y for the bottom right corner of the cropped image. + */ + function crop($x1, $y1, $x2, $y2) + { + if (!is_null($this->_imagick)) { + $result = $this->_imagick->cropImage($x2 - $x1, $y2 - $y1, $x1, $y1); + $this->_imagick->setImagePage(0, 0, 0, 0); + } else { + $line = ($x2 - $x1) . 'x' . ($y2 - $y1) . '+' . $x1 . '+' . $y1; + $this->_operations[] = '-crop ' . $line . ' +repage'; + $result = true; + } + // Reset width/height since these might change + $this->raw(); + $this->_width = 0; + $this->_height = 0; + return $result; + } + + /** + * Rotate the current image. + * + * @param integer $angle The angle to rotate the image by, + * in the clockwise direction. + * @param integer $background The background color to fill any triangles. + */ + function rotate($angle, $background = 'white') + { + if (!is_null($this->_imagick)) { + return $this->_imagick->rotateImage($background, $angle); + } else { + $this->raw(); + $this->_operations[] = "-background $background -rotate {$angle}"; + $this->raw(); + } + // Reset width/height since these might have changed + $this->_width = 0; + $this->_height = 0; + } + + /** + * Flip the current image. + */ + function flip() + { + if (!is_null($this->_imagick)) { + $this->_imagick->flipImage(); + } else { + $this->_operations[] = '-flip'; + } + } + + /** + * Mirror the current image. + */ + function mirror() + { + if (!is_null($this->_imagick)) { + $this->_imagick->flopImage(); + } else { + $this->_operations[] = '-flop'; + } + } + + /** + * Convert the current image to grayscale. + */ + function grayscale() + { + if (!is_null($this->_imagick)) { + $this->_imagick->setImageColorSpace(constant('Imagick::COLORSPACE_GRAY')); + } else { + $this->_postSrcOperations[] = '-colorspace GRAY'; + } + } + + /** + * Sepia filter. + * + * @param integer $threshold Extent of sepia effect. + */ + function sepia($threshold = 85) + { + if (!is_null($this->_imagick)) { + $this->_imagick->sepiaToneImage($threshold); + } else { + $this->_operations[] = '-sepia-tone ' . $threshold . '%'; + } + } + + /** + * Draws a text string on the image in a specified location, with + * the specified style information. + * + * @TODO: Need to differentiate between the stroke (border) and the fill color, + * but this is a BC break, since we were just not providing a border. + * + * @param string $text The text to draw. + * @param integer $x The left x coordinate of the start of the text string. + * @param integer $y The top y coordinate of the start of the text string. + * @param string $font The font identifier you want to use for the text. + * @param string $color The color that you want the text displayed in. + * @param integer $direction An integer that specifies the orientation of the text. + * @param string $fontsize Size of the font (small, medium, large, giant) + */ + function text($string, $x, $y, $font = '', $color = 'black', $direction = 0, $fontsize = 'small') + { + if (!is_null($this->_imagick)) { + $fontsize = $this->_getFontSize($fontsize); + + return $this->_imagick->text($string, $x, $y, $font, $color, $direction, $fontsize); + } else { + $string = addslashes('"' . $string . '"'); + $fontsize = $this->_getFontSize($fontsize); + $this->_postSrcOperations[] = "-fill $color " . (!empty($font) ? "-font $font" : '') . " -pointsize $fontsize -gravity northwest -draw \"text $x,$y $string\" -fill none"; + } + } + + /** + * Draw a circle. + * + * @param integer $x The x coordinate of the centre. + * @param integer $y The y coordinate of the centre. + * @param integer $r The radius of the circle. + * @param string $color The line color of the circle. + * @param string $fill The color to fill the circle. + */ + function circle($x, $y, $r, $color, $fill = 'none') + { + if (!is_null($this->_imagick)) { + return $this->_imagick->circle($x, $y, $r, $color, $fill); + } else { + $xMax = $x + $r; + $this->_postSrcOperations[] = "-stroke $color -fill $fill -draw \"circle $x,$y $xMax,$y\" -stroke none -fill none"; + } + } + + /** + * Draw a polygon based on a set of vertices. + * + * @param array $vertices An array of x and y labeled arrays + * (eg. $vertices[0]['x'], $vertices[0]['y'], ...). + * @param string $color The color you want to draw the polygon with. + * @param string $fill The color to fill the polygon. + */ + function polygon($verts, $color, $fill = 'none') + { + // TODO: For now, use only convert since ::polygon is called from other + // methods that are convert-only for now. + //if (!is_null($this->_imagick)) { + //return $this->_imagick->polygon($verts, $color, $fill); + //} else { + $command = ''; + foreach ($verts as $vert) { + $command .= sprintf(' %d,%d', $vert['x'], $vert['y']); + } + $this->_postSrcOperations[] = "-stroke $color -fill $fill -draw \"polygon $command\" -stroke none -fill none"; + //} + } + + /** + * Draw a rectangle. + * + * @param integer $x The left x-coordinate of the rectangle. + * @param integer $y The top y-coordinate of the rectangle. + * @param integer $width The width of the rectangle. + * @param integer $height The height of the rectangle. + * @param string $color The line color of the rectangle. + * @param string $fill The color to fill the rectangle. + */ + function rectangle($x, $y, $width, $height, $color, $fill = 'none') + { + if (!is_null($this->_imagick)) { + $this->_imagick->rectangle($x, $y, $width, $height, $color, $fill); + } else { + $xMax = $x + $width; + $yMax = $y + $height; + $this->_postSrcOperations[] = "-stroke $color -fill $fill -draw \"rectangle $x,$y $xMax,$yMax\" -stroke none -fill none"; + } + } + + /** + * Draw a rounded rectangle. + * + * @param integer $x The left x-coordinate of the rectangle. + * @param integer $y The top y-coordinate of the rectangle. + * @param integer $width The width of the rectangle. + * @param integer $height The height of the rectangle. + * @param integer $round The width of the corner rounding. + * @param string $color The line color of the rectangle. + * @param string $fill The color to fill the rounded rectangle with. + */ + function roundedRectangle($x, $y, $width, $height, $round, $color, $fill) + { + if (!is_null($this->_imagick)) { + $this->_imagick->roundedRectangle($x, $y, $width, $height, $round, $color, $fill); + } else { + $x1 = $x + $width; + $y1 = $y + $height; + $this->_postSrcOperations[] = "-stroke $color -fill $fill -draw \"roundRectangle $x,$y $x1,$y1 $round,$round\" -stroke none -fill none"; + + } + } + + /** + * Draw a line. + * + * @param integer $x0 The x coordinate of the start. + * @param integer $y0 The y coordinate of the start. + * @param integer $x1 The x coordinate of the end. + * @param integer $y1 The y coordinate of the end. + * @param string $color The line color. + * @param string $width The width of the line. + */ + function line($x0, $y0, $x1, $y1, $color = 'black', $width = 1) + { + if (!is_null($this->_imagick)) { + return $this->_imagick->line($x0, $y0, $x1, $y1, $color, $width); + } else { + $this->_operations[] = "-stroke $color -strokewidth $width -draw \"line $x0,$y0 $x1,$y1\""; + } + } + + /** + * Draw a dashed line. + * + * @param integer $x0 The x co-ordinate of the start. + * @param integer $y0 The y co-ordinate of the start. + * @param integer $x1 The x co-ordinate of the end. + * @param integer $y1 The y co-ordinate of the end. + * @param string $color The line color. + * @param string $width The width of the line. + * @param integer $dash_length The length of a dash on the dashed line + * @param integer $dash_space The length of a space in the dashed line + */ + function dashedLine($x0, $y0, $x1, $y1, $color = 'black', $width = 1, $dash_length = 2, $dash_space = 2) + { + if (!is_null($this->_imagick)) { + return $this->_imagick->dashedLine($x0, $y0, $x1, $y1, $color, + $width, $dash_length, + $dash_space); + } else { + $this->_operations[] = "-stroke $color -strokewidth $width -draw \"line $x0,$y0 $x1,$y1\""; + } + } + + /** + * Draw a polyline (a non-closed, non-filled polygon) based on a + * set of vertices. + * + * @param array $vertices An array of x and y labeled arrays + * (eg. $vertices[0]['x'], $vertices[0]['y'], ...). + * @param string $color The color you want to draw the line with. + * @param string $width The width of the line. + */ + function polyline($verts, $color, $width = 1) + { + if (!is_null($this->_imagick)) { + return $this->_imagick->polyline($verts, $color, $width); + } else { + $command = ''; + foreach ($verts as $vert) { + $command .= sprintf(' %d,%d', $vert['x'], $vert['y']); + } + $this->_operations[] = "-stroke $color -strokewidth $width -fill none -draw \"polyline $command\" -strokewidth 1 -stroke none -fill none"; + } + } + + /** + * Draw an arc. + * + * @param integer $x The x coordinate of the centre. + * @param integer $y The y coordinate of the centre. + * @param integer $r The radius of the arc. + * @param integer $start The start angle of the arc. + * @param integer $end The end angle of the arc. + * @param string $color The line color of the arc. + * @param string $fill The fill color of the arc (defaults to none). + */ + function arc($x, $y, $r, $start, $end, $color = 'black', $fill = 'none') + { + // Split up arcs greater than 180 degrees into two pieces. + $this->_postSrcOperations[] = "-stroke $color -fill $fill"; + $mid = round(($start + $end) / 2); + $x = round($x); + $y = round($y); + $r = round($r); + if ($mid > 90) { + $this->_postSrcOperations[] = "-draw \"ellipse $x,$y $r,$r $start,$mid\""; + $this->_postSrcOperations[] = "-draw \"ellipse $x,$y $r,$r $mid,$end\""; + } else { + $this->_postSrcOperations[] = "-draw \"ellipse $x,$y $r,$r $start,$end\""; + } + + // If filled, draw the outline. + if (!empty($fill)) { + list($x1, $y1) = $this->_circlePoint($start, $r * 2); + list($x2, $y2) = $this->_circlePoint($mid, $r * 2); + list($x3, $y3) = $this->_circlePoint($end, $r * 2); + + // This seems to result in slightly better placement of + // pie slices. + $x++; + $y++; + + $verts = array(array('x' => $x + $x3, 'y' => $y + $y3), + array('x' => $x, 'y' => $y), + array('x' => $x + $x1, 'y' => $y + $y1)); + + if ($mid > 90) { + $verts1 = array(array('x' => $x + $x2, 'y' => $y + $y2), + array('x' => $x, 'y' => $y), + array('x' => $x + $x1, 'y' => $y + $y1)); + $verts2 = array(array('x' => $x + $x3, 'y' => $y + $y3), + array('x' => $x, 'y' => $y), + array('x' => $x + $x2, 'y' => $y + $y2)); + + $this->polygon($verts1, $fill, $fill); + $this->polygon($verts2, $fill, $fill); + } else { + $this->polygon($verts, $fill, $fill); + } + + $this->polyline($verts, $color); + + $this->_postSrcOperations[] = '-stroke none -fill none'; + } + } + + /** + * Change the current fill color. Will only affect the command + * string if $color is different from the previous fill color + * (stored in $this->_fillColor). + * + * @access private + * @see $_fill + * + * @param string $color The new fill color. + */ + function setFillColor($color) + { + if ($color != $this->_fillColor) { + $this->_operations[] = "-fill $color"; + $this->_fillColor = $color; + } + } + + function applyEffects() + { + $this->raw(); + foreach ($this->_toClean as $tempfile) { + @unlink($tempfile); + } + } + + /** + * Method to execute a raw command directly in convert. + * + * The input and output files are quoted and substituted for __FILEIN__ and + * __FILEOUT__ respectfully. In order to support piped convert commands, the + * path to the convert command is substitued for __CONVERT__ (but the + * initial convert command is added automatically). + * + * @param string $cmd The command string, with substitutable tokens + * @param array $values Any values that should be substituted for tokens. + * + * @return + */ + function executeConvertCmd($cmd, $values = array()) + { + // First, get a temporary file for the input + if (strpos($cmd, '__FILEIN__') !== false) { + $tmpin = $this->toFile($this->_data); + } else { + $tmpin = ''; + } + + // Now an output file + $tmpout = Util::getTempFile('img', false, $this->_tmpdir); + + // Substitue them in the cmd string + $cmd = str_replace(array('__FILEIN__', '__FILEOUT__', '__CONVERT__'), + array('"' . $tmpin . '"', '"' . $tmpout . '"', $GLOBALS['conf']['image']['convert']), + $cmd); + + //TODO: See what else needs to be replaced. + $cmd = $GLOBALS['conf']['image']['convert'] . ' ' . $cmd . ' 2>&1'; + + // Log it + Horde::logMessage('convert command executed by Horde_Image_im::executeConvertCmd(): ' . $cmd, __FILE__, __LINE__, PEAR_LOG_DEBUG); + exec($cmd, $output, $retval); + if ($retval) { + Horde::logMessage('Error running command: ' . $cmd . "\n" . implode("\n", $output), __FILE__, __LINE__, PEAR_LOG_WARNING); + } + $this->_data = file_get_contents($tmpout); + + @unlink($tmpin); + @unlink($tmpout); + } + + + /** + * Return point size for font + */ + function _getFontSize($fontsize) + { + switch ($fontsize) { + case 'medium': + $point = 18; + break; + case 'large': + $point = 24; + break; + case 'giant': + $point = 30; + break; + default: + $point = 12; + } + return $point; + } + + + function _getIMVersion() + { + static $version = null; + if (!is_array($version)) { + if (!is_null($this->_imagick)) { + $output = $this->_imagick->getVersion(); + $output[0] = $output['versionString']; + } else { + $commandline = $GLOBALS['conf']['image']['convert'] . ' --version'; + exec($commandline, $output, $retval); + } + if (preg_match('/([0-9])\.([0-9])\.([0-9])/', $output[0], $matches)) { + $version = $matches; + return $matches; + } else { + return false; + } + } + return $version; + } + +} diff --git a/framework/Image/Image/imagick.php b/framework/Image/Image/imagick.php new file mode 100644 index 000000000..eed658cbd --- /dev/null +++ b/framework/Image/Image/imagick.php @@ -0,0 +1,452 @@ + + * @since Horde 3.2 + * @package Horde_Image + */ +class Horde_Image_ImagickProxy { + + /** + * Instance variable for our Imagick object. + * + * @var Imagick object + */ + protected $_imagick = null; + + /** + * Constructor. Instantiate our imagick object and set some defaults. + */ + public function __construct($width = 1, $height = 1, $bg = 'white', $format = 'png') + { + $this->_imagick = new Imagick(); + $this->_imagick->newImage($width, $height, new ImagickPixel($bg)); + $this->_imagick->setImageFormat($format); + } + + /** + * Clears the current imagick object and reloads it + * with the passed in binary data. + * + * @param string $image_data The data representing an image. + * + * @return mixed true || PEAR_Error + */ + public function loadString($image_data) + { + try { + if (!$this->_imagick->clear()) { + return PEAR::raiseError('Unable to clear the Imagick object'); + } + if (!$this->_imagick->readImageBlob($image_data)) { + return PEAR::raiseError(sprintf("Call to Imagick::readImageBlob failed on line %s of %s", __LINE__, __FILE__)); + } + return true; + } catch (ImagickException $e) { + return PEAR::raiseError($e->getMessage()); + } + } + + /** + * Rotates image as described. Don't pass through since we are not passing + * a ImagickPixel object from PHP4 code. + * + * @param string $bg Background color + * @param integer $angle Angle to rotate + * + * @return mixed true || PEAR_Error + */ + public function rotateImage($bg, $angle) + { + try { + if (!$this->_imagick->rotateImage(new ImagickPixel($bg), $angle)) { + return PEAR::raiseError(sprintf("Call to Imagick::rotateImage failed on line %s of %s", __LINE__, __FILE__)); + } + return true; + } catch (ImagickException $e) { + return PEAR::raiseError($e->getMessage()); + } + } + + /** + * Change image to a grayscale image. + * + * @return mixed true || PEAR_Error + */ + function grayscale() + { + try { + if (!$this->_imagick->setImageColorSpace(Imagick::COLORSPACE_GRAY)) { + return PEAR::raiseError(sprintf("Call to Imagick::setImageColorSpace failed on line %s of %s", __LINE__, __FILE__)); + } + return true; + } catch (ImagickException $e) { + return PEAR::raiseError($e->getMessage()); + } + } + + /** + * Places a string of text on this image with the specified properties + * + * @TODO + * + * @return mixed true || PEAR_Error + */ + function text($string, $x, $y, $font = 'ariel', $color = 'black', $direction = 0, $fontsize = 'small') + { + try { + $pixel = new ImagickPixel($color); + $draw = new ImagickDraw(); + $draw->setFillColor($pixel); + if (!empty($font)) { + $draw->setFont($font); + } + $draw->setFontSize($fontsize); + $draw->setGravity(Imagick::GRAVITY_NORTHWEST); + $res = $this->_imagick->annotateImage($draw, $x, $y, $direction, $string); + $draw->destroy(); + if (!$res) { + return PEAR::raiseError(sprintf("Call to Imagick::annotateImage failed on line %s of %s", __LINE__, __FILE__)); + } + return true; + } catch (ImagickException $e) { + return PEAR::raiseError($e->getMessage()); + } + } + + /** + * @TODO + * + * @return mixed true || PEAR_Error + */ + function circle($x, $y, $r, $color, $fill) + { + try { + $draw = new ImagickDraw(); + $draw->setFillColor(new ImagickPixel($fill)); + $draw->setStrokeColor(new ImagickPixel($color)); + $draw->circle($x, $y, $r + $x, $y); + $res = $this->_imagick->drawImage($draw); + $draw->destroy(); + if (!$res) { + return PEAR::raiseError(sprintf("Call to Imagick::drawImage failed on line %s of %s", __LINE__, __FILE__)); + } + return true; + } catch (ImagickException $e) { + return PEAR::raiseError($e->getMessage()); + } + } + + /** + * @TODO + * + * @return mixed true || PEAR_Error + */ + function polygon($verts, $color, $fill) + { + try { + $draw = new ImagickDraw(); + $draw->setFillColor(new ImagickPixel($fill)); + $draw->setStrokeColor(new ImagickPixel($color)); + $draw->polygon($verts); + $res = $this->_imagick->drawImage($draw); + $draw->destroy(); + if (!$res) { + return PEAR::raiseError(sprintf("Call to Imagick::drawImage failed on line %s of %s", __LINE__, __FILE__)); + } + return true; + } catch (ImagickException $e) { + return PEAR::raiseError($e->getMessage()); + } + } + + /** + * @TODO + * + * @return mixed true || Pear_Error + */ + function rectangle($x, $y, $width, $height, $color, $fill = 'none') + { + try { + $draw = new ImagickDraw(); + $draw->setStrokeColor(new ImagickPixel($color)); + $draw->setFillColor(new ImagickPixel($fill)); + $draw->rectangle($x, $y, $x + $width, $y + $height); + $res = $this->_imagick->drawImage($draw); + $draw->destroy(); + if (!$res) { + return PEAR::raiseError(sprintf("Call to Imagick::drawImage failed on line %s of %s", __LINE__, __FILE__)); + } + return true; + } catch (ImagickException $e) { + return PEAR::raiseError($e->getMessage()); + } + } + + /** + * Rounded Rectangle + * + * + */ + function roundedRectangle($x, $y, $width, $height, $round, $color, $fill) + { + $draw = new ImagickDraw(); + $draw->setStrokeColor(new ImagickPixel($color)); + $draw->setFillColor(new ImagickPixel($fill)); + $draw->roundRectangle($x, $y, $x + $width, $y + $height, $round, $round); + $res = $this->_imagick->drawImage($draw); + + + } + + /** + * @TODO + * + * @return mixed true || PEAR_Error + */ + function line($x0, $y0, $x1, $y1, $color, $width) + { + try { + $draw = new ImagickDraw(); + $draw->setStrokeColor(new ImagickPixel($color)); + $draw->setStrokeWidth($width); + $draw->line($x0, $y0, $x1, $y1); + $res = $this->_imagick->drawImage($draw); + $draw->destroy(); + if (!$res) { + return PEAR::raiseError(sprintf("Call to Imagick::drawImage failed on line %s of %s", __LINE__, __FILE__)); + } + return true; + } catch (ImagickException $e) { + return PEAR::raiseError($e->getMessage()); + } + } + + /** + * @TODO + * + * @return mixed true || PEAR_Error + */ + function dashedLine($x0, $y0, $x1, $y1, $color, $width, $dash_length, $dash_space) + { + try { + $draw = new ImagickDraw(); + $draw->setStrokeColor(new ImagickPixel($color)); + $draw->setStrokeWidth($width); + $draw->setStrokeDashArray(array($dash_length, $dash_space)); + $draw->line($x0, $y0, $x1, $y1); + $res = $this->_imagick->drawImage($draw); + $draw->destroy(); + if (!$res) { + return PEAR::raiseError(sprintf("Call to Imagick::drawImage failed on line %s of %s", __LINE__, __FILE__)); + } + return true; + } catch (ImagickException $e) { + return PEAR::raiseError($e->getMessage()); + } + } + + /** + * @TODO + * + * @return mixed true || PEAR_Error + */ + function polyline($verts, $color, $width) + { + try { + $draw = new ImagickDraw(); + $draw->setStrokeColor(new ImagickPixel($color)); + $draw->setStrokeWidth($width); + $draw->setFillColor(new ImagickPixel('none')); + $draw->polyline($verts); + $res = $this->_imagick->drawImage($draw); + $draw->destroy(); + if (!$res) { + return PEAR::raiseError(sprintf("Call to Imagick::drawImage failed on line %s of %s", __LINE__, __FILE__)); + } + return true; + } catch (ImagickException $e) { + return PEAR::raiseError($e->getMessage()); + } + } + + /** + * @TODO + * + * @return mixed true || PEAR_Error + */ + function setImageBackgroundColor($color) + { + try { + $res = $this->_imagick->setImageBackgroundColor(new ImagickPixel($color)); + if (!$res) { + return PEAR::raiseError(sprintf("Call to Imagick::setImageBackgroundColor failed on line %s of %s", __LINE__, __FILE__)); + } + return true; + } catch (ImagickException $e) { + return PEAR::raiseError($e->getMessage()); + } + } + + /** + * @TODO + * + * @return mixed true || PEAR_Error + */ + function compositeImage(&$imagickProxy, $constant, $x, $y, $channel = null) + { + try { + $res = $this->_imagick->compositeImage($imagickProxy->getIMObject(), + $constant, + $x, + $y, $channel); + if (!$res) { + return PEAR::raiseError(sprintf("Call to Imagick::compositeImage failed on line %s of %s", __LINE__, __FILE__)); + } + return true; + } catch (ImagickException $e) { + return PEAR::raiseError($e->getMessage()); + } + } + + /** + * @TODO + * + * @return mixed true || PEAR_Error + */ + function addImage(&$imagickProxy) + { + try { + $res = $this->_imagick->addImage($imagickProxy->getIMObject()); + if (!$res) { + return PEAR::raiseError(sprintf("Call to Imagick::drawImage failed on line %s of %s", __LINE__, __FILE__)); + } + return true; + } catch (ImagickException $e) { + return PEAR::raiseError($e->getMessage()); + } + } + + /** + * Add a border to this image. + * + * @param string $color The color of the border. + * @param integer $width The border width + * @param integer $height The border height + * + * @return mixed true || PEAR_Error + * + */ + function borderImage($color, $width, $height) + { + try { + // Jump through all there hoops to preserve any transparency. + $border = $this->_imagick->clone(); + $border->borderImage(new ImagickPixel($color), + $width, $height); + $border->compositeImage($this->_imagick, + constant('Imagick::COMPOSITE_COPY'), + $width, $height); + $this->_imagick->clear(); + $this->_imagick->addImage($border); + $border->destroy(); + return true; + } catch (ImagickException $e) { + return PEAR::raiseError($e->getMessage()); + } + } + + /** + * Return the raw Imagick object + * + * @return Imagick The Imagick object for this proxy. + */ + function &getIMObject() + { + return $this->_imagick; + } + + /** + * Produces a clone of this ImagickProxy object. + * + * @return mixed Horde_Image_ImagickProxy object || PEAR_Error + * + */ + function &cloneIM() + { + try { + $new = new Horde_Image_ImagickProxy(); + $new->clear(); + if (!$new->readImageBlob($this->getImageBlob())) { + return PEAR::raiseError(sprintf("Call to Imagick::readImageBlob failed on line %s of %s", __LINE__, __FILE__)); + } + return $new; + } catch (ImagickException $e) { + return PEAR::raiseError($e->getMessage()); + } + } + + /** + * + */ + function polaroidImage($angle = 0) + { + try { + $bg = new ImagickDraw(); + return $this->_imagick->polaroidImage($bg, $angle); + } catch (ImagickException $e) { + return PEAR::raiseError($e->getMessage()); + } + + } + + /** + * Check if a particular method exists in the installed version of Imagick + * + * @param string $methodName The name of the method to check for. + * + * @return boolean + */ + function methodExists($methodName) + { + if (method_exists($this->_imagick, $methodName)) { + return true; + } else { + return false; + } + } + + /** + * Pass through any methods not explicitly handled above. + * Note that any methods that take any Imagick* object as a parameter + * should be called through it's own method as above so we can avoid + * having objects that might throw exceptions running in PHP4 code. + */ + function __call($method, $params) + { + try { + if (method_exists($this->_imagick, $method)) { + $result = call_user_func_array(array($this->_imagick, $method), $params); + } else { + return PEAR::raiseError(sprintf("Unable to execute %s. Your ImageMagick version may not support this feature.", $method)); + } + } catch (ImagickException $e) { + return PEAR::raiseError($e->getMessage()); + } + return $result; + } + +} diff --git a/framework/Image/Image/png.php b/framework/Image/Image/png.php new file mode 100644 index 000000000..d05b6d256 --- /dev/null +++ b/framework/Image/Image/png.php @@ -0,0 +1,246 @@ + + * @since Horde 3.0 + * @package Horde_Image + */ +class Horde_Image_png extends Horde_Image { + + /** + * The array of pixel data. + * + * @var array + */ + var $_img = array(); + + /** + * Color depth (only 8 and 16 implemented). + * + * @var integer + */ + var $_colorDepth = 8; + + /** + * Color type (only 2 (true color) implemented). + * + * @var integer + */ + var $_colorType = 2; + + /** + * Compression method (0 is the only current valid value). + * + * @var integer + */ + var $_compressionMethod = 0; + + /** + * Filter method (0 is the only current valid value). + * + * @var integer + */ + var $_filterMethod = 0; + + /** + * Interlace method (only 0 (no interlace) implemented). + * + * @var integer + */ + var $_interlaceMethod = 0; + + /** + * PNG image constructor. + */ + function Horde_Image_png($params) + { + parent::Horde_Image($params); + + if (!empty($params['width'])) { + $this->rectangle(0, 0, $params['width'], $params['height'], $this->_background, $this->_background); + } + } + + function getContentType() + { + return 'image/png'; + } + + /** + * Return the raw data for this image. + * + * @return string The raw image data. + */ + function raw() + { + return + $this->_header() . + $this->_IHDR() . + + /* Say what created the image file. */ + $this->_tEXt('Software', 'Horde Framework Image_png Class') . + + /* Set the last modified date/time. */ + $this->_tIME() . + + $this->_IDAT() . + $this->_IEND(); + } + + /** + * Reset the image data. + */ + function reset() + { + parent::reset(); + $this->_img = array(); + } + + /** + * Draw a rectangle. + * + * @param integer $x The left x-coordinate of the rectangle. + * @param integer $y The top y-coordinate of the rectangle. + * @param integer $width The width of the rectangle. + * @param integer $height The height of the rectangle. + * @param string $color The line color of the rectangle. + * @param string $fill The color to fill the rectangle with. + */ + function rectangle($x, $y, $width, $height, $color = 'black', $fill = 'none') + { + list($r, $g, $b) = $this->getRGB($color); + if ($fill != 'none') { + list($fR, $fG, $fB) = $this->getRGB($fill); + } + + $x2 = $x + $width; + $y2 = $y + $height; + + for ($h = $y; $h <= $y2; $h++) { + for ($w = $x; $w <= $x2; $w++) { + // See if we're on an edge. + if ($w == $x || $h == $y || $w == $x2 || $h == $y2) { + $this->_img[$h][$w] = array('r' => $r, 'g' => $g, 'b' => $b); + } elseif ($fill != 'none') { + $this->_img[$h][$w] = array('r' => $fR, 'g' => $fG, 'b' => $fB); + } + } + } + } + + /** + * Create the PNG file header. + */ + function _header() + { + return pack('CCCCCCCC', 137, 80, 78, 71, 13, 10, 26, 10); + } + + /** + * Create Image Header block. + */ + function _IHDR() + { + $data = pack('a4NNCCCCC', 'IHDR', $this->_width, $this->_height, $this->_colorDepth, $this->_colorType, $this->_compressionMethod, $this->_filterMethod, $this->_interlaceMethod); + return pack('Na' . strlen($data) . 'N', strlen($data) - 4, $data, crc32($data)); + } + + /** + * Create IEND block. + */ + function _IEND() + { + $data = 'IEND'; + return pack('Na' . strlen($data) . 'N', strlen($data) - 4, $data, crc32($data)); + } + + /** + * Create Image Data block. + */ + function _IDAT() + { + $data = ''; + $prevscanline = null; + $filter = 0; + for ($i = 0; $i < $this->_height; $i++) { + $scanline = array(); + $data .= chr($filter); + for ($j = 0; $j < $this->_width; $j++) { + if ($this->_colorDepth == 8) { + $scanline[$j] = pack('CCC', $this->_img[$i][$j]['r'], $this->_img[$i][$j]['g'], $this->_img[$i][$j]['b']); + } elseif ($this->_colorDepth == 16) { + $scanline[$j] = pack('nnn', $this->_img[$i][$j]['r'] << 8, $this->_img[$i][$j]['g'] << 8, $this->_img[$i][$j]['b'] << 8); + } + + if ($filter == 0) { + /* No Filter. */ + $data .= $scanline[$j]; + } elseif ($filter == 2) { + /* Up Filter. */ + $pixel = $scanline[$j] - $prevscanline[$j]; + if ($this->_colorDepth == 8) { + $data .= pack('CCC', $pixel >> 16, ($pixel >> 8) & 0xFF, $pixel & 0xFF); + } elseif ($this->_colorDepth == 16) { + $data .= pack('nnn', ($pixel >> 32), ($pixel >> 16) & 0xFFFF, $pixel & 0xFFFF); + } + } + } + $prevscanline = $scanline; + } + $compressed = gzdeflate($data, 9); + + $data = 'IDAT' . pack('CCa' . strlen($compressed) . 'a4', 0x78, 0x01, $compressed, $this->_Adler32($data)); + return pack('Na' . strlen($data) . 'N', strlen($data) - 4, $data, crc32($data)); + } + + /** + * Create tEXt block. + */ + function _tEXt($keyword, $text) + { + $data = 'tEXt' . $keyword . "\0" . $text; + return pack('Na' . strlen($data) . 'N', strlen($data) - 4, $data, crc32($data)); + } + + /** + * Create last modified time block. + */ + function _tIME($date = null) + { + if (is_null($date)) { + $date = time(); + } + + $data = 'tIME' . pack('nCCCCC', intval(date('Y', $date)), intval(date('m', $date)), intval(date('j', $date)), intval(date('G', $date)), intval(date('i', $date)), intval(date('s', $date))); + return pack('Na' . strlen($data) . 'N', strlen($data) - 4, $data, crc32($data)); + } + + /** + * Calculate an Adler32 checksum for a string. + */ + function _Adler32($input) + { + $s1 = 1; + $s2 = 0; + $iMax = strlen($input); + for ($i = 0; $i < $iMax; $i++) { + $s1 = ($s1 + ord($input[$i])) % 0xFFF1; + $s2 = ($s2 + $s1) % 0xFFF1; + } + return pack('N', (($s2 << 16) | $s1)); + } + +} diff --git a/framework/Image/Image/rgb.php b/framework/Image/Image/rgb.php new file mode 100644 index 000000000..2d30976c9 --- /dev/null +++ b/framework/Image/Image/rgb.php @@ -0,0 +1,446 @@ + array(0, 255, 255), + 'lime' => array(0, 255, 0), + 'teal' => array(0, 128, 128), + 'whitesmoke' => array(245, 245, 245), + 'gainsboro' => array(220, 220, 220), + 'oldlace' => array(253, 245, 230), + 'linen' => array(250, 240, 230), + 'antiquewhite' => array(250, 235, 215), + 'papayawhip' => array(255, 239, 213), + 'blanchedalmond' => array(255, 235, 205), + 'bisque' => array(255, 228, 196), + 'peachpuff' => array(255, 218, 185), + 'navajowhite' => array(255, 222, 173), + 'moccasin' => array(255, 228, 181), + 'cornsilk' => array(255, 248, 220), + 'ivory' => array(255, 255, 240), + 'lemonchiffon' => array(255, 250, 205), + 'seashell' => array(255, 245, 238), + 'mintcream' => array(245, 255, 250), + 'azure' => array(240, 255, 255), + 'aliceblue' => array(240, 248, 255), + 'lavender' => array(230, 230, 250), + 'lavenderblush' => array(255, 240, 245), + 'mistyrose' => array(255, 228, 225), + 'white' => array(255, 255, 255), + 'black' => array(0, 0, 0), + 'darkslategray' => array(47, 79, 79), + 'dimgray' => array(105, 105, 105), + 'slategray' => array(112, 128, 144), + 'lightslategray' => array(119, 136, 153), + 'gray' => array(190, 190, 190), + 'lightgray' => array(211, 211, 211), + 'midnightblue' => array(25, 25, 112), + 'navy' => array(0, 0, 128), + 'cornflowerblue' => array(100, 149, 237), + 'darkslateblue' => array(72, 61, 139), + 'slateblue' => array(106, 90, 205), + 'mediumslateblue' => array(123, 104, 238), + 'lightslateblue' => array(132, 112, 255), + 'mediumblue' => array(0, 0, 205), + 'royalblue' => array(65, 105, 225), + 'blue' => array(0, 0, 255), + 'dodgerblue' => array(30, 144, 255), + 'deepskyblue' => array(0, 191, 255), + 'skyblue' => array(135, 206, 235), + 'lightskyblue' => array(135, 206, 250), + 'steelblue' => array(70, 130, 180), + 'lightred' => array(211, 167, 168), + 'lightsteelblue' => array(176, 196, 222), + 'lightblue' => array(173, 216, 230), + 'powderblue' => array(176, 224, 230), + 'paleturquoise' => array(175, 238, 238), + 'darkturquoise' => array(0, 206, 209), + 'mediumturquoise' => array(72, 209, 204), + 'turquoise' => array(64, 224, 208), + 'cyan' => array(0, 255, 255), + 'lightcyan' => array(224, 255, 255), + 'cadetblue' => array(95, 158, 160), + 'mediumaquamarine' => array(102, 205, 170), + 'aquamarine' => array(127, 255, 212), + 'darkgreen' => array(0, 100, 0), + 'darkolivegreen' => array(85, 107, 47), + 'darkseagreen' => array(143, 188, 143), + 'seagreen' => array(46, 139, 87), + 'mediumseagreen' => array(60, 179, 113), + 'lightseagreen' => array(32, 178, 170), + 'palegreen' => array(152, 251, 152), + 'springgreen' => array(0, 255, 127), + 'lawngreen' => array(124, 252, 0), + 'green' => array(0, 255, 0), + 'chartreuse' => array(127, 255, 0), + 'mediumspringgreen' => array(0, 250, 154), + 'greenyellow' => array(173, 255, 47), + 'limegreen' => array(50, 205, 50), + 'yellowgreen' => array(154, 205, 50), + 'forestgreen' => array(34, 139, 34), + 'olivedrab' => array(107, 142, 35), + 'darkkhaki' => array(189, 183, 107), + 'khaki' => array(240, 230, 140), + 'palegoldenrod' => array(238, 232, 170), + 'lightgoldenrodyellow' => array(250, 250, 210), + 'lightyellow' => array(255, 255, 200), + 'yellow' => array(255, 255, 0), + 'gold' => array(255, 215, 0), + 'lightgoldenrod' => array(238, 221, 130), + 'goldenrod' => array(218, 165, 32), + 'darkgoldenrod' => array(184, 134, 11), + 'rosybrown' => array(188, 143, 143), + 'indianred' => array(205, 92, 92), + 'saddlebrown' => array(139, 69, 19), + 'sienna' => array(160, 82, 45), + 'peru' => array(205, 133, 63), + 'burlywood' => array(222, 184, 135), + 'beige' => array(245, 245, 220), + 'wheat' => array(245, 222, 179), + 'sandybrown' => array(244, 164, 96), + 'tan' => array(210, 180, 140), + 'chocolate' => array(210, 105, 30), + 'firebrick' => array(178, 34, 34), + 'brown' => array(165, 42, 42), + 'darksalmon' => array(233, 150, 122), + 'salmon' => array(250, 128, 114), + 'lightsalmon' => array(255, 160, 122), + 'orange' => array(255, 165, 0), + 'darkorange' => array(255, 140, 0), + 'coral' => array(255, 127, 80), + 'lightcoral' => array(240, 128, 128), + 'tomato' => array(255, 99, 71), + 'orangered' => array(255, 69, 0), + 'red' => array(255, 0, 0), + 'hotpink' => array(255, 105, 180), + 'deeppink' => array(255, 20, 147), + 'pink' => array(255, 192, 203), + 'lightpink' => array(255, 182, 193), + 'palevioletred' => array(219, 112, 147), + 'maroon' => array(176, 48, 96), + 'mediumvioletred' => array(199, 21, 133), + 'violetred' => array(208, 32, 144), + 'magenta' => array(255, 0, 255), + 'violet' => array(238, 130, 238), + 'plum' => array(221, 160, 221), + 'orchid' => array(218, 112, 214), + 'mediumorchid' => array(186, 85, 211), + 'darkorchid' => array(153, 50, 204), + 'darkviolet' => array(148, 0, 211), + 'blueviolet' => array(138, 43, 226), + 'purple' => array(160, 32, 240), + 'mediumpurple' => array(147, 112, 219), + 'thistle' => array(216, 191, 216), + 'snow1' => array(255, 250, 250), + 'snow2' => array(238, 233, 233), + 'snow3' => array(205, 201, 201), + 'snow4' => array(139, 137, 137), + 'seashell1' => array(255, 245, 238), + 'seashell2' => array(238, 229, 222), + 'seashell3' => array(205, 197, 191), + 'seashell4' => array(139, 134, 130), + 'AntiqueWhite1' => array(255, 239, 219), + 'AntiqueWhite2' => array(238, 223, 204), + 'AntiqueWhite3' => array(205, 192, 176), + 'AntiqueWhite4' => array(139, 131, 120), + 'bisque1' => array(255, 228, 196), + 'bisque2' => array(238, 213, 183), + 'bisque3' => array(205, 183, 158), + 'bisque4' => array(139, 125, 107), + 'peachPuff1' => array(255, 218, 185), + 'peachpuff2' => array(238, 203, 173), + 'peachpuff3' => array(205, 175, 149), + 'peachpuff4' => array(139, 119, 101), + 'navajowhite1' => array(255, 222, 173), + 'navajowhite2' => array(238, 207, 161), + 'navajowhite3' => array(205, 179, 139), + 'navajowhite4' => array(139, 121, 94), + 'lemonchiffon1' => array(255, 250, 205), + 'lemonchiffon2' => array(238, 233, 191), + 'lemonchiffon3' => array(205, 201, 165), + 'lemonchiffon4' => array(139, 137, 112), + 'ivory1' => array(255, 255, 240), + 'ivory2' => array(238, 238, 224), + 'ivory3' => array(205, 205, 193), + 'ivory4' => array(139, 139, 131), + 'honeydew' => array(193, 205, 193), + 'lavenderblush1' => array(255, 240, 245), + 'lavenderblush2' => array(238, 224, 229), + 'lavenderblush3' => array(205, 193, 197), + 'lavenderblush4' => array(139, 131, 134), + 'mistyrose1' => array(255, 228, 225), + 'mistyrose2' => array(238, 213, 210), + 'mistyrose3' => array(205, 183, 181), + 'mistyrose4' => array(139, 125, 123), + 'azure1' => array(240, 255, 255), + 'azure2' => array(224, 238, 238), + 'azure3' => array(193, 205, 205), + 'azure4' => array(131, 139, 139), + 'slateblue1' => array(131, 111, 255), + 'slateblue2' => array(122, 103, 238), + 'slateblue3' => array(105, 89, 205), + 'slateblue4' => array(71, 60, 139), + 'royalblue1' => array(72, 118, 255), + 'royalblue2' => array(67, 110, 238), + 'royalblue3' => array(58, 95, 205), + 'royalblue4' => array(39, 64, 139), + 'dodgerblue1' => array(30, 144, 255), + 'dodgerblue2' => array(28, 134, 238), + 'dodgerblue3' => array(24, 116, 205), + 'dodgerblue4' => array(16, 78, 139), + 'steelblue1' => array(99, 184, 255), + 'steelblue2' => array(92, 172, 238), + 'steelblue3' => array(79, 148, 205), + 'steelblue4' => array(54, 100, 139), + 'deepskyblue1' => array(0, 191, 255), + 'deepskyblue2' => array(0, 178, 238), + 'deepskyblue3' => array(0, 154, 205), + 'deepskyblue4' => array(0, 104, 139), + 'skyblue1' => array(135, 206, 255), + 'skyblue2' => array(126, 192, 238), + 'skyblue3' => array(108, 166, 205), + 'skyblue4' => array(74, 112, 139), + 'lightskyblue1' => array(176, 226, 255), + 'lightskyblue2' => array(164, 211, 238), + 'lightskyblue3' => array(141, 182, 205), + 'lightskyblue4' => array(96, 123, 139), + 'slategray1' => array(198, 226, 255), + 'slategray2' => array(185, 211, 238), + 'slategray3' => array(159, 182, 205), + 'slategray4' => array(108, 123, 139), + 'lightsteelblue1' => array(202, 225, 255), + 'lightsteelblue2' => array(188, 210, 238), + 'lightsteelblue3' => array(162, 181, 205), + 'lightsteelblue4' => array(110, 123, 139), + 'lightblue1' => array(191, 239, 255), + 'lightblue2' => array(178, 223, 238), + 'lightblue3' => array(154, 192, 205), + 'lightblue4' => array(104, 131, 139), + 'lightcyan1' => array(224, 255, 255), + 'lightcyan2' => array(209, 238, 238), + 'lightcyan3' => array(180, 205, 205), + 'lightcyan4' => array(122, 139, 139), + 'paleturquoise1' => array(187, 255, 255), + 'paleturquoise2' => array(174, 238, 238), + 'paleturquoise3' => array(150, 205, 205), + 'paleturquoise4' => array(102, 139, 139), + 'cadetblue1' => array(152, 245, 255), + 'cadetblue2' => array(142, 229, 238), + 'cadetblue3' => array(122, 197, 205), + 'cadetblue4' => array(83, 134, 139), + 'turquoise1' => array(0, 245, 255), + 'turquoise2' => array(0, 229, 238), + 'turquoise3' => array(0, 197, 205), + 'turquoise4' => array(0, 134, 139), + 'cyan1' => array(0, 255, 255), + 'cyan2' => array(0, 238, 238), + 'cyan3' => array(0, 205, 205), + 'cyan4' => array(0, 139, 139), + 'darkslategray1' => array(151, 255, 255), + 'darkslategray2' => array(141, 238, 238), + 'darkslategray3' => array(121, 205, 205), + 'darkslategray4' => array(82, 139, 139), + 'aquamarine1' => array(127, 255, 212), + 'aquamarine2' => array(118, 238, 198), + 'aquamarine3' => array(102, 205, 170), + 'aquamarine4' => array(69, 139, 116), + 'darkseagreen1' => array(193, 255, 193), + 'darkseagreen2' => array(180, 238, 180), + 'darkseagreen3' => array(155, 205, 155), + 'darkseagreen4' => array(105, 139, 105), + 'seagreen1' => array(84, 255, 159), + 'seagreen2' => array(78, 238, 148), + 'seagreen3' => array(67, 205, 128), + 'seagreen4' => array(46, 139, 87), + 'palegreen1' => array(154, 255, 154), + 'palegreen2' => array(144, 238, 144), + 'palegreen3' => array(124, 205, 124), + 'palegreen4' => array(84, 139, 84), + 'springgreen1' => array(0, 255, 127), + 'springgreen2' => array(0, 238, 118), + 'springgreen3' => array(0, 205, 102), + 'springgreen4' => array(0, 139, 69), + 'chartreuse1' => array(127, 255, 0), + 'chartreuse2' => array(118, 238, 0), + 'chartreuse3' => array(102, 205, 0), + 'chartreuse4' => array(69, 139, 0), + 'olivedrab1' => array(192, 255, 62), + 'olivedrab2' => array(179, 238, 58), + 'olivedrab3' => array(154, 205, 50), + 'olivedrab4' => array(105, 139, 34), + 'darkolivegreen1' => array(202, 255, 112), + 'darkolivegreen2' => array(188, 238, 104), + 'darkolivegreen3' => array(162, 205, 90), + 'darkolivegreen4' => array(110, 139, 61), + 'khaki1' => array(255, 246, 143), + 'khaki2' => array(238, 230, 133), + 'khaki3' => array(205, 198, 115), + 'khaki4' => array(139, 134, 78), + 'lightgoldenrod1' => array(255, 236, 139), + 'lightgoldenrod2' => array(238, 220, 130), + 'lightgoldenrod3' => array(205, 190, 112), + 'lightgoldenrod4' => array(139, 129, 76), + 'yellow1' => array(255, 255, 0), + 'yellow2' => array(238, 238, 0), + 'yellow3' => array(205, 205, 0), + 'yellow4' => array(139, 139, 0), + 'gold1' => array(255, 215, 0), + 'gold2' => array(238, 201, 0), + 'gold3' => array(205, 173, 0), + 'gold4' => array(139, 117, 0), + 'goldenrod1' => array(255, 193, 37), + 'goldenrod2' => array(238, 180, 34), + 'goldenrod3' => array(205, 155, 29), + 'goldenrod4' => array(139, 105, 20), + 'darkgoldenrod1' => array(255, 185, 15), + 'darkgoldenrod2' => array(238, 173, 14), + 'darkgoldenrod3' => array(205, 149, 12), + 'darkgoldenrod4' => array(139, 101, 8), + 'rosybrown1' => array(255, 193, 193), + 'rosybrown2' => array(238, 180, 180), + 'rosybrown3' => array(205, 155, 155), + 'rosybrown4' => array(139, 105, 105), + 'indianred1' => array(255, 106, 106), + 'indianred2' => array(238, 99, 99), + 'indianred3' => array(205, 85, 85), + 'indianred4' => array(139, 58, 58), + 'sienna1' => array(255, 130, 71), + 'sienna2' => array(238, 121, 66), + 'sienna3' => array(205, 104, 57), + 'sienna4' => array(139, 71, 38), + 'burlywood1' => array(255, 211, 155), + 'burlywood2' => array(238, 197, 145), + 'burlywood3' => array(205, 170, 125), + 'burlywood4' => array(139, 115, 85), + 'wheat1' => array(255, 231, 186), + 'wheat2' => array(238, 216, 174), + 'wheat3' => array(205, 186, 150), + 'wheat4' => array(139, 126, 102), + 'tan1' => array(255, 165, 79), + 'tan2' => array(238, 154, 73), + 'tan3' => array(205, 133, 63), + 'tan4' => array(139, 90, 43), + 'chocolate1' => array(255, 127, 36), + 'chocolate2' => array(238, 118, 33), + 'chocolate3' => array(205, 102, 29), + 'chocolate4' => array(139, 69, 19), + 'firebrick1' => array(255, 48, 48), + 'firebrick2' => array(238, 44, 44), + 'firebrick3' => array(205, 38, 38), + 'firebrick4' => array(139, 26, 26), + 'brown1' => array(255, 64, 64), + 'brown2' => array(238, 59, 59), + 'brown3' => array(205, 51, 51), + 'brown4' => array(139, 35, 35), + 'salmon1' => array(255, 140, 105), + 'salmon2' => array(238, 130, 98), + 'salmon3' => array(205, 112, 84), + 'salmon4' => array(139, 76, 57), + 'lightsalmon1' => array(255, 160, 122), + 'lightsalmon2' => array(238, 149, 114), + 'lightsalmon3' => array(205, 129, 98), + 'lightsalmon4' => array(139, 87, 66), + 'orange1' => array(255, 165, 0), + 'orange2' => array(238, 154, 0), + 'orange3' => array(205, 133, 0), + 'orange4' => array(139, 90, 0), + 'darkorange1' => array(255, 127, 0), + 'darkorange2' => array(238, 118, 0), + 'darkorange3' => array(205, 102, 0), + 'darkorange4' => array(139, 69, 0), + 'coral1' => array(255, 114, 86), + 'coral2' => array(238, 106, 80), + 'coral3' => array(205, 91, 69), + 'coral4' => array(139, 62, 47), + 'tomato1' => array(255, 99, 71), + 'tomato2' => array(238, 92, 66), + 'tomato3' => array(205, 79, 57), + 'tomato4' => array(139, 54, 38), + 'orangered1' => array(255, 69, 0), + 'orangered2' => array(238, 64, 0), + 'orangered3' => array(205, 55, 0), + 'orangered4' => array(139, 37, 0), + 'deeppink1' => array(255, 20, 147), + 'deeppink2' => array(238, 18, 137), + 'deeppink3' => array(205, 16, 118), + 'deeppink4' => array(139, 10, 80), + 'hotpink1' => array(255, 110, 180), + 'hotpink2' => array(238, 106, 167), + 'hotpink3' => array(205, 96, 144), + 'hotpink4' => array(139, 58, 98), + 'pink1' => array(255, 181, 197), + 'pink2' => array(238, 169, 184), + 'pink3' => array(205, 145, 158), + 'pink4' => array(139, 99, 108), + 'lightpink1' => array(255, 174, 185), + 'lightpink2' => array(238, 162, 173), + 'lightpink3' => array(205, 140, 149), + 'lightpink4' => array(139, 95, 101), + 'palevioletred1' => array(255, 130, 171), + 'palevioletred2' => array(238, 121, 159), + 'palevioletred3' => array(205, 104, 137), + 'palevioletred4' => array(139, 71, 93), + 'maroon1' => array(255, 52, 179), + 'maroon2' => array(238, 48, 167), + 'maroon3' => array(205, 41, 144), + 'maroon4' => array(139, 28, 98), + 'violetred1' => array(255, 62, 150), + 'violetred2' => array(238, 58, 140), + 'violetred3' => array(205, 50, 120), + 'violetred4' => array(139, 34, 82), + 'magenta1' => array(255, 0, 255), + 'magenta2' => array(238, 0, 238), + 'magenta3' => array(205, 0, 205), + 'magenta4' => array(139, 0, 139), + 'mediumred' => array(140, 34, 34), + 'orchid1' => array(255, 131, 250), + 'orchid2' => array(238, 122, 233), + 'orchid3' => array(205, 105, 201), + 'orchid4' => array(139, 71, 137), + 'plum1' => array(255, 187, 255), + 'plum2' => array(238, 174, 238), + 'plum3' => array(205, 150, 205), + 'plum4' => array(139, 102, 139), + 'mediumorchid1' => array(224, 102, 255), + 'mediumorchid2' => array(209, 95, 238), + 'mediumorchid3' => array(180, 82, 205), + 'mediumorchid4' => array(122, 55, 139), + 'darkorchid1' => array(191, 62, 255), + 'darkorchid2' => array(178, 58, 238), + 'darkorchid3' => array(154, 50, 205), + 'darkorchid4' => array(104, 34, 139), + 'purple1' => array(155, 48, 255), + 'purple2' => array(145, 44, 238), + 'purple3' => array(125, 38, 205), + 'purple4' => array(85, 26, 139), + 'mediumpurple1' => array(171, 130, 255), + 'mediumpurple2' => array(159, 121, 238), + 'mediumpurple3' => array(137, 104, 205), + 'mediumpurple4' => array(93, 71, 139), + 'thistle1' => array(255, 225, 255), + 'thistle2' => array(238, 210, 238), + 'thistle3' => array(205, 181, 205), + 'thistle4' => array(139, 123, 139), + 'gray1' => array(10, 10, 10), + 'gray2' => array(40, 40, 30), + 'gray3' => array(70, 70, 70), + 'gray4' => array(100, 100, 100), + 'gray5' => array(130, 130, 130), + 'gray6' => array(160, 160, 160), + 'gray7' => array(190, 190, 190), + 'gray8' => array(210, 210, 210), + 'gray9' => array(240, 240, 240), + 'darkgray' => array(100, 100, 100), + 'darkblue' => array(0, 0, 139), + 'darkcyan' => array(0, 139, 139), + 'darkmagenta' => array(139, 0, 139), + 'darkred' => array(139, 0, 0), + 'silver' => array(192, 192, 192), + 'eggplant' => array(144, 176, 168), + 'lightgreen' => array(144, 238, 144) +); diff --git a/framework/Image/Image/svg.php b/framework/Image/Image/svg.php new file mode 100644 index 000000000..3e051517c --- /dev/null +++ b/framework/Image/Image/svg.php @@ -0,0 +1,354 @@ + + * @since Horde 3.0 + * @package Horde_Image + */ +class Horde_Image_svg extends Horde_Image { + + var $_svg; + + /** + * Capabilites of this driver. + * + * @var array + */ + var $_capabilities = array('canvas'); + + function Horde_Image_svg($params) + { + parent::Horde_Image($params); + $this->_svg = new XML_SVG_Document(array('width' => $this->_width, + 'height' => $this->_height)); + } + + function getContentType() + { + return 'image/svg+xml'; + } + + function getLink($url, $title = '') + { + } + + function display() + { + $this->_svg->printElement(); + } + + /** + * Return the raw data for this image. + * + * @return string The raw image data. + */ + function raw() + { + return $this->_svg->bufferObject(); + } + + function getFont($font) + { + return $font; + } + + function _createSymbol($s, $id) + { + $s->setParam('id', $id); + $defs = new XML_SVG_Defs(); + $defs->addChild($s); + $this->_svg->addChild($defs); + } + + function _createDropShadow($id = 'dropShadow') + { + $defs = new XML_SVG_Defs(); + $filter = new XML_SVG_Filter(array('id' => $id)); + $filter->addPrimitive('GaussianBlur', array('in' => 'SourceAlpha', + 'stdDeviation' => 2, + 'result' => 'blur')); + $filter->addPrimitive('Offset', array('in' => 'blur', + 'dx' => 4, + 'dy' => 4, + 'result' => 'offsetBlur')); + $merge = new XML_SVG_FilterPrimitive('Merge'); + $merge->addMergeNode('offsetBlur'); + $merge->addMergeNode('SourceGraphic'); + + $filter->addChild($merge); + $defs->addChild($filter); + $this->_svg->addChild($defs); + } + + /** + * Draws a text string on the image in a specified location, with + * the specified style information. + * + * @param string $text The text to draw. + * @param integer $x The left x coordinate of the start of the text string. + * @param integer $y The top y coordinate of the start of the text string. + * @param string $font The font identifier you want to use for the text. + * @param string $color The color that you want the text displayed in. + * @param integer $direction An integer that specifies the orientation of the text. + */ + function text($string, $x, $y, $font = 'monospace', $color = 'black', $direction = 0) + { + $height = 12; + $style = 'font-family:' . $font . ';font-height:' . $height . 'px;fill:' . $this->getHexColor($color) . ';text-anchor:start;'; + $transform = 'rotate(' . $direction . ',' . $x . ',' . $y . ')'; + $this->_svg->addChild(new XML_SVG_Text(array('text' => $string, + 'x' => (int)$x, + 'y' => (int)$y + $height, + 'transform' => $transform, + 'style' => $style))); + } + + /** + * Draw a circle. + * + * @param integer $x The x coordinate of the centre. + * @param integer $y The y coordinate of the centre. + * @param integer $r The radius of the circle. + * @param string $color The line color of the circle. + * @param string $fill The color to fill the circle. + */ + function circle($x, $y, $r, $color, $fill = null) + { + if (!empty($fill)) { + $style = 'fill:' . $this->getHexColor($fill) . '; '; + } else { + $style = 'fill:none;'; + } + $style .= 'stroke:' . $this->getHexColor($color) . '; stroke-width:1'; + + $this->_svg->addChild(new XML_SVG_Circle(array('cx' => $x, + 'cy' => $y, + 'r' => $r, + 'style' => $style))); + } + + /** + * Draw a polygon based on a set of vertices. + * + * @param array $vertices An array of x and y labeled arrays + * (eg. $vertices[0]['x'], $vertices[0]['y'], ...). + * @param string $color The color you want to draw the polygon with. + * @param string $fill The color to fill the polygon. + */ + function polygon($verts, $color, $fill = null) + { + if (!empty($fill)) { + $style = 'fill:' . $this->getHexColor($fill) . '; '; + } else { + $style = 'fill:none;'; + } + $style .= 'stroke:' . $this->getHexColor($color) . '; stroke-width:1'; + + $points = ''; + foreach ($verts as $v) { + $points .= $v['x'] . ',' . $v['y'] . ' '; + } + $points = trim($points); + + $this->_svg->addChild(new XML_SVG_Polygon(array('points' => $points, + 'style' => $style))); + } + + /** + * Draw a rectangle. + * + * @param integer $x The left x-coordinate of the rectangle. + * @param integer $y The top y-coordinate of the rectangle. + * @param integer $width The width of the rectangle. + * @param integer $height The height of the rectangle. + * @param string $color The line color of the rectangle. + * @param string $fill The color to fill the rectangle. + */ + function rectangle($x, $y, $width, $height, $color, $fill = null) + { + if (!empty($fill)) { + $style = 'fill:' . $this->getHexColor($fill) . '; '; + } else { + $style = 'fill:none;'; + } + $style .= 'stroke:' . $this->getHexColor($color) . '; stroke-width:1'; + + $this->_svg->addChild(new XML_SVG_Rect(array('x' => $x, + 'y' => $y, + 'width' => $width, + 'height' => $height, + 'style' => $style))); + } + + /** + * Draw a rectangle. + * + * @param integer $x The left x-coordinate of the rectangle. + * @param integer $y The top y-coordinate of the rectangle. + * @param integer $width The width of the rectangle. + * @param integer $height The height of the rectangle. + * @param integer $round The width of the corner rounding. + * @param string $color The line color of the rectangle. + * @param string $fill The color to fill the rectangle. + */ + function roundedRectangle($x, $y, $width, $height, $round, $color, $fill) + { + if (!empty($fill)) { + $style = 'fill:' . $this->getHexColor($fill) . '; '; + } else { + $style = 'fill:none;'; + } + $style .= 'stroke:' . $this->getHexColor($color) . '; stroke-width:1'; + + $this->_svg->addChild(new XML_SVG_Rect(array('x' => $x, + 'y' => $y, + 'rx' => $round, + 'ry' => $round, + 'width' => $width, + 'height' => $height, + 'style' => $style))); + } + + /** + * Draw a line. + * + * @param integer $x0 The x coordinate of the start. + * @param integer $y0 The y coordinate of the start. + * @param integer $x1 The x coordinate of the end. + * @param integer $y1 The y coordinate of the end. + * @param string $color The line color. + * @param string $width The width of the line. + */ + function line($x1, $y1, $x2, $y2, $color = 'black', $width = 1) + { + $style = 'stroke:' . $this->getHexColor($color) . '; stroke-width:' . (int)$width; + $this->_svg->addChild(new XML_SVG_Line(array('x1' => $x1, + 'y1' => $y1, + 'x2' => $x2, + 'y2' => $y2, + 'style' => $style))); + } + + /** + * Draw a dashed line. + * + * @param integer $x0 The x coordinate of the start. + * @param integer $y0 The y coordinate of the start. + * @param integer $x1 The x coordinate of the end. + * @param integer $y1 The y coordinate of the end. + * @param string $color The line color. + * @param string $width The width of the line. + * @param integer $dash_length The length of a dash on the dashed line + * @param integer $dash_space The length of a space in the dashed line + */ + function dashedLine($x1, $y1, $x2, $y2, $color = 'black', $width = 1, $dash_length = 2, $dash_space = 2) + { + $style = 'stroke:' . $this->getHexColor($color) . '; stroke-width:' . (int)$width . '; stroke-dasharray:' . $dash_length . ',' . $dash_space . ';'; + $this->_svg->addChild(new XML_SVG_Line(array('x1' => $x1, + 'y1' => $y1, + 'x2' => $x2, + 'y2' => $y2, + 'style' => $style))); + } + + /** + * Draw a polyline (a non-closed, non-filled polygon) based on a + * set of vertices. + * + * @param array $vertices An array of x and y labeled arrays + * (eg. $vertices[0]['x'], $vertices[0]['y'], ...). + * @param string $color The color you want to draw the line with. + * @param string $width The width of the line. + */ + function polyline($verts, $color, $width = 1) + { + $style = 'stroke:' . $this->getHexColor($color) . '; stroke-width:' . $width . ';fill:none;'; + + // Calculate the path entry. + $path = ''; + + $first = true; + foreach ($verts as $vert) { + if ($first) { + $first = false; + $path .= 'M ' . $vert['x'] . ',' . $vert['y']; + } else { + $path .= ' L ' . $vert['x'] . ',' . $vert['y']; + } + } + + $this->_svg->addChild(new XML_SVG_Path(array('d' => $path, + 'style' => $style))); + } + + /** + * Draw an arc. + * + * @param integer $x The x coordinate of the centre. + * @param integer $y The y coordinate of the centre. + * @param integer $r The radius of the arc. + * @param integer $start The start angle of the arc. + * @param integer $end The end angle of the arc. + * @param string $color The line color of the arc. + * @param string $fill The fill color of the arc (defaults to none). + */ + function arc($x, $y, $r, $start, $end, $color = 'black', $fill = null) + { + if (!empty($fill)) { + $style = 'fill:' . $this->getHexColor($fill) . '; '; + } else { + $style = 'fill:none;'; + } + $style .= 'stroke:' . $this->getHexColor($color) . '; stroke-width:1'; + + $mid = round(($start + $end) / 2); + + // Calculate the path entry. + $path = ''; + + // If filled, draw the outline. + if (!empty($fill)) { + // Start at the center of the ellipse the arc is on. + $path .= "M $x,$y "; + + // Draw out to ellipse edge. + list($arcX, $arcY) = $this->_circlePoint($start, $r * 2); + $path .= 'L ' . round($x + $arcX) . ',' . + round($y + $arcY) . ' '; + } + + // Draw arcs. + list($arcX, $arcY) = $this->_circlePoint($mid, $r * 2); + $path .= "A $r,$r 0 0 1 " . + round($x + $arcX) . ',' . + round($y + $arcY) . ' '; + + list($arcX, $arcY) = $this->_circlePoint($end, $r * 2); + $path .= "A $r,$r 0 0 1 " . + round($x + $arcX) . ',' . + round($y + $arcY) . ' '; + + // If filled, close the outline. + if (!empty($fill)) { + $path .= 'Z'; + } + + $path = trim($path); + + $this->_svg->addChild(new XML_SVG_Path(array('d' => $path, + 'style' => $style))); + } + +} diff --git a/framework/Image/Image/swf.php b/framework/Image/Image/swf.php new file mode 100644 index 000000000..1cb5cb73f --- /dev/null +++ b/framework/Image/Image/swf.php @@ -0,0 +1,532 @@ + + * @since Horde 3.0 + * @package Horde_Image + */ +class Horde_Image_swf extends Horde_Image { + + /** + * Capabilites of this driver. + * + * @var array + */ + var $_capabilities = array('canvas'); + + /** + * SWF root movie. + * + * @var resource + */ + var $_movie; + + function Horde_Image_swf($params) + { + parent::Horde_Image($params); + + $this->_movie = new SWFMovie(); + $this->_movie->setDimension($this->_width, $this->_height); + + // FIXME: honor the 'background' parameter here. + $this->_movie->setBackground(0xff, 0xff, 0xff); + $this->_movie->setRate(30); + } + + function getContentType() + { + return 'application/x-shockwave-flash'; + } + + /** + * Display the movie. + */ + function display() + { + $this->headers(); + $this->_movie->output(); + } + + /** + * Return the raw data for this image. + * + * @return string The raw image data. + */ + function raw() + { + ob_start(); + $this->_movie->output(); + $data = ob_get_contents(); + ob_end_clean(); + + return $data; + } + + /** + * Creates a color that can be accessed in this object. When a + * color is set, the rgba values are returned in an array. + * + * @param string $name The name of the color. + * + * @return array The red, green, blue, alpha values of the color. + */ + function allocateColor($name) + { + list($r, $g, $b) = $this->getRGB($name); + return array('red' => $r, + 'green' => $g, + 'blue' => $b, + 'alpha' => 255); + } + + function getFont($font) + { + switch ($font) { + case 'sans-serif': + return '_sans'; + + case 'serif': + return '_serif'; + + case 'monospace': + return '_typewriter'; + + default: + return $font; + } + } + + /** + * Draws a text string on the image in a specified location, with + * the specified style information. + * + * @param string $text The text to draw. + * @param integer $x The left x coordinate of the start of the text string. + * @param integer $y The top y coordinate of the start of the text string. + * @param string $font The font identifier you want to use for the text. + * @param string $color The color that you want the text displayed in. + * @param integer $direction An integer that specifies the orientation of the text. + */ + function text($string, $x, $y, $font = 'monospace', $color = 'black', $direction = 0) + { + $color = $this->allocateColor($color); + + if (!strncasecmp(PHP_OS, 'WIN', 3)) { + $text = new SWFTextField(SWFTEXTFIELD_NOEDIT); + } else { + $text = new SWFText(); + } + $text->setColor($color['red'], $color['green'], $color['blue'], $color['alpha']); + $text->addString($string); + $text->setFont(new SWFFont($this->getFont($font))); + + $t = $this->_movie->add($text); + $t->moveTo($x, $y); + $t->rotate($direction); + + return $t; + } + + /** + * Draw a circle. + * + * @param integer $x The x co-ordinate of the centre. + * @param integer $y The y co-ordinate of the centre. + * @param integer $r The radius of the circle. + * @param string $color The line color of the circle. + * @param string $fill The color to fill the circle. + */ + function circle($x, $y, $r, $color, $fill = 'none') + { + $s = new SWFShape(); + $color = $this->allocateColor($color); + $s->setLine(1, $color['red'], $color['green'], $color['blue'], $color['alpha']); + + if ($fill != 'none') { + $fillColor = $this->allocateColor($fill); + $f = $s->addFill($fillColor['red'], $fillColor['green'], $fillColor['blue'], $fillColor['alpha']); + $s->setRightFill($f); + } + + $a = $r * 0.414213562; // = tan(22.5 deg) + $b = $r * 0.707106781; // = sqrt(2)/2 = sin(45 deg) + + $s->movePenTo($x + $r, $y); + + $s->drawCurveTo($x + $r, $y - $a, $x + $b, $y - $b); + $s->drawCurveTo($x + $a, $y - $r, $x, $y - $r); + $s->drawCurveTo($x - $a, $y - $r, $x - $b, $y - $b); + $s->drawCurveTo($x - $r, $y - $a, $x - $r, $y); + $s->drawCurveTo($x - $r, $y + $a, $x - $b, $y + $b); + $s->drawCurveTo($x - $a, $y + $r, $x, $y + $r); + $s->drawCurveTo($x + $a, $y + $r, $x + $b, $y + $b); + $s->drawCurveTo($x + $r, $y + $a, $x + $r, $y); + + return $this->_movie->add($s); + } + + /** + * Draw a polygon based on a set of vertices. + * + * @param array $vertices An array of x and y labeled arrays + * (eg. $vertices[0]['x'], $vertices[0]['y'], ...). + * @param string $color The color you want to draw the polygon with. + * @param string $fill The color to fill the polygon. + */ + function polygon($verts, $color, $fill = 'none') + { + $color = $this->allocateColor($color); + + if (is_array($color) && is_array($verts) && (sizeof($verts) > 2)) { + $shape = new SWFShape(); + $shape->setLine(1, $color['red'], $color['green'], $color['blue'], $color['alpha']); + + if ($fill != 'none') { + $fillColor = $this->allocateColor($fill); + $f = $shape->addFill($fillColor['red'], $fillColor['green'], $fillColor['blue'], $fillColor['alpha']); + $shape->setRightFill($f); + } + + $first_done = false; + foreach ($verts as $value) { + if (!$first_done) { + $shape->movePenTo($value['x'], $value['y']); + $first_done = true; + $first_x = $value['x']; + $first_y = $value['y']; + } + $shape->drawLineTo($value['x'], $value['y']); + } + $shape->drawLineTo($first_x, $first_y); + + return $this->_movie->add($shape); + } else { + // If the color is an array and the vertices is a an array + // of more than 2 points. + return false; + } + } + + /** + * Draw a rectangle. + * + * @param integer $x The left x-coordinate of the rectangle. + * @param integer $y The top y-coordinate of the rectangle. + * @param integer $width The width of the rectangle. + * @param integer $height The height of the rectangle. + * @param string $color The line color of the rectangle. + * @param string $fill The color to fill the rectangle. + */ + function rectangle($x, $y, $width, $height, $color, $fill = 'none') + { + $verts[0] = array('x' => $x, 'y' => $y); + $verts[1] = array('x' => $x + $width, 'y' => $y); + $verts[2] = array('x' => $x + $width, 'y' => $y + $height); + $verts[3] = array('x' => $x, 'y' => $y + $height); + + return $this->polygon($verts, $color, $fill); + } + + /** + * Draw a rectangle. + * + * @param integer $x The left x-coordinate of the rectangle. + * @param integer $y The top y-coordinate of the rectangle. + * @param integer $width The width of the rectangle. + * @param integer $height The height of the rectangle. + * @param integer $round The width of the corner rounding. + * @param string $color The line color of the rectangle. + * @param string $fill The color to fill the rectangle. + */ + function roundedRectangle($x, $y, $width, $height, $round, $color = 'black', $fill = 'none') + { + if ($round <= 0) { + // Optimize out any calls with no corner rounding. + return $this->rectangle($x, $y, $width, $height, $color, $fill); + } + + $s = new SWFShape(); + $color = $this->allocateColor($color); + $s->setLine(1, $color['red'], $color['green'], $color['blue'], $color['alpha']); + + if ($fill != 'none') { + $fillColor = $this->allocateColor($fill); + $f = $s->addFill($fillColor['red'], $fillColor['green'], $fillColor['blue'], $fillColor['alpha']); + $s->setRightFill($f); + } + + // Set corner points to avoid lots of redundant math. + $x1 = $x + $round; + $y1 = $y + $round; + + $x2 = $x + $width - $round; + $y2 = $y + $round; + + $x3 = $x + $width - $round; + $y3 = $y + $height - $round; + + $x4 = $x + $round; + $y4 = $y + $height - $round; + + // Start in the upper left. + $p1 = $this->_arcPoints($round, 180, 225); + $p2 = $this->_arcPoints($round, 225, 270); + + // Start at the lower left corner of the top left curve. + $s->movePenTo($x1 + $p1['x1'], $y1 + $p1['y1']); + + // Draw the upper left corner. + $s->drawCurveTo($x1 + $p1['x3'], $y1 + $p1['y3'], $x1 + $p1['x2'], $y1 + $p1['y2']); + $s->drawCurveTo($x1 + $p2['x3'], $y1 + $p2['y3'], $x1 + $p2['x2'], $y1 + $p2['y2']); + + // Calculate the upper right points. + $p3 = $this->_arcPoints($round, 270, 315); + $p4 = $this->_arcPoints($round, 315, 360); + + // Connect the top left and right curves. + $s->drawLineTo($x2 + $p3['x1'], $y2 + $p3['y1']); + + // Draw the upper right corner. + $s->drawCurveTo($x2 + $p3['x3'], $y2 + $p3['y3'], $x2 + $p3['x2'], $y2 + $p3['y2']); + $s->drawCurveTo($x2 + $p4['x3'], $y2 + $p4['y3'], $x2 + $p4['x2'], $y2 + $p4['y2']); + + // Calculate the lower right points. + $p5 = $this->_arcPoints($round, 0, 45); + $p6 = $this->_arcPoints($round, 45, 90); + + // Connect the top right and lower right curves. + $s->drawLineTo($x3 + $p5['x1'], $y3 + $p5['y1']); + + // Draw the lower right corner. + $s->drawCurveTo($x3 + $p5['x3'], $y3 + $p5['y3'], $x3 + $p5['x2'], $y3 + $p5['y2']); + $s->drawCurveTo($x3 + $p6['x3'], $y3 + $p6['y3'], $x3 + $p6['x2'], $y3 + $p6['y2']); + + // Calculate the lower left points. + $p7 = $this->_arcPoints($round, 90, 135); + $p8 = $this->_arcPoints($round, 135, 180); + + // Connect the bottom right and bottom left curves. + $s->drawLineTo($x4 + $p7['x1'], $y4 + $p7['y1']); + + // Draw the lower left corner. + $s->drawCurveTo($x4 + $p7['x3'], $y4 + $p7['y3'], $x4 + $p7['x2'], $y4 + $p7['y2']); + $s->drawCurveTo($x4 + $p8['x3'], $y4 + $p8['y3'], $x4 + $p8['x2'], $y4 + $p8['y2']); + + // Close the shape. + $s->drawLineTo($x1 + $p1['x1'], $y1 + $p1['y1']); + + return $this->_movie->add($s); + } + + /** + * Draw a line. + * + * @param integer $x0 The x co-ordinate of the start. + * @param integer $y0 The y co-ordinate of the start. + * @param integer $x1 The x co-ordinate of the end. + * @param integer $y1 The y co-ordinate of the end. + * @param string $color The line color. + * @param string $width The width of the line. + */ + function line($x1, $y1, $x2, $y2, $color = 'black', $width = 1) + { + $color = $this->allocateColor($color); + + if (is_array($color)) { + $shape = new SWFShape(); + $shape->setLine($width, $color['red'], $color['green'], $color['blue'], $color['alpha']); + $shape->movePenTo($x1, $y1); + $shape->drawLineTo($x2, $y2); + + return $this->_movie->add($shape); + } else { + return false; + } + } + + /** + * Draw a dashed line. + * + * @param integer $x0 The x co-ordinate of the start. + * @param integer $y0 The y co-ordinate of the start. + * @param integer $x1 The x co-ordinate of the end. + * @param integer $y1 The y co-ordinate of the end. + * @param string $color The line color. + * @param string $width The width of the line. + * @param integer $dash_length The length of a dash on the dashed line + * @param integer $dash_space The length of a space in the dashed line + */ + function dashedLine($x0, $y0, $x1, $y1, $color = 'black', $width = 1, $dash_length = 2, $dash_space = 2) + { + // Get the length of the line in pixels. + $line_length = max(ceil(sqrt(pow(($x1 - $x0), 2) + pow(($y1 - $y0), 2))), 2); + + $cosTheta = ($x1 - $x0) / $line_length; + $sinTheta = ($y1 - $y0) / $line_length; + $lastx = $x0; + $lasty = $y0; + + // Draw the dashed line. + for ($i = 0; $i < $line_length; $i += ($dash_length + $dash_space)) { + $x = ($dash_length * $cosTheta) + $lastx; + $y = ($dash_length * $sinTheta) + $lasty; + + $this->line($lastx, $lasty, $x, $y, $color); + + $lastx = $x + ($dash_space * $cosTheta); + $lasty = $y + ($dash_space * $sinTheta); + } + } + + /** + * Draw a polyline (a non-closed, non-filled polygon) based on a + * set of vertices. + * + * @param array $vertices An array of x and y labeled arrays + * (eg. $vertices[0]['x'], $vertices[0]['y'], ...). + * @param string $color The color you want to draw the line with. + * @param string $width The width of the line. + */ + function polyline($verts, $color, $width = 1) + { + $color = $this->allocateColor($color); + + $shape = new SWFShape(); + $shape->setLine($width, $color['red'], $color['green'], $color['blue'], $color['alpha']); + + $first_done = false; + foreach ($verts as $value) { + if (!$first_done) { + $shape->movePenTo($value['x'], $value['y']); + $first_done = true; + } + $shape->drawLineTo($value['x'], $value['y']); + } + + return $this->_movie->add($shape); + } + + /** + * Draw an arc. + * + * @param integer $x The x co-ordinate of the centre. + * @param integer $y The y co-ordinate of the centre. + * @param integer $r The radius of the arc. + * @param integer $start The start angle of the arc. + * @param integer $end The end angle of the arc. + * @param string $color The line color of the arc. + * @param string $fill The fill color of the arc. + */ + function arc($x, $y, $r, $start, $end, $color = 'black', $fill = 'none') + { + $s = new SWFShape(); + $color = $this->allocateColor($color); + $s->setLine(1, $color['red'], $color['green'], $color['blue'], $color['alpha']); + + if ($fill != 'none') { + $fillColor = $this->allocateColor($fill); + $f = $s->addFill($fillColor['red'], $fillColor['green'], $fillColor['blue'], $fillColor['alpha']); + $s->setRightFill($f); + } + + if ($end - $start <= 45) { + $pts = $this->_arcPoints($r, $start, $end); + $s->movePenTo($x, $y); + $s->drawLineTo($pts['x1'] + $x, $pts['y1'] + $y); + $s->drawCurveTo($pts['x3'] + $x, $pts['y3'] + $y, $pts['x2'] + $x, $pts['y2'] + $y); + $s->drawLineTo($x, $y); + } else { + $sections = ceil(($end - $start) / 45); + for ($i = 0; $i < $sections; $i++) { + $pts = $this->_arcPoints($r, $start + ($i * 45), ($start + (($i + 1) * 45) > $end) + ? $end + : ($start + (($i + 1) * 45))); + + // If we are on the first section, move the pen to the + // centre and draw out to the edge. + if ($i == 0 && $fill != 'none') { + $s->movePenTo($x, $y); + $s->drawLineTo($pts['x1'] + $x, $pts['y1'] + $y); + } else { + $s->movePenTo($pts['x1'] + $x, $pts['y1'] + $y); + } + + // Draw the arc. + $s->drawCurveTo($pts['x3'] + $x, $pts['y3'] + $y, $pts['x2'] + $x, $pts['y2'] + $y); + } + + if ($fill != 'none') { + // Draw a line from the edge back to the centre to close + // off the segment. + $s->drawLineTo($x, $y); + } + } + + return $this->_movie->add($s); + } + + /** + * Draw a rectangle filled with a gradient from $color1 to + * $color2. + * + * @param integer $x The left x-coordinate of the rectangle. + * @param integer $y The top y-coordinate of the rectangle. + * @param integer $width The width of the rectangle. + * @param integer $height The height of the rectangle. + * @param string $color The outline color of the rectangle. + * @param string $fill1 The name of the start color for the gradient. + * @param string $fill2 The name of the end color for the gradient. + */ + function gradientRectangle($x, $y, $width, $height, $color = 'black', $fill1 = 'black', $fill2 = 'white') + { + $s = new SWFShape(); + + if ($color != 'none') { + $color = $this->allocateColor($color); + $s->setLine(1, $color['red'], $color['green'], $color['blue'], $color['alpha']); + } + + $fill1 = $this->allocateColor($fill1); + $fill2 = $this->allocateColor($fill2); + $gradient = new SWFGradient(); + $gradient->addEntry(0.0, $fill1['red'], $fill1['green'], $fill1['blue'], $fill1['alpha']); + $gradient->addEntry(1.0, $fill2['red'], $fill2['green'], $fill2['blue'], $fill2['alpha']); + + $f = $s->addFill($gradient, SWFFILL_LINEAR_GRADIENT); + $f->scaleTo($width / $this->_width); + $f->moveTo($x, $y); + $s->setRightFill($f); + + $verts[0] = array('x' => $x, 'y' => $y); + $verts[1] = array('x' => $x + $width, 'y' => $y); + $verts[2] = array('x' => $x + $width, 'y' => $y + $height); + $verts[3] = array('x' => $x, 'y' => $y + $height); + + $first_done = false; + foreach ($verts as $vert) { + if (!$first_done) { + $s->movePenTo($vert['x'], $vert['y']); + $first_done = true; + $first_x = $vert['x']; + $first_y = $vert['y']; + } + $s->drawLineTo($vert['x'], $vert['y']); + } + $s->drawLineTo($first_x, $first_y); + + return $this->_movie->add($s); + } + +} diff --git a/framework/Image/lib/Horde/Image.php b/framework/Image/lib/Horde/Image.php new file mode 100644 index 000000000..b1a48a374 --- /dev/null +++ b/framework/Image/lib/Horde/Image.php @@ -0,0 +1,664 @@ + + * @author Michael J. Rubinsky + * + * @package Horde_Image + * + * @TODO: - Can we depend on the Util:: class or some other solution needed? + * - Exceptions + */ +class Horde_Image +{ + /** + * Background color. + * + * @var string + */ + protected $_background = 'white'; + + /** + * Observers. + * + * @var array + */ + protected $_observers = array(); + + /** + * Capabilites of this driver. + * + * @var array + */ + protected $_capabilities = array(); + + /** + * The current image data. + * + * @var string + */ + protected $_data = ''; + + /** + * The current image id. + * + * @TODO: Do we *really* need an image id...and if so, we can make the + * parameter optional in the methods that take one? + * + * @var string + */ + protected $_id = ''; + + /** + * Logger + */ + protected $_logger; + + // @TODO: width/height should be protected since they aren't reliable + // (should use ::getDimensions()) but we need a way to set them + // to zero from Effects... leaving public until a clearGeometry() + // method is implemented. + /** + * The current width of the image data. + * + * @var integer + */ + public $_width = 0; + + /** + * The current height of the image data. + * + * @var integer + */ + public $_height = 0; + + /** + * A directory for temporary files. + * + * @var string + */ + protected $_tmpdir; + + /** + * Array containing available Effects + * + * @var array + */ + protected $_loadedEffects = array(); + + /** + * What kind of images should ImageMagick generate? Defaults to 'png'. + * + * @var string + */ + protected $_type = 'png'; + + /** + * Constructor. + * + * @param string $rgb The base color for generated pixels/images. + */ + protected function __construct($params, $context = array()) + { + //@TODO: This is a temporary BC hack until I update all new Horde_Image calls + if (empty($context['tmpdir'])) { + throw new InvalidArgumentException('A path to a temporary directory is required.'); + } + $this->_tmpdir = $context['tmpdir']; + if (isset($params['width'])) { + $this->_width = $params['width']; + } + if (isset($params['height'])) { + $this->_height = $params['height']; + } + if (!empty($params['type'])) { + $this->_type = $params['type']; + } + + if (!empty($context['logger'])) { + $this->_logger = $context['logger']; + } + + $this->_background = isset($params['background']) ? $params['background'] : 'white'; + } + + /** + * Getter for the capabilities array + * + * @return array + */ + public function getCapabilities() + { + return $this->_capabilities; + } + + /** + * Check the existence of a particular capability. + * + * @param string $capability The capability to check for. + * + * @return boolean + */ + public function hasCapability($capability) + { + return in_array($capability, $this->_capabilities); + } + + /** + * Generate image headers. + */ + public function headers() + { + header('Content-type: ' . $this->getContentType()); + } + + /** + * Return the content type for this image. + * + * @return string The content type for this image. + */ + public function getContentType() + { + return 'image/' . $this->_type; + } + + /** + * Getter for the simplified image type. + * + * @return string The type of image (png, jpg, etc...) + */ + public function getType() + { + return $this->_type; + } + + /** + * Calculate a lighter (or darker) version of a color. + * + * @static + * + * @param string $color An HTML color, e.g.: #ffffcc. + * @param string $factor TODO + * + * @return string A modified HTML color. + */ + static public function modifyColor($color, $factor = 0x11) + { + $r = hexdec(substr($color, 1, 2)) + $factor; + $g = hexdec(substr($color, 3, 2)) + $factor; + $b = hexdec(substr($color, 5, 2)) + $factor; + + $r = min(max($r, 0), 255); + $g = min(max($g, 0), 255); + $b = min(max($b, 0), 255); + + return '#' . str_pad(dechex($r), 2, '0', STR_PAD_LEFT) . str_pad(dechex($g), 2, '0', STR_PAD_LEFT) . str_pad(dechex($b), 2, '0', STR_PAD_LEFT); + } + + /** + * Calculate a more intense version of a color. + * + * @static + * + * @param string $color An HTML color, e.g.: #ffffcc. + * @param string $factor TODO + * + * @return string A more intense HTML color. + */ + static public function moreIntenseColor($color, $factor = 0x11) + { + $r = hexdec(substr($color, 1, 2)); + $g = hexdec(substr($color, 3, 2)); + $b = hexdec(substr($color, 5, 2)); + + if ($r >= $g && $r >= $b) { + $g = $g / $r; + $b = $b / $r; + + $r += $factor; + $g = floor($g * $r); + $b = floor($b * $r); + } elseif ($g >= $r && $g >= $b) { + $r = $r / $g; + $b = $b / $g; + + $g += $factor; + $r = floor($r * $g); + $b = floor($b * $g); + } else { + $r = $r / $b; + $g = $g / $b; + + $b += $factor; + $r = floor($r * $b); + $g = floor($g * $b); + } + + $r = min(max($r, 0), 255); + $g = min(max($g, 0), 255); + $b = min(max($b, 0), 255); + + return '#' . str_pad(dechex($r), 2, '0', STR_PAD_LEFT) . str_pad(dechex($g), 2, '0', STR_PAD_LEFT) . str_pad(dechex($b), 2, '0', STR_PAD_LEFT); + } + + /** + * Returns the brightness of a color. + * + * @static + * + * @param string $color An HTML color, e.g.: #ffffcc. + * + * @return integer The brightness on a scale of 0 to 255. + */ + static public function brightness($color) + { + $r = hexdec(substr($color, 1, 2)); + $g = hexdec(substr($color, 3, 2)); + $b = hexdec(substr($color, 5, 2)); + + return round((($r * 299) + ($g * 587) + ($b * 114)) / 1000); + } + + /** + * Get the RGB value for a given colorname. + * + * @param string $colorname The colorname + * + * @return array An array of RGB values. + */ + static public function getRGB($colorname) + { + require_once dirname(__FILE__) . '/Image/rgb.php'; + return isset($GLOBALS['horde_image_rgb_colors'][$colorname]) ? + $GLOBALS['horde_image_rgb_colors'][$colorname] : + array(0, 0, 0); + } + + /** + * Get the hex representation of the given colorname. + * + * @param string $colorname The colorname + * + * @return string The hex representation of the color. + */ + static public function getHexColor($colorname) + { + require_once dirname(__FILE__) . '/Image/rgb.php'; + if (isset($GLOBALS['horde_image_rgb_colors'][$colorname])) { + list($r, $g, $b) = $GLOBALS['horde_image_rgb_colors'][$colorname]; + return '#' . str_pad(dechex(min($r, 255)), 2, '0', STR_PAD_LEFT) . str_pad(dechex(min($g, 255)), 2, '0', STR_PAD_LEFT) . str_pad(dechex(min($b, 255)), 2, '0', STR_PAD_LEFT); + } else { + return 'black'; + } + } + + /** + * Draw a shaped point at the specified (x,y) point. Useful for + * scatter diagrams, debug points, etc. Draws squares, circles, + * diamonds, and triangles. + * + * @param integer $x The x coordinate of the point to brush. + * @param integer $y The y coordinate of the point to brush. + * @param string $color The color to brush the point with. + * @param string $shape What brush to use? Defaults to a square. + */ + public function brush($x, $y, $color = 'black', $shape = 'square') + { + switch ($shape) { + case 'triangle': + $verts[0] = array('x' => $x + 3, 'y' => $y + 3); + $verts[1] = array('x' => $x, 'y' => $y - 3); + $verts[2] = array('x' => $x - 3, 'y' => $y + 3); + $this->polygon($verts, $color, $color); + break; + + case 'circle': + $this->circle($x, $y, 3, $color, $color); + break; + + case 'diamond': + $verts[0] = array('x' => $x - 3, 'y' => $y); + $verts[1] = array('x' => $x, 'y' => $y + 3); + $verts[2] = array('x' => $x + 3, 'y' => $y); + $verts[3] = array('x' => $x, 'y' => $y - 3); + $this->polygon($verts, $color, $color); + break; + + case 'square': + default: + $this->rectangle($x - 2, $y - 2, 4, 4, $color, $color); + break; + } + } + + /** + * Add an observer to this image. The observer will be notified + * when the image's changes. + */ + public function addObserver($method, $object) + { + $this->_observers[] = array($method, $object); + } + + /** + * Let observers know that something happened worth acting on. + */ + public function notifyObservers() + { + for ($i = 0; $i < count($this->_observers); ++$i) { + $obj = $this->_observers[$i][1]; + $method = $this->_observers[$i][0]; + $obj->$method($this); + } + } + + /** + * Reset the image data to defaults. + */ + public function reset() + { + $this->_data = ''; + $this->_id = ''; + $this->_width = null; + $this->_height = null; + $this->_background = 'white'; + $this->_type = 'png'; + } + + /** + * Get the height and width of the current image data. + * + * @return array An hash with 'width' containing the width, + * 'height' containing the height of the image. + */ + public function getDimensions() + { + // Check if we know it already + if ($this->_width == 0 && $this->_height == 0) { + $tmp = $this->toFile(); + $details = @getimagesize($tmp); + list($this->_width, $this->_height) = $details; + unlink($tmp); + } + + return array('width' => $this->_width, + 'height' => $this->_height); + } + + /** + * Load the image data from a string. + * + * @param string $id An arbitrary id for the image. + * @param string $image_data The data to use for the image. + */ + public function loadString($id, $image_data) + { + if ($id != $this->_id) { + $this->reset(); + $this->_data = $image_data; + $this->_id = $id; + } + } + + /** + * Load the image data from a file. + * + * @param string $filename The full path and filename to the file to load + * the image data from. The filename will also be + * used for the image id. + * + * @return mixed True if successful or already loaded, PEAR Error if file + * does not exist or could not be loaded. + */ + public function loadFile($filename) + { + if ($filename != $this->_id) { + $this->reset(); + if (!file_exists($filename)) { + return PEAR::raiseError('The image file ' . $filename . ' does not exist.'); + } + if ($this->_data = file_get_contents($filename)) { + $this->_id = $filename; + } else { + return PEAR::raiseError('Could not load the image file ' . $filename); + } + } + + return true; + } + + /** + * Ouputs image data to file. If $data is false, outputs current + * image data after performing any pending operations on the data. + * If $data contains raw image data, outputs that data to file without + * regard for $this->_data + * + * @param mixed String of binary image data | false + * + * @return string Path to temporary file. + */ + public function toFile($data = false) + { + $tmp = Util::getTempFile('img', false, $this->_tmpdir); + $fp = @fopen($tmp, 'wb'); + fwrite($fp, $data ? $data : $this->raw()); + fclose($fp); + return $tmp; + } + + /** + * Display the current image. + */ + public function display() + { + $this->headers(); + echo $this->raw(); + } + + /** + * Returns the raw data for this image. + * + * @param boolean $convert If true, the image data will be returned in the + * target format, independently from any image + * operations. + * + * @return string The raw image data. + */ + public function raw($convert = false) + { + return $this->_data; + } + + // @TODO: I don't see why these need to be private/protected... + // probably can just make them static. Right now, I think + // only _arcPoints is used (in gd.php) + /** + * Get an x,y pair on circle, assuming center is 0,0. + * + * @access private + * + * @param double $degrees The degrees of arc to get the point for. + * @param integer $diameter The diameter of the circle. + * + * @return array (x coordinate, y coordinate) of the point. + */ + static protected function _circlePoint($degrees, $diameter) + { + // Avoid problems with doubles. + $degrees += 0.0001; + + return array(cos(deg2rad($degrees)) * ($diameter / 2), + sin(deg2rad($degrees)) * ($diameter / 2)); + } + + /** + * Get point coordinates at the limits of an arc. Only valid for + * angles ($end - $start) <= 45 degrees. + * + * @access private + * + * @param integer $r The radius of the arc. + * @param integer $start The starting angle. + * @param integer $end The ending angle. + * + * @return array The start point, end point, and anchor point. + */ + static protected function _arcPoints($r, $start, $end) + { + // Start point. + $pts['x1'] = $r * cos(deg2rad($start)); + $pts['y1'] = $r * sin(deg2rad($start)); + + // End point. + $pts['x2'] = $r * cos(deg2rad($end)); + $pts['y2'] = $r * sin(deg2rad($end)); + + // Anchor point. + $a3 = ($start + $end) / 2; + $r3 = $r / cos(deg2rad(($end - $start) / 2)); + $pts['x3'] = $r3 * cos(deg2rad($a3)); + $pts['y3'] = $r3 * sin(deg2rad($a3)); + + return $pts; + } + + + /** + * Attempts to apply requested effect to this image. If the + * effect cannot be found a PEAR_Error is returned. + * + * @param string $type The type of effect to apply. + * @param array $params Any parameters for the effect. + * + * @return mixed true on success | PEAR_Error on failure. + */ + public function addEffect($type, $params) + { + $class = str_replace('Horde_Image_', '', get_class($this)); + $effect = Horde_Image_Effect::factory($type, $class, $params); + if (is_a($effect, 'PEAR_Error')) { + return $effect; + } + $effect->setImageObject($this); + return $effect->apply(); + } + + /** + * Load a list of available effects for this driver. + */ + public function getLoadedEffects() + { + if (empty($this->_loadedEffects)) { + $class = str_replace('Horde_Image_', '', get_class($this)); + + // First, load the driver-agnostic Effects. + // TODO: This will need to be revisted when directory structure + // changes for Horde 4. + $path = dirname(__FILE__) . '/Image/Effect/'; + if (is_dir($path)) { + if ($handle = opendir($path)) { + while (($file = readdir($handle)) !== false) { + if (substr($file, -4, 4) == '.php') { + $this->_loadedEffects[] = substr($file, 0, strlen($file) - 4); + } + } + } + } + + // Driver specific effects. + $path = $path . $class; + if (is_dir($path)) { + if ($handle = opendir($path)) { + while (($file = readdir($handle)) !== false) { + if (substr($file, -4, 4) == '.php') { + $this->_loadedEffects[] = substr($file, 0, strlen($file) - 4); + } + } + } + } + } + + return $this->_loadedEffects; + } + + /** + * Apply any effects in the effect queue. + */ + public function applyEffects() + { + $this->raw(); + } + + /** + * Attempts to return a concrete Horde_Image instance based on $driver. + * + * @param mixed $driver The type of concrete Horde_Image subclass to + * return. This is based on the storage driver + * ($driver). The code is dynamically included. If + * $driver is an array, then we will look in + * $driver[0]/lib/Image/ for the subclass + * implementation named $driver[1].php. + * @param array $params A hash containing any additional configuration or + * connection parameters a subclass might need. + * + * @return mixed Horde_Image object | PEAR_Error + */ + static public function factory($driver, $params = array()) + { + if (is_array($driver)) { + list($app, $driver) = $driver; + } + + $driver = basename($driver); + $class = 'Horde_Image_' . $driver; + if (!class_exists($class)) { + if (!empty($app)) { + include_once $GLOBALS['registry']->get('fileroot', $app) . '/lib/Image/' . $driver . '.php'; + } else { + include_once 'Horde/Image/' . $driver . '.php'; + } + } + + if (!empty($params['context']) && count($params['context'])) { + $context = $params['context']; + unset($params['context']); + } else { + $context = array(); + } + if (class_exists($class)) { + $image = new $class($params, $context); + } else { + $image = PEAR::raiseError('Class definition of ' . $class . ' not found.'); + } + + return $image; + } + + public function getTmpDir() + { + return $this->_tmpdir; + } + + protected function _logDebug($message) + { + if (!empty($this->_logger)) { + $this->_logger->debug($message); + } + } + + protected function _logErr($message) + { + if (!empty($this->_logger)) { + $this->_logger->err($message); + } + } + +} \ No newline at end of file diff --git a/framework/Image/lib/Horde/Image/Effect.php b/framework/Image/lib/Horde/Image/Effect.php new file mode 100644 index 000000000..083da9d15 --- /dev/null +++ b/framework/Image/lib/Horde/Image/Effect.php @@ -0,0 +1,91 @@ + + * @author Michael J. Rubinsky + * @package Horde_Image + */ +class Horde_Image_Effect +{ + /** + * Effect parameters. + * + * @var array + */ + protected $_params = array(); + + /** + * The bound Horde_Image object + * + * @var Horde_Image + */ + protected $_image = null; + + /** + * Effect constructor. + * + * @param array $params Any parameters for the effect. Parameters are + * documented in each subclass. + */ + public function __construct($params = array()) + { + foreach ($params as $key => $val) { + $this->_params[$key] = $val; + } + } + + /** + * Bind this effect to a Horde_Image object. + * + * @param Horde_Image $image The Horde_Image object + * + * @TODO: Can we get rid of the reference here? (Looks OK for GD, but need + * to test im/imagick also). + * + * @return void + */ + public function setImageObject(&$image) + { + $this->_image = &$image; + } + + public function factory($type, $driver, $params) + { + if (is_array($type)) { + list($app, $type) = $type; + } + + // First check for a driver specific effect, if we can't find one, + // assume there is a vanilla effect object around. + $class = 'Horde_Image_Effect_' . $driver . '_' . $type; + $vclass = 'Horde_Image_Effect_' . $type; + if (!class_exists($class) && !class_exists($vclass)) { + if (!empty($app)) { + $path = $GLOBALS['registry']->get('fileroot', $app) . '/lib/Image/Effect/' . $driver . '/' . $type . '.php'; + } else { + $path = 'Horde/Image/Effect/' . $driver . '/' . $type . '.php'; + } + + @include_once $path; + if (!class_exists($class)) { + if (!empty($app)) { + $path = $GLOBALS['registry']->get('fileroot', $app) . '/lib/Image/Effect/' . $type . '.php'; + } else { + $path = 'Horde/Image/Effect/' . $type . '.php'; + } + $class = $vclass; + @include_once $path; + } + } + if (class_exists($class)) { + $effect = new $class($params); + } else { + $effect = PEAR::raiseError(sprintf("Horde_Image_Effect %s for %s driver not found.", $type, $driver)); + } + + return $effect; + } + +} \ No newline at end of file diff --git a/framework/Image/lib/Horde/Image/Effect/border.php b/framework/Image/lib/Horde/Image/Effect/border.php new file mode 100644 index 000000000..dbc91d11d --- /dev/null +++ b/framework/Image/lib/Horde/Image/Effect/border.php @@ -0,0 +1,53 @@ + + * @package Horde_Image + */ +class Horde_Image_Effect_border extends Horde_Image_Effect { + + /** + * Valid parameters for border decorators: + * + * padding - Pixels from the image edge that the border will start. + * borderColor - Border color. Defaults to black. + * fillColor - Color to fill the border with. Defaults to white. + * lineWidth - Border thickness, defaults to 1 pixel. + * roundWidth - Width of the corner rounding. Defaults to none. + * + * @var array + */ + var $_params = array('padding' => 0, + 'borderColor' => 'black', + 'fillColor' => 'white', + 'lineWidth' => 1, + 'roundWidth' => 0); + + /** + * Draw the border. + * + * This draws the configured border to the provided image. Beware, + * that every pixel inside the border clipping will be overwritten + * with the background color. + */ + function apply() + { + $o = $this->_params; + + $d = $this->_image->getDimensions(); + $x = $o['padding']; + $y = $o['padding']; + $width = $d['width'] - (2 * $o['padding']); + $height = $d['height'] - (2 * $o['padding']); + + if ($o['roundWidth'] > 0) { + $this->_image->roundedRectangle($x, $y, $width, $height, $o['roundWidth'], $o['borderColor'], $o['fillColor']); + } else { + $this->_image->rectangle($x, $y, $width, $height, $o['borderColor'], $o['fillColor']); + } + } + +} diff --git a/framework/Image/lib/Horde/Image/Effect/gd/drop_shadow.php b/framework/Image/lib/Horde/Image/Effect/gd/drop_shadow.php new file mode 100644 index 000000000..a6ae2875d --- /dev/null +++ b/framework/Image/lib/Horde/Image/Effect/gd/drop_shadow.php @@ -0,0 +1,124 @@ +. Modifications made to the code + * to fit it within the Horde framework and to adjust for our coding standards. + * + * @author Michael J. Rubinsky + * @package Horde_Image + */ +class Horde_Image_Effect_gd_drop_shadow extends Horde_Image_Effect +{ + /** + * Valid parameters: + * + * @TODO + * + * @var array + */ + protected $_params = array('distance' => 5, + 'width' => 2, + 'hexcolor' => '000000', + 'angle' => 215, + 'fade' => 10); + + /** + * Apply the drop_shadow effect. + * + * @return mixed true | PEAR_Error + */ + public function apply() + { + $distance = $this->_params['distance']; + $width = $this->_params['width']; + $hexcolor = $this->_params['hexcolor']; + $angle = $this->_params['angle']; + $fade = $this->_params['fade']; + + $width_shadow = cos(deg2rad($angle)) * ($distance + $width); + $height_shadow = sin(deg2rad($angle)) * ($distance + $width); + $gdimg = $this->_image->_im; + $imgX = $this->_image->call('imageSX', array($gdimg)); + $imgY = $this->_image->call('imageSY', array($gdimg)); + + $offset['x'] = cos(deg2rad($angle)) * ($distance + $width - 1); + $offset['y'] = sin(deg2rad($angle)) * ($distance + $width - 1); + + $tempImageWidth = $imgX + abs($offset['x']); + $tempImageHeight = $imgY + abs($offset['y']); + $gdimg_dropshadow_temp = $this->_image->create($tempImageWidth, + $tempImageHeight); + if (!is_a($gdimg_dropshadow_temp, 'PEAR_Error')) { + $this->_image->call('imageAlphaBlending', + array($gdimg_dropshadow_temp, false)); + + $this->_image->call('imageSaveAlpha', + array($gdimg_dropshadow_temp, true)); + + $transparent1 = $this->_image->call('imageColorAllocateAlpha', array($gdimg_dropshadow_temp, 0, 0, 0, 127)); + + if (is_a($transparent1, 'PEAR_Error')) { + return $transparent1; + } + + $this->_image->call('imageFill', + array($gdimg_dropshadow_temp, 0, 0, $transparent1)); + + for ($x = 0; $x < $imgX; $x++) { + for ($y = 0; $y < $imgY; $y++) { + $colorat = $this->_image->call('imageColorAt', array($gdimg, $x, $y)); + $PixelMap[$x][$y] = $this->_image->call('imageColorsForIndex', + array($gdimg, $colorat)); + } + } + + /* Creates the shadow */ + $r = hexdec(substr($hexcolor, 0, 2)); + $g = hexdec(substr($hexcolor, 2, 2)); + $b = hexdec(substr($hexcolor, 4, 2)); + + /* Essentially masks the original image and creates the shadow */ + for ($x = 0; $x < $tempImageWidth; $x++) { + for ($y = 0; $y < $tempImageHeight; $y++) { + if (!isset($PixelMap[$x][$y]['alpha']) || + ($PixelMap[$x][$y]['alpha'] > 0)) { + if (isset($PixelMap[$x + $offset['x']][$y + $offset['y']]['alpha']) && ($PixelMap[$x + $offset['x']][$y + $offset['y']]['alpha'] < 127)) { + $thisColor = $this->_image->call('imageColorAllocateAlpha', array($gdimg_dropshadow_temp, $r, $g, $b, $PixelMap[$x + $offset['x']][$y + $offset['y']]['alpha'])); + $this->_image->call('imageSetPixel', + array($gdimg_dropshadow_temp, $x, $y, $thisColor)); + } + } + } + } + /* Overlays the original image */ + $this->_image->call('imageAlphaBlending', + array($gdimg_dropshadow_temp, true)); + + for ($x = 0; $x < $imgX; $x++) { + for ($y = 0; $y < $imgY; $y++) { + if ($PixelMap[$x][$y]['alpha'] < 127) { + $thisColor = $this->_image->call('imageColorAllocateAlpha', array($gdimg_dropshadow_temp, $PixelMap[$x][$y]['red'], $PixelMap[$x][$y]['green'], $PixelMap[$x][$y]['blue'], $PixelMap[$x][$y]['alpha'])); + $this->_image->call('imageSetPixel', + array($gdimg_dropshadow_temp, $x, $y, $thisColor)); + } + } + } + + $this->_image->call('imageSaveAlpha', + array($gdimg, true)); + $this->_image->call('imageAlphaBlending', + array($gdimg, false)); + + // Merge the shadow and the original into the original. + $this->_image->call('imageCopyResampled', + array($gdimg, $gdimg_dropshadow_temp, 0, 0, 0, 0, $imgX, $imgY, $this->_image->call('imageSX', array($gdimg_dropshadow_temp)), $this->_image->call('imageSY', array($gdimg_dropshadow_temp)))); + + $this->_image->call('imageDestroy', array($gdimg_dropshadow_temp)); + } + return true; + } + +} \ No newline at end of file diff --git a/framework/Image/lib/Horde/Image/Effect/gd/round_corners.php b/framework/Image/lib/Horde/Image/Effect/gd/round_corners.php new file mode 100644 index 000000000..37f785f76 --- /dev/null +++ b/framework/Image/lib/Horde/Image/Effect/gd/round_corners.php @@ -0,0 +1,135 @@ +. Modifications + * made to the code to fit it within the Horde framework and to adjust for our + * coding standards. + * + * @author Michael J. Rubinsky + * @package Horde_Image + */ +class Horde_Image_Effect_gd_round_corners extends Horde_Image_Effect +{ + /** + * Valid parameters: + * + * radius - Radius of rounded corners. + * + * @var array + */ + protected $_params = array('radius' => 10); + + /** + * Apply the round_corners effect. + * + * @return mixed true | PEAR_Error + */ + public function apply() + { + // Original comments from phpThumb projet: + // generate mask at twice desired resolution and downsample afterwards + // for easy antialiasing mask is generated as a white double-size + // elipse on a triple-size black background and copy-paste-resampled + // onto a correct-size mask image as 4 corners due to errors when the + // entire mask is resampled at once (gray edges) + $radius_x = $radius_y = $this->_params['radius']; + $gdimg = $this->_image->_im; + $imgX = round($this->_image->call('imageSX', array($gdimg))); + $imgY = round($this->_image->call('imageSY', array($gdimg))); + + $gdimg_cornermask_triple = $this->_image->create(round($radius_x * 6), + round($radius_y * 6)); + if (!is_a($gdimg_cornermask_triple, 'PEAR_Error')) { + + $gdimg_cornermask = $this->_image->create($imgX, $imgY); + if (!is_a($gdimg_cornermask, 'PEAR_Error')) { + $color_transparent = $this->_image->call('imageColorAllocate', + array($gdimg_cornermask_triple, + 255, + 255, + 255)); + + $this->_image->call('imageFilledEllipse', + array($gdimg_cornermask_triple, + $radius_x * 3, + $radius_y * 3, + $radius_x * 4, + $radius_y * 4, + $color_transparent)); + + $this->_image->call('imageFilledRectangle', + array($gdimg_cornermask, + 0, + 0, + $imgX, + $imgY, + $color_transparent)); + + $this->_image->call('imageCopyResampled', + array($gdimg_cornermask, + $gdimg_cornermask_triple, + 0, + 0, + $radius_x, + $radius_y, + $radius_x, + $radius_y, + $radius_x * 2, + $radius_y * 2)); + + $this->_image->call('imageCopyResampled', + array($gdimg_cornermask, + $gdimg_cornermask_triple, + 0, + $imgY - $radius_y, + $radius_x, + $radius_y * 3, + $radius_x, + $radius_y, + $radius_x * 2, + $radius_y * 2)); + + $this->_image->call('imageCopyResampled', + array($gdimg_cornermask, + $gdimg_cornermask_triple, + $imgX - $radius_x, + $imgY - $radius_y, + $radius_x * 3, + $radius_y * 3, + $radius_x, + $radius_y, + $radius_x * 2, + $radius_y * 2)); + + $this->_image->call('imageCopyResampled', + array($gdimg_cornermask, + $gdimg_cornermask_triple, + $imgX - $radius_x, + 0, + $radius_x * 3, + $radius_y, + $radius_x, + $radius_y, + $radius_x * 2, + $radius_y * 2)); + + $result = $this->_image->_applyMask($gdimg_cornermask); + if (is_a($result, 'PEAR_Error')) { + return $result; + } + $this->_image->call('imageDestroy', array($gdimg_cornermask)); + return true; + } else { + return $gdimg_cornermas; // PEAR_Error + } + $this->_image->call('imageDestroy', + array($gdimg_cornermask_triple)); + } else { + return $gdimg_cornermas_triple; // PEAR_Error + } + } + +} \ No newline at end of file diff --git a/framework/Image/lib/Horde/Image/Effect/gd/text_watermark.php b/framework/Image/lib/Horde/Image/Effect/gd/text_watermark.php new file mode 100644 index 000000000..6fcde437c --- /dev/null +++ b/framework/Image/lib/Horde/Image/Effect/gd/text_watermark.php @@ -0,0 +1,122 @@ + + * @package Horde_Image + */ +class Horde_Image_Effect_gd_text_watermark extends Horde_Image_Effect +{ + /** + * Valid parameters for watermark effects: + * + * text (required) - The text of the watermark. + * halign - The horizontal placement + * valign - The vertical placement + * font - The font name or family to use + * fontsize - The size of the font to use + * (small, medium, large, giant) + * + * @var array + */ + protected $_params = array('halign' => 'right', + 'valign' => 'bottom', + 'font' => 'courier', + 'fontsize' => 'small'); + /** + * Add the watermark + */ + public function apply() + { + $color = $this->_image->call('imageColorClosest', + array($this->_image->_im, 255, 255, 255)); + if (is_a($color, 'PEAR_Error')) { + return $color; + } + $shadow = $this->_image->call('imageColorClosest', + array($this->_image->_im, 0, 0, 0)); + if (is_a($shadow, 'PEAR_Error')) { + return $shadow; + } + + // Shadow offset in pixels. + $drop = 1; + + // Maximum text width. + $maxwidth = 200; + + // Amount of space to leave between the text and the image border. + $padding = 10; + + $f = $this->_image->getFont($this->_params['fontsize']); + $fontwidth = $this->_image->call('imageFontWidth', array($f)); + if (is_a($fontwidth, 'PEAR_Error')) { + return $fontwidth; + } + $fontheight = $this->_image->call('imageFontHeight', array($f)); + if (is_a($fontheight, 'PEAR_Error')) { + return $fontheight; + } + + // So that shadow is not off the image with right align and bottom valign. + $margin = floor($padding + $drop) / 2; + if ($maxwidth) { + $maxcharsperline = floor(($maxwidth - ($margin * 2)) / $fontwidth); + $text = wordwrap($this->_params['text'], $maxcharsperline, "\n", 1); + } + + // Split $text into individual lines. + $lines = explode("\n", $text); + + switch ($this->_params['valign']) { + case 'center': + $y = ($this->_image->call('imageSY', array($this->_image->_im)) - ($fontheight * count($lines))) / 2; + break; + + case 'bottom': + $y = $this->_image->call('imageSY', array($this->_image->_im)) - (($fontheight * count($lines)) + $margin); + break; + + default: + $y = $margin; + break; + } + + switch ($this->_params['halign']) { + case 'right': + foreach ($lines as $line) { + if (is_a($result = $this->_image->call('imageString', array($this->_image->_im, $f, ($this->_image->call('imageSX', array($this->_image->_im)) - $fontwidth * strlen($line)) - $margin + $drop, ($y + $drop), $line, $shadow)), 'PEAR_Error')) { + return $result; + } + $result = $this->_image->call('imageString', array($this->_image->_im, $f, ($this->_image->call('imageSX', array($this->_image->_im)) - $fontwidth * strlen($line)) - $margin, $y, $line, $color)); + $y += $fontheight; + } + break; + + case 'center': + foreach ($lines as $line) { + if (is_a($result = $this->_image->call('imageString', array($this->_image->_im, $f, floor(($this->_image->call('imageSX', array($this->_image->_im)) - $fontwidth * strlen($line)) / 2) + $drop, ($y + $drop), $line, $shadow)), 'PEAR_Error')) { + return $result; + } + $result = $this->_image->call('imageString', array($this->_image->_im, $f, floor(($this->_image->call('imageSX', array($this->_image->_im)) - $fontwidth * strlen($line)) / 2), $y, $line, $color)); + $y += $fontheight; + } + break; + + default: + foreach ($lines as $line) { + if (is_a($result = $this->_image->call('imageString', array($this->_image->_im, $f, $margin + $drop, ($y + $drop), $line, $shadow)), 'PEAR_Error')) { + return $result; + } + $result = $this->_image->call('imageString', array($this->_image->_im, $f, $margin, $y, $line, $color)); + $y += $fontheight; + } + break; + } + + if (is_a($result, 'PEAR_Error')) { + return $result; + } + } + +} \ No newline at end of file diff --git a/framework/Image/lib/Horde/Image/Effect/gd/unsharp_mask.php b/framework/Image/lib/Horde/Image/Effect/gd/unsharp_mask.php new file mode 100644 index 000000000..3282c5f55 --- /dev/null +++ b/framework/Image/lib/Horde/Image/Effect/gd/unsharp_mask.php @@ -0,0 +1,134 @@ + + * From: http://www.vikjavev.com/hovudsida/umtestside.php + * + * @package Horde_Image + */ +class Horde_Image_Effect_gd_unsharp_mask extends Horde_Image_Effect +{ + /** + * Valid parameters: + * + * @TODO + * + * @var array + */ + protected $_params = array('amount' => 0, + 'radius' => 0, + 'threshold' => 0); + + /** + * Apply the unsharp_mask effect. + * + * @return mixed true | PEAR_Error + */ + public function apply() + { + $amount = $this->_params['amount']; + $radius = $this->_params['radius']; + $threshold = $this->_params['threshold']; + + // Attempt to calibrate the parameters to Photoshop: + $amount = min($amount, 500); + $amount = $amount * 0.016; + if ($amount == 0) { + return true; + } + + $radius = min($radius, 50); + $radius = $radius * 2; + + $threshold = min($threshold, 255); + + $radius = abs(round($radius)); // Only integers make sense. + if ($radius == 0) { + return true; + } + + $img = $this->_image->_im; + $w = ImageSX($img); + $h = ImageSY($img); + $imgCanvas = ImageCreateTrueColor($w, $h); + $imgCanvas2 = ImageCreateTrueColor($w, $h); + $imgBlur = ImageCreateTrueColor($w, $h); + $imgBlur2 = ImageCreateTrueColor($w, $h); + ImageCopy($imgCanvas, $img, 0, 0, 0, 0, $w, $h); + ImageCopy($imgCanvas2, $img, 0, 0, 0, 0, $w, $h); + + // Gaussian blur matrix: + // + // 1 2 1 + // 2 4 2 + // 1 2 1 + // + ////////////////////////////////////////////////// + + // Move copies of the image around one pixel at the time and merge them with weight + // according to the matrix. The same matrix is simply repeated for higher radii. + for ($i = 0; $i < $radius; $i++) { + ImageCopy ($imgBlur, $imgCanvas, 0, 0, 1, 1, $w - 1, $h - 1); // up left + ImageCopyMerge($imgBlur, $imgCanvas, 1, 1, 0, 0, $w, $h, 50); // down right + ImageCopyMerge($imgBlur, $imgCanvas, 0, 1, 1, 0, $w - 1, $h, 33.33333); // down left + ImageCopyMerge($imgBlur, $imgCanvas, 1, 0, 0, 1, $w, $h - 1, 25); // up right + ImageCopyMerge($imgBlur, $imgCanvas, 0, 0, 1, 0, $w - 1, $h, 33.33333); // left + ImageCopyMerge($imgBlur, $imgCanvas, 1, 0, 0, 0, $w, $h, 25); // right + ImageCopyMerge($imgBlur, $imgCanvas, 0, 0, 0, 1, $w, $h - 1, 20 ); // up + ImageCopyMerge($imgBlur, $imgCanvas, 0, 1, 0, 0, $w, $h, 16.666667); // down + ImageCopyMerge($imgBlur, $imgCanvas, 0, 0, 0, 0, $w, $h, 50); // center + ImageCopy ($imgCanvas, $imgBlur, 0, 0, 0, 0, $w, $h); + + // During the loop above the blurred copy darkens, possibly due to a roundoff + // error. Therefore the sharp picture has to go through the same loop to + // produce a similar image for comparison. This is not a good thing, as processing + // time increases heavily. + ImageCopy ($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h); + ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 50); + ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 33.33333); + ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 25); + ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 33.33333); + ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 25); + ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 20 ); + ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 16.666667); + ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 50); + ImageCopy ($imgCanvas2, $imgBlur2, 0, 0, 0, 0, $w, $h); + } + + // Calculate the difference between the blurred pixels and the original + // and set the pixels + for ($x = 0; $x < $w; $x++) { // each row + for ($y = 0; $y < $h; $y++) { // each pixel + + $rgbOrig = ImageColorAt($imgCanvas2, $x, $y); + $rOrig = (($rgbOrig >> 16) & 0xFF); + $gOrig = (($rgbOrig >> 8) & 0xFF); + $bOrig = ($rgbOrig & 0xFF); + + $rgbBlur = ImageColorAt($imgCanvas, $x, $y); + $rBlur = (($rgbBlur >> 16) & 0xFF); + $gBlur = (($rgbBlur >> 8) & 0xFF); + $bBlur = ($rgbBlur & 0xFF); + + // When the masked pixels differ less from the original + // than the threshold specifies, they are set to their original value. + $rNew = (abs($rOrig - $rBlur) >= $threshold) ? max(0, min(255, ($amount * ($rOrig - $rBlur)) + $rOrig)) : $rOrig; + $gNew = (abs($gOrig - $gBlur) >= $threshold) ? max(0, min(255, ($amount * ($gOrig - $gBlur)) + $gOrig)) : $gOrig; + $bNew = (abs($bOrig - $bBlur) >= $threshold) ? max(0, min(255, ($amount * ($bOrig - $bBlur)) + $bOrig)) : $bOrig; + + if (($rOrig != $rNew) || ($gOrig != $gNew) || ($bOrig != $bNew)) { + $pixCol = ImageColorAllocate($img, $rNew, $gNew, $bNew); + ImageSetPixel($img, $x, $y, $pixCol); + } + } + } + ImageDestroy($imgCanvas); + ImageDestroy($imgCanvas2); + ImageDestroy($imgBlur); + ImageDestroy($imgBlur2); + + return true; + } + +} \ No newline at end of file diff --git a/framework/Image/lib/Horde/Image/Effect/im/border.php b/framework/Image/lib/Horde/Image/Effect/im/border.php new file mode 100755 index 000000000..15e1baf2a --- /dev/null +++ b/framework/Image/lib/Horde/Image/Effect/im/border.php @@ -0,0 +1,48 @@ + + * @package Horde_Image + */ +class Horde_Image_Effect_im_border extends Horde_Image_Effect +{ + /** + * Valid parameters for border effects: + * + * bordercolor - Border color. Defaults to black. + * borderwidth - Border thickness, defaults to 1 pixel. + * preserve - Preserves the alpha transparency layer (if present) + * + * @var array + */ + protected $_params = array('bordercolor' => 'black', + 'borderwidth' => 1, + 'preserve' => true); + + /** + * Draw the border. + * + * This draws the configured border to the provided image. Beware, + * that every pixel inside the border clipping will be overwritten + * with the background color. + */ + public function apply() + { + if (!is_null($this->_image->_imagick)) { + $this->_image->_imagick->borderImage( + $this->_params['bordercolor'], + $this->_params['borderwidth'], + $this->_params['borderwidth']); + } else { + $this->_image->addPostSrcOperation(sprintf( + " -bordercolor \"%s\" %s -border %s", + $this->_params['bordercolor'], + (!empty($this->_params['preserve']) ? '-compose Copy' : ''), + $this->_params['borderwidth'])); + } + + return true; + } + +} \ No newline at end of file diff --git a/framework/Image/lib/Horde/Image/Effect/im/composite.php b/framework/Image/lib/Horde/Image/Effect/im/composite.php new file mode 100755 index 000000000..c44f5f1f3 --- /dev/null +++ b/framework/Image/lib/Horde/Image/Effect/im/composite.php @@ -0,0 +1,83 @@ + + * @package Horde_Image + */ +class Horde_Image_Effect_im_composite extends Horde_Image_Effect +{ + /** + * Valid parameters for border effects: + * + * 'images' - an array of Horde_Image objects to overlay. + * + * ...and ONE of the following. If both are provided, the behaviour is + * undefined. + * + * 'gravity' - the ImageMagick gravity constant describing placement + * (IM driver only so far, not imagick) + * + * 'x' and 'y' - coordinates for the overlay placement. + * + * @var array + */ + protected $_params = array(); + + /** + * Draw the border. + * + * This draws the configured border to the provided image. Beware, + * that every pixel inside the border clipping will be overwritten + * with the background color. + */ + public function apply() + { + $this->_image->_imagick = null; + if (!is_null($this->_image->_imagick)) { + foreach ($this->_params['images'] as $image) { + $topimg = new Horde_Image_ImagickProxy(); + $topimg->clear(); + $topimg->readImageBlob($image->raw()); + + /* Calculate center for composite (gravity center)*/ + $geometry = $this->_image->_imagick->getImageGeometry(); + $x = $geometry['width'] / 2; + $y = $geometry['height'] / 2; + + if (isset($this->_params['x']) && isset($this->_params['y'])) { + $x = $this->_params['x']; + $y = $this->_params['y']; + } + $this->_image->_imagick->compositeImage($topimg, constant('Imagick::COMPOSITE_OVER'), $x, $y); + } + } else { + $ops = $geometry = $gravity = ''; + if (isset($this->_params['gravity'])) { + $gravity = ' -gravity ' . $this->_params['gravity']; + } + + if (isset($this->_params['x']) && isset($this->_params['y'])) { + $geometry = ' -geometry +' . $this->_params['x'] . '+' . $this->_params['y'] . ' '; + } + if (isset($this->_params['compose'])) { + // The -matte ensures that the destination (background) image + // has an alpha channel - to avoid black holes in the image. + $compose = ' -compose ' . $this->_params['compose'] . ' -matte'; + } + + foreach($this->_params['images'] as $image) { + $temp = $image->toFile(); + $this->_image->addFileToClean($temp); + $ops .= ' ' . $temp . $gravity . $compose . ' -composite'; + } + $this->_image->addOperation($geometry); + $this->_image->addPostSrcOperation($ops); + } + return true; + } + +} \ No newline at end of file diff --git a/framework/Image/lib/Horde/Image/Effect/im/drop_shadow.php b/framework/Image/lib/Horde/Image/Effect/im/drop_shadow.php new file mode 100644 index 000000000..500d8259e --- /dev/null +++ b/framework/Image/lib/Horde/Image/Effect/im/drop_shadow.php @@ -0,0 +1,84 @@ + + * @package Horde_Image + */ +class Horde_Image_Effect_im_drop_shadow extends Horde_Image_Effect +{ + /** + * Valid parameters: Most are currently ignored for the im version + * of this effect. + * + * @TODO + * + * @var array + */ + protected $_params = array('distance' => 5, // This is used as the x and y offset + 'width' => 2, + 'hexcolor' => '000000', + 'angle' => 215, + 'fade' => 3, // Sigma value + 'padding' => 0, + 'background' => 'none'); + + /** + * Apply the effect. + * + * @return mixed true | PEAR_Error + */ + public function apply() + { + if (!is_null($this->_image->_imagick)) { + // $shadow is_a ImagickProxy object + $shadow = $this->_image->_imagick->cloneIM(); + $shadow->setImageBackgroundColor('black'); + $shadow->shadowImage(80, $this->_params['fade'], + $this->_params['distance'], + $this->_params['distance']); + + + // If we have an actual background color, we need to explicitly + // create a new background image with that color to be sure there + // *is* a background color. + if ($this->_params['background'] != 'none') { + $size = $shadow->getImageGeometry(); + $new = new Horde_Image_ImagickProxy($size['width'], + $size['height'], + $this->_params['background'], + $this->_image->getType()); + + $new->compositeImage($shadow, + constant('Imagick::COMPOSITE_OVER'), 0, 0); + $shadow->clear(); + $shadow->addImage($new); + $new->destroy(); + } + + if ($this->_params['padding']) { + $shadow->borderImage($this->_params['background'], + $this->_params['padding'], + $this->_params['padding']); + } + $shadow->compositeImage($this->_image->_imagick, + constant('Imagick::COMPOSITE_OVER'), + 0, 0); + $this->_image->_imagick->clear(); + $this->_image->_imagick->addImage($shadow); + $shadow->destroy(); + } else { + $size = $this->_image->getDimensions(); +// $this->_image->addPostSrcOperation("-size {$size['width']}x{$size['height']} xc:{$this->_params['background']} " +// . "-fill {$this->_params['background']} -draw \"matte 0,0 reset\""); + $this->_image->addPostSrcOperation('\( +clone -background black -shadow 80x' . $this->_params['fade'] . '+' . $this->_params['distance'] . '+' . $this->_params['distance'] . ' \) +swap -background none -flatten +repage -bordercolor ' . $this->_params['background'] . ' -border ' . $this->_params['padding']); + } + $this->_image->_width = 0; + $this->_image->_height = 0; + + return true; + } + +} \ No newline at end of file diff --git a/framework/Image/lib/Horde/Image/Effect/im/photo_stack.php b/framework/Image/lib/Horde/Image/Effect/im/photo_stack.php new file mode 100644 index 000000000..0160635d5 --- /dev/null +++ b/framework/Image/lib/Horde/Image/Effect/im/photo_stack.php @@ -0,0 +1,328 @@ + + * @package Horde_Image + */ +class Horde_Image_Effect_im_photo_stack extends Horde_Image_Effect +{ + /** + * Valid parameters for the stack effect + * + * images - An array of Horde_Image objects to stack. Images + * are stacked in a FIFO manner, so that the top-most + * image is the last one in this array. + * + * type - Determines the style for the composition. + * 'plain' or 'polaroid' are supported. + * + * resize_height - The height that each individual thumbnail + * should be resized to before composing on the image. + * + * padding - How much padding should we ensure is left around + * the active image area? + * + * background - The background canvas color - this is used as the + * color to set any padding to. + * + * bordercolor - If using type 'plain' this sets the color of the + * border that each individual thumbnail gets. + * + * borderwidth - If using type 'plain' this sets the width of the + * border on each individual thumbnail. + * + * offset - If using type 'plain' this determines the amount of + * x and y offset to give each successive image when + * it is placed on the top of the stack. + * + * @var array + */ + protected $_params = array('type' => 'plain', + 'resize_height' => '150', + 'padding' => 0, + 'background' => 'none', + 'bordercolor' => '#333', + 'borderwidth' => 1, + 'borderrounding' => 10, + 'offset' => 5); + + /** + * Create the photo_stack + * + */ + public function apply() + { + $i = 1; + $cnt = count($this->_params['images']); + if ($cnt <=0) { + return PEAR::raiseError('No images provided'); + } + if (!is_null($this->_image->_imagick) && + $this->_image->_imagick->methodExists('polaroidImage') && + $this->_image->_imagick->methodExists('trimImage')) { + + $imgs = array(); + $length = 0; + + switch ($this->_params['type']) { + case 'plain': + case 'rounded': + $haveBottom = false; + // First, we need to resize the top image to get the dimensions + // for the rest of the stack. + $topimg = new Horde_Image_ImagickProxy(); + $topimg->clear(); + $topimg->readImageBlob($this->_params['images'][$cnt - 1]->raw()); + $topimg->thumbnailImage( + $this->_params['resize_height'], + $this->_params['resize_height'], + true); + if ($this->_params['type'] == 'rounded') { + $topimg = $this->_roundBorder($topimg); + } + + $size = $topimg->getImageGeometry(); + foreach ($this->_params['images'] as $image) { + $imgk= new Horde_Image_ImagickProxy(); + $imgk->clear(); + $imgk->readImageBlob($image->raw()); + if ($i++ <= $cnt) { + $imgk->thumbnailImage($size['width'], $size['height'], + false); + } else { + $imgk->destroy(); + $imgk = $topimg->cloneIM(); + } + + if ($this->_params['type'] == 'rounded') { + $imgk = $this->_roundBorder($imgk); + } else { + $imgk->borderImage($this->_params['bordercolor'], 1, 1); + } + // Only shadow the bottom image for 'plain' stacks + if (!$haveBottom) { + $shad = $imgk->cloneIM(); + $shad->setImageBackgroundColor('black'); + $shad->shadowImage(80, 4, 0, 0); + $shad->compositeImage($imgk, + constant('Imagick::COMPOSITE_OVER'), + 0, 0); + $imgk->clear(); + $imgk->addImage($shad); + $shad->destroy(); + $haveBottom = true; + } + // Get the geometry of the image and remember the largest. + $geo = $imgk->getImageGeometry(); + $length = max( + $length, + sqrt(pow($geo['height'], 2) + pow($geo['width'], 2))); + + $imgs[] = $imgk; + } + break; + case 'polaroid': + foreach ($this->_params['images'] as $image) { + $imgk= new Horde_Image_ImagickProxy(); + $imgk->clear(); + $imgk->readImageBlob($image->raw()); + $imgk->thumbnailImage($this->_params['resize_height'], + $this->_params['resize_height'], + true); + $imgk->setImageBackgroundColor('black'); + if ($i++ == $cnt) { + $angle = 0; + } else { + $angle = mt_rand(1, 45); + if (mt_rand(1, 2) % 2 === 0) { + $angle = $angle * -1; + } + } + $result = $imgk->polaroidImage($angle); + if (is_a($result, 'PEAR_Error')) { + return $result; + } + // Get the geometry of the image and remember the largest. + $geo = $imgk->getImageGeometry(); + $length = max( + $length, + sqrt(pow($geo['height'], 2) + pow($geo['width'], 2))); + + $imgs[] = $imgk; + } + break; + } + + // Make sure the background canvas is large enough to hold it all. + $this->_image->_imagick->thumbnailImage($length * 1.5 + 20, + $length * 1.5 + 20); + + // x and y offsets. + $xo = $yo = (count($imgs) + 1) * $this->_params['offset']; + foreach ($imgs as $image) { + if ($this->_params['type'] == 'polaroid') { + $xo = mt_rand(1, $this->_params['resize_height'] / 2); + $yo = mt_rand(1, $this->_params['resize_height'] / 2); + } elseif ($this->_params['type'] == 'plain' || + $this->_params['type'] == 'rounded') { + $xo -= $this->_params['offset']; + $yo -= $this->_params['offset']; + } + + $this->_image->_imagick->compositeImage( + $image, constant('Imagick::COMPOSITE_OVER'), $xo, $yo); + $image->removeImage(); + $image->destroy(); + } + // If we have a background other than 'none' we need to + // compose two images together to make sure we *have* a background. + if ($this->_params['background'] != 'none') { + $size = $this->_image->getDimensions(); + $new = new Horde_Image_ImagickProxy($length * 1.5 + 20, + $length * 1.5 + 20, + $this->_params['background'], + $this->_image->getType()); + + + + $new->compositeImage($this->_image->_imagick, + constant('Imagick::COMPOSITE_OVER'), 0, 0); + $this->_image->_imagick->clear(); + $this->_image->_imagick->addImage($new); + $new->destroy(); + } + // Trim the canvas before resizing to keep the thumbnails as large + // as possible. + $this->_image->_imagick->trimImage(0); + if ($this->_params['padding']) { + $this->_image->_imagick->borderImage($this->_params['background'], + $this->_params['padding'], + $this->_params['padding']); + } + + } else { + // No Imagick installed - use im, but make sure we don't mix imagick + // and convert. + $this->_image->_imagick = null; + $this->_image->raw(); + + switch ($this->_params['type']) { + case 'plain': + case 'rounded': + // Get top image dimensions, then force each bottom image to the + // same dimensions. + $this->_params['images'][$cnt - 1]->resize($this->_params['resize_height'], + $this->_params['resize_height'], + true); + $size = $this->_params['images'][$cnt - 1]->getDimensions(); + //$this->_image->resize(2 * $this->_params['resize_height'], 2 * $this->_params['resize_height']); + for ($i = 0; $i < $cnt; $i++) { + $this->_params['images'][$i]->resize($size['height'], $size['width'], false); + } + $xo = $yo = (count($this->_params['images']) + 1) * $this->_params['offset']; + $ops = ''; + $haveBottom = false; + foreach ($this->_params['images'] as $image) { + $xo -= $this->_params['offset']; + $yo -= $this->_params['offset']; + + if ($this->_params['type'] == 'rounded') { + $temp = $this->_roundBorder($image); + } else { + $temp = $image->toFile(); + } + $this->_image->addFileToClean($temp); + $ops .= ' \( ' . $temp . ' -background none -thumbnail ' . $size['width'] . 'x' . $size['height'] . '! -repage +' . $xo . '+' . $yo . ($this->_params['type'] == 'plain' ? ' -bordercolor "#333" -border 1 ' : ' ' ) . ((!$haveBottom) ? '\( +clone -shadow 80x4+0+0 \) +swap -mosaic' : '') . ' \) '; + $haveBottom = true; + } + + // The first -background none option below is only honored in + // convert versions before 6.4 it seems. Without it specified as + // none here, all stacks come out with a white background. + $this->_image->addPostSrcOperation($ops . ' -background ' . $this->_params['background'] . ' -mosaic -bordercolor ' . $this->_params['background'] . ' -border ' . $this->_params['padding']); + + break; + + case 'polaroid': + // Check for im version > 6.3.2 + $ver = $this->_image->getIMVersion(); + if (is_array($ver) && version_compare($ver[0], '6.3.2') >= 0) { + $ops = ''; + foreach ($this->_params['images'] as $image) { + $temp = $image->toFile(); + // Remember the temp files so we can nuke them later. + $this->_image->addFileToClean($temp); + + // Don't rotate the top image. + if ($i++ == $cnt) { + $angle = 0; + } else { + $angle = mt_rand(1, 45); + if (mt_rand(1, 2) % 2 === 0) { + $angle = $angle * -1; + } + } + $ops .= ' \( ' . $temp . ' -geometry +' . mt_rand(1, $this->_params['resize_height']) . '+' . mt_rand(1, $this->_params['resize_height']) . ' -thumbnail \'' . $this->_params['resize_height'] . 'x' . $this->_params['resize_height'] . '>\' -bordercolor Snow -border 1 -polaroid ' . $angle . ' \) '; + } + $this->_image->addPostSrcOperation('-background none' . $ops . '-mosaic -bordercolor ' . $this->_params['background'] . ' -border ' . $this->_params['padding']); + } else { + // An attempt at a -polaroid command free version of this + // effect based on various examples and ideas at + // http://imagemagick.org + $ops = ''; + foreach ($this->_params['images'] as $image) { + $temp = $image->toFile(); + $this->_image->addFileToClean($temp); + if ($i++ == $cnt) { + $angle = 0; + } else { + $angle = mt_rand(1, 45); + if (mt_rand(1, 2) % 2 === 0) { + $angle = $angle * -1; + } + } + $ops .= '\( ' . $temp . ' -thumbnail \'' . $this->_params['resize_height'] . 'x' . $this->_params['resize_height']. '>\' -bordercolor "#eee" -border 4 -bordercolor grey90 -border 1 -bordercolor none -background none -rotate ' . $angle . ' -background none \( +clone -shadow 60x4+4+4 \) +swap -background none -flatten \) '; + } + $this->_image->addPostSrcOperation('-background none ' . $ops . '-mosaic -trim +repage -bordercolor ' . $this->_params['background'] . ' -border ' . $this->_params['padding']); + } + break; + } + } + + return true; + } + + private function _roundBorder($image) + { + $context = array('tmpdir' => $this->_image->getTmpDir(), + 'convert' => $this->_image->getConvertPath()); + if (!is_null($this->_image->_imagick)) { + $size = $image->getImageGeometry(); + $new = Horde_Image::factory('im', array('context' => $context)); + $new->loadString('somestring', $image->getImageBlob()); + $image->destroy(); + $new->addEffect('round_corners', array('border' => 2, 'bordercolor' => '#111')); + $new->applyEffects(); + $return = new Horde_Image_ImagickProxy($size['width'] + $this->_params['borderwidth'], + $size['height'] + $this->_params['borderwidth'], + $this->_params['bordercolor'], + $this->_image->getType()); + $return->clear(); + $return->readImageBlob($new->raw()); + return $return; + } else { + $size = $image->getDimensions(); + $new = Horde_Image::factory('im', array('data' => $image->raw(), 'context' => $context)); + $new->addEffect('round_corners', array('border' => 2, 'bordercolor' => '#111', 'background' => 'none')); + $new->applyEffects(); + return $new->toFile(); + } + } + +} \ No newline at end of file diff --git a/framework/Image/lib/Horde/Image/Effect/im/polaroid_image.php b/framework/Image/lib/Horde/Image/Effect/im/polaroid_image.php new file mode 100755 index 000000000..b46bec5a1 --- /dev/null +++ b/framework/Image/lib/Horde/Image/Effect/im/polaroid_image.php @@ -0,0 +1,86 @@ + + * @package Horde_Image + */ +class Horde_Image_Effect_im_polaroid_image extends Horde_Image_Effect +{ + /** + * Valid parameters for the polaroid effect + * + * resize_height - The height that each individual thumbnail + * should be resized to before composing on the image. + * + * background - The color of the image background. + * + * angle - Angle to rotate the image. + * + * shadowcolor - The color of the image shadow. + */ + + /** + * @var array + */ + protected $_params = array('background' => 'none', + 'angle' => 0, + 'shadowcolor' => 'black'); + + /** + * Create the effect + * + */ + public function apply() + { + if (!is_null($this->_image->_imagick) && + $this->_image->_imagick->methodExists('polaroidImage') && + $this->_image->_imagick->methodExists('trimImage')) { + + // This determines the color of the underlying shadow. + $this->_image->_imagick->setImageBackgroundColor($this->_params['shadowcolor']); + + $result = $this->_image->_imagick->polaroidImage($this->_params['angle']); + if (is_a($result, 'PEAR_Error')) { + return $result; + } + + // We need to create a new image to composite the polaroid over. + // (yes, even if it's a transparent background evidently) + $size = $this->_image->getDimensions(); + $imk = new Horde_Image_ImagickProxy($size['width'], + $size['height'], + $this->_params['background'], + $this->_image->getType()); + + $result = $imk->compositeImage($this->_image->_imagick, + constant('Imagick::COMPOSITE_OVER'), + 0, 0); + if (is_a($result, 'PEAR_Error')) { + return $result; + } + $this->_image->_imagick->clear(); + $this->_image->_imagick->addImage($imk); + $imk->destroy(); + + } else { + + // Check for im version > 6.3.2 + $this->_image->_imagick = null; + $ver = $this->_image->getIMVersion(); + if (is_array($ver) && version_compare($ver[0], '6.3.2') >= 0) { + $this->_image->addPostSrcOperation(sprintf("-bordercolor \"#eee\" -background none -polaroid %s \( +clone -fill %s -draw 'color 0,0 reset' \) +swap +flatten", + $this->_params['angle'], $this->_params['background'])); + } else { + $size = $this->_image->getDimensions(); + $this->_image->addPostSrcOperation(sprintf("-bordercolor \"#eee\" -border 8 bordercolor grey90 -border 1 -bordercolor none -background none -rotate %s \( +clone -shadow 60x1.5+1+1 -rotate 90 -wave 1x%s -rotate 90 \) +swap -rotate 90 -wave 1x%s -rotate -90 -flatten \( +clone -fill %s -draw 'color 0,0 reset ' \) +swap -flatten", + $this->_params['angle'], $size['height'] * 2, $size['height'] * 2, $this->_params['background'])); + } + + return true; + } + } + +} \ No newline at end of file diff --git a/framework/Image/lib/Horde/Image/Effect/im/round_corners.php b/framework/Image/lib/Horde/Image/Effect/im/round_corners.php new file mode 100644 index 000000000..297082d37 --- /dev/null +++ b/framework/Image/lib/Horde/Image/Effect/im/round_corners.php @@ -0,0 +1,105 @@ + + * @package Horde_Image + */ +class Horde_Image_Effect_im_round_corners extends Horde_Image_Effect +{ + /** + * Valid parameters: + * + * radius - Radius of rounded corners. + * + * @var array + */ + protected $_params = array('radius' => 10, + 'background' => 'none', + 'border' => 0, + 'bordercolor' => 'none'); + + public function apply() + { + /* Use imagick extension if available */ + $round = $this->_params['radius']; + // Apparently roundCorners() requires imagick to be compiled against + // IM > 6.2.8. + if (!is_null($this->_image->_imagick) && + $this->_image->_imagick->methodExists('roundCorners')) { + $result = $this->_image->_imagick->roundCorners($round, $round); + if (is_a($result, 'PEAR_Error')) { + return $result; + } + + // Using a border? + if ($this->_params['bordercolor'] != 'none' && + $this->_params['border'] > 0) { + + $size = $this->_image->getDimensions(); + + $new = new Horde_Image_ImagickProxy($size['width'] + $this->_params['border'], + $size['height'] + $this->_params['border'], + $this->_params['bordercolor'], + $this->_image->getType()); + + $result = $new->roundCorners($round, $round); + if (is_a($result, 'PEAR_Error')) { + return $result; + } + $new->compositeImage($this->_image->_imagick, + constant('Imagick::COMPOSITE_OVER'), 1, 1); + $this->_image->_imagick->clear(); + $this->_image->_imagick->addImage($new); + $new->destroy(); + } + + // If we have a background other than 'none' we need to + // compose two images together to make sure we *have* a background. + if ($this->_params['background'] != 'none') { + $size = $this->_image->getDimensions(); + $new = new Horde_Image_ImagickProxy($size['width'], + $size['height'], + $this->_params['background'], + $this->_image->getType()); + + + + $new->compositeImage($this->_image->_imagick, + constant('Imagick::COMPOSITE_OVER'), 0, 0); + $this->_image->_imagick->clear(); + $this->_image->_imagick->addImage($new); + $new->destroy(); + } + } else { + // Get image dimensions + $dimensions = $this->_image->getDimensions(); + $height = $dimensions['height']; + $width = $dimensions['width']; + + // Make sure we don't attempt to use Imagick for any other effects + // to make sure we do them in the proper order. + $this->_image->_imagick = null; + + $this->_image->addOperation("-size {$width}x{$height} xc:{$this->_params['background']} " + . "-fill {$this->_params['background']} -draw \"matte 0,0 reset\" -tile"); + + $this->_image->roundedRectangle(round($round / 2), + round($round / 2), + $width - round($round / 2) - 2, + $height - round($round / 2) - 2, + $round + 2, + 'none', + 'white'); + } + + // Reset width/height since these might have changed + $this->_image->_width = 0; + $this->_image->_height = 0; + + return true; + } + +} \ No newline at end of file diff --git a/framework/Image/lib/Horde/Image/Effect/im/text_watermark.php b/framework/Image/lib/Horde/Image/Effect/im/text_watermark.php new file mode 100644 index 000000000..764c1aec3 --- /dev/null +++ b/framework/Image/lib/Horde/Image/Effect/im/text_watermark.php @@ -0,0 +1,73 @@ + + * @package Horde_Image + */ +class Horde_Image_Effect_im_text_watermark extends Horde_Image_Effect +{ + /** + * Valid parameters for watermark effects: + * + * text (required) - The text of the watermark. + * halign - The horizontal placement + * valign - The vertical placement + * font - The font name or family to use + * fontsize - The size of the font to use + * (small, medium, large, giant) + * + * @var array + */ + protected $_params = array('halign' => 'right', + 'valign' => 'bottom', + 'font' => 'courier', + 'fontsize' => 'small'); + + /** + * Add the watermark + * + */ + public function apply() + { + /* Determine placement on image */ + switch ($this->_params['valign']) { + case 'bottom': + $v = 'south'; + break; + case 'center': + $v = 'center'; + break; + default: + $v = 'north'; + } + + switch ($this->_params['halign']) { + case 'right': + $h = 'east'; + break; + case 'center': + $h = 'center'; + break; + default: + $h = 'west'; + + } + if (($v == 'center' && $h != 'center') || + ($v == 'center' && $h == 'center')) { + $gravity = $h; + } elseif ($h == 'center' && $v != 'center') { + $gravity = $v; + } else { + $gravity = $v . $h; + } + /* Determine font point size */ + $point = $this->_image->getFontSize($this->_params['fontsize']); + $this->_image->raw(); + $this->_image->addPostSrcOperation(' -font ' . $this->_params['font'] . ' -pointsize ' . $point . ' \( +clone -resize 1x1 -fx 1-intensity -threshold 50% -scale 32x32 -write mpr:color +delete \) -tile mpr:color -gravity ' . $gravity . ' -annotate +20+10 "' . $this->_params['text'] . '"'); + $this->_image->raw(); + } + +} \ No newline at end of file diff --git a/framework/Image/lib/Horde/Image/gd.php b/framework/Image/lib/Horde/Image/gd.php new file mode 100644 index 000000000..35a6607b4 --- /dev/null +++ b/framework/Image/lib/Horde/Image/gd.php @@ -0,0 +1,971 @@ + + * @author Michael J. Rubinsky + * @package Horde_Image + */ +class Horde_Image_gd extends Horde_Image +{ + + /** + * Capabilites of this driver. + * + * @var array + */ + protected $_capabilities = array('resize', + 'crop', + 'rotate', + 'flip', + 'mirror', + 'grayscale', + 'sepia', + 'yellowize', + 'canvas'); + + /** + * GD Image resource for the current image data. + * + * @TODO: Having this protected probably breaks effects + * @var resource + */ + protected $_im; + + /** + * Const'r + * + * @param $params + * + * @return Horde_Image_gd + */ + public function __construct($params, $context = array()) + { + parent::__construct($params, $context); + if (!empty($params['width'])) { + $this->_im = $this->create($this->_width, $this->_height); + if (is_a($this->_im, 'PEAR_Error')) { + return $this->_im; + } + if (is_resource($this->_im)) { + $this->call('imageFill', array($this->_im, 0, 0, $this->_allocateColor($this->_background))); + } + } + } + + public function __get($property) + { + switch ($property) { + case '_im': + return $this->_im; + } + } + + /** + * Display the current image. + */ + public function display() + { + $this->headers(); + + return $this->call('image' . $this->_type, array($this->_im)); + } + + /** + * Returns the raw data for this image. + * + * @param boolean $convert (ignored) + * + * @return string The raw image data. + */ + public function raw($convert = false) + { + if (!is_resource($this->_im)) { + return ''; + } + + return Util::bufferOutput('image' . $this->_type, $this->_im); + } + + /** + * Reset the image data. + */ + public function reset() + { + parent::reset(); + if (is_resource($this->_im)) { + return $this->call('imageDestroy', array($this->_im)); + } + + return true; + } + + /** + * Get the height and width of the current image. + * + * @return array An hash with 'width' containing the width, + * 'height' containing the height of the image. + */ + public function getDimensions() + { + if (is_a($this->_im, 'PEAR_Error')) { + return $this->_im; + } elseif (is_resource($this->_im) && $this->_width == 0 && $this->_height ==0) { + $this->_width = $this->call('imageSX', array($this->_im)); + $this->_height = $this->call('imageSY', array($this->_im)); + return array('width' => $this->_width, + 'height' => $this->_height); + } else { + return array('width' => $this->_width, + 'height' => $this->_height); + } + } + + /** + * Creates a color that can be accessed in this object. When a + * color is set, the integer resource of it is returned. + * + * @param string $name The name of the color. + * @param int $alpha Alpha transparency (0 - 127) + * + * @return integer The resource of the color that can be passed to GD. + */ + private function _allocateColor($name, $alpha = 0) + { + static $colors = array(); + + if (empty($colors[$name])) { + list($r, $g, $b) = self::getRGB($name); + $colors[$name] = $this->call('imageColorAllocateAlpha', array($this->_im, $r, $g, $b, $alpha)); + } + + return $colors[$name]; + } + + /** + * + * + * @param $font + * @return unknown_type + */ + private function _getFont($font) + { + switch ($font) { + case 'tiny': + return 1; + + case 'medium': + return 3; + + case 'large': + return 4; + + case 'giant': + return 5; + + case 'small': + default: + return 2; + } + } + + /** + * Load the image data from a string. + * + * @param string $id An arbitrary id for the image. + * @param string $image_data The data to use for the image. + */ + public function loadString($id, $image_data) + { + if ($id != $this->_id) { + if ($this->_im) { + if (is_a($result = $this->reset(), 'PEAR_Error')) { + return $result; + } + } + $this->_im = $this->call('imageCreateFromString', array($image_data)); + $this->_id = $id; + if (is_a($this->_im, 'PEAR_Error')) { + return $this->_im; + } + } + } + + /** + * Load the image data from a file. + * + * @param string $filename The full path and filename to the file to load + * the image data from. The filename will also be + * used for the image id. + * + * @return mixed true on success | PEAR Error if file does not exist or + * could not be loaded. + */ + public function loadFile($filename) + { + if (is_a($result = $this->reset(), 'PEAR_Error')) { + return $result; + } + + if (is_a($info = $this->call('getimagesize', array($filename)), 'PEAR_Error')) { + return $info; + } + + if (is_array($info)) { + switch ($info[2]) { + case 1: + if (function_exists('imagecreatefromgif')) { + $this->_im = $this->call('imagecreatefromgif', array($filename)); + } + break; + case 2: + $this->_im = $this->call('imagecreatefromjpeg', array($filename)); + break; + case 3: + $this->_im = $this->call('imagecreatefrompng', array($filename)); + break; + case 15: + if (function_exists('imagecreatefromgwbmp')) { + $this->_im = $this->call('imagecreatefromgwbmp', array($filename)); + } + break; + case 16: + $this->_im = $this->call('imagecreatefromxbm', array($filename)); + break; + } + } + + if (is_a($this->_im, 'PEAR_Error')) { + return $this->_im; + } + + if (is_resource($this->_im)) { + return true; + } + + $result = parent::loadFile($filename); + if (is_a($result, 'PEAR_Error')) { + return $result; + } + + return $this->_im = $this->call('imageCreateFromString', array($this->_data)); + } + + /** + * Resize the current image. + * + * @param integer $width The new width. + * @param integer $height The new height. + * @param boolean $ratio Maintain original aspect ratio. + * + * @return PEAR_Error on failure + */ + public function resize($width, $height, $ratio = true) + { + /* Abort if we're asked to divide by zero, truncate the image + * completely in either direction, or there is no image data. + * @TODO: This should throw an exception + */ + if (!$width || !$height || !is_resource($this->_im)) { + return; + } + + if ($ratio) { + if ($width / $height > $this->call('imageSX', array($this->_im)) / $this->call('imageSY', array($this->_im))) { + $width = $height * $this->call('imageSX', array($this->_im)) / $this->call('imageSY', array($this->_im)); + } else { + $height = $width * $this->call('imageSY', array($this->_im)) / $this->call('imageSX', array($this->_im)); + } + } + + $im = $this->_im; + $this->_im = $this->create($width, $height); + + /* Reset geometry since it will change */ + $this->_width = 0; + $this->_height = 0; + + if (is_a($this->_im, 'PEAR_Error')) { + return $this->_im; + } + if (is_a($result = $this->call('imageFill', array($this->_im, 0, 0, $this->call('imageColorAllocate', array($this->_im, 255, 255, 255)))), 'PEAR_Error')) { + return $result; + } + if (is_a($this->call('imageCopyResampled', array($this->_im, $im, 0, 0, 0, 0, $width, $height, $this->call('imageSX', array($im)), $this->call('imageSY', array($im)))), 'PEAR_Error')) { + return $this->call('imageCopyResized', array($this->_im, $im, 0, 0, 0, 0, $width, $height, $this->call('imageSX', array($im)), $this->call('imageSY', array($im)))); + } + } + + /** + * Crop the current image. + * + * @param integer $x1 The top left corner of the cropped image. + * @param integer $y1 The top right corner of the cropped image. + * @param integer $x2 The bottom left corner of the cropped image. + * @param integer $y2 The bottom right corner of the cropped image. + */ + public function crop($x1, $y1, $x2, $y2) + { + $im = $this->_im; + $this->_im = $this->create($x2 - $x1, $y2 - $y1); + if (is_a($this->_im, 'PEAR_Error')) { + return $this->_im; + } + $this->_width = 0; + $this->_height = 0; + return $this->call('imageCopy', array($this->_im, $im, 0, 0, $x1, $y1, $x2 - $x1, $y2 - $y1)); + } + + /** + * Rotate the current image. + * + * @param integer $angle The angle to rotate the image by, + * in the clockwise direction + * @param integer $background The background color to fill any triangles + */ + public function rotate($angle, $background = 'white') + { + $background = $this->_allocateColor($background); + if (is_a($background, 'PEAR_Error')) { + return $background; + } + + $this->_width = 0; + $this->_height = 0; + + switch ($angle) { + case '90': + $x = $this->call('imageSX', array($this->_im)); + $y = $this->call('imageSY', array($this->_im)); + $xymax = max($x, $y); + + $im = $this->create($xymax, $xymax); + if (is_a($im, 'PEAR_Error')) { + return $im; + } + if (is_a($result = $this->call('imageCopy', array($im, $this->_im, 0, 0, 0, 0, $x, $y)), 'PEAR_Error')) { + return $result; + } + $im = $this->call('imageRotate', array($im, 270, $background)); + if (is_a($im, 'PEAR_Error')) { + return $im; + } + $this->_im = $im; + $im = $this->create($y, $x); + if (is_a($im, 'PEAR_Error')) { + return $im; + } + if ($x < $y) { + if (is_a($result = $this->call('imageCopy', array($im, $this->_im, 0, 0, 0, 0, $xymax, $xymax)), 'PEAR_Error')) { + return $result; + } + } elseif ($x > $y) { + if (is_a($result = $this->call('imageCopy', array($im, $this->_im, 0, 0, $xymax - $y, $xymax - $x, $xymax, $xymax)), 'PEAR_Error')) { + return $result; + } + } + $this->_im = $im; + break; + + default: + $this->_im = $this->call('imageRotate', array($this->_im, 360 - $angle, $background)); + if (is_a($this->_im, 'PEAR_Error')) { + return $this->_im; + } + break; + } + } + + /** + * Flip the current image. + */ + public function flip() + { + $x = $this->call('imageSX', array($this->_im)); + $y = $this->call('imageSY', array($this->_im)); + + $im = $this->create($x, $y); + if (is_a($im, 'PEAR_Error')) { + return $im; + } + for ($curY = 0; $curY < $y; $curY++) { + if (is_a($result = $this->call('imageCopy', array($im, $this->_im, 0, $y - ($curY + 1), 0, $curY, $x, 1)), 'PEAR_Error')) { + return $result; + } + } + + $this->_im = $im; + } + + /** + * Mirror the current image. + */ + public function mirror() + { + $x = $this->call('imageSX', array($this->_im)); + $y = $this->call('imageSY', array($this->_im)); + + $im = $this->create($x, $y); + if (is_a($im, 'PEAR_Error')) { + return $im; + } + for ($curX = 0; $curX < $x; $curX++) { + if (is_a($result = $this->call('imageCopy', array($im, $this->_im, $x - ($curX + 1), 0, $curX, 0, 1, $y)), 'PEAR_Error')) { + return $result; + } + } + + $this->_im = $im; + } + + /** + * Convert the current image to grayscale. + */ + public function grayscale() + { + $rateR = .229; + $rateG = .587; + $rateB = .114; + $whiteness = 3; + + if ($this->call('imageIsTrueColor', array($this->_im)) === true) { + if (is_a($result = $this->call('imageTrueColorToPalette', array($this->_im, true, 256)), 'PEAR_Error')) { + return $result; + } + } + + $colors = min(256, $this->call('imageColorsTotal', array($this->_im))); + for ($x = 0; $x < $colors; $x++) { + $src = $this->call('imageColorsForIndex', array($this->_im, $x)); + if (is_a($src, 'PEAR_Error')) { + return $src; + } + $new = min(255, abs($src['red'] * $rateR + $src['green'] * $rateG + $src['blue'] * $rateB) + $whiteness); + if (is_a($result = $this->call('imageColorSet', array($this->_im, $x, $new, $new, $new)), 'PEAR_Error')) { + return $result; + } + } + } + + /** + * Sepia filter. + * + * Basically turns the image to grayscale and then adds some + * defined tint on it (R += 30, G += 43, B += -23) so it will + * appear to be a very old picture. + * + * @param integer $threshold (Ignored in GD driver for now) + */ + public function sepia($threshold = 85) + { + $tintR = 80; + $tintG = 43; + $tintB = -23; + $rateR = .229; + $rateG = .587; + $rateB = .114; + $whiteness = 3; + + if ($this->call('imageIsTrueColor', array($this->_im)) === true) { + if (is_a($result = $this->call('imageTrueColorToPalette', array($this->_im, true, 256)), 'PEAR_Error')) { + return $result; + } + } + + $colors = max(256, $this->call('imageColorsTotal', array($this->_im))); + for ($x = 0; $x < $colors; $x++) { + $src = $this->call('imageColorsForIndex', array($this->_im, $x)); + if (is_a($src, 'PEAR_Error')) { + return $src; + } + $new = min(255, abs($src['red'] * $rateR + $src['green'] * $rateG + $src['blue'] * $rateB) + $whiteness); + $r = min(255, $new + $tintR); + $g = min(255, $new + $tintG); + $b = min(255, $new + $tintB); + if (is_a($result = $this->call('imageColorSet', array($this->_im, $x, $r, $g, $b)), 'PEAR_Error')) { + return $result; + } + } + } + + /** + * Yellowize filter. + * + * Adds a layer of yellow that can be transparent or solid. If + * $intensityA is 255 the image will be 0% transparent (solid). + * + * @param integer $intensityY How strong should the yellow (red and green) be? (0-255) + * @param integer $intensityB How weak should the blue be? (>= 2, in the positive limit it will be make BLUE 0) + */ + public function yellowize($intensityY = 50, $intensityB = 3) + { + if ($this->call('imageIsTrueColor', array($this->_im)) === true) { + if (is_a($result = $this->call('imageTrueColorToPalette', array($this->_im, true, 256)), 'PEAR_Error')) { + return $result; + } + } + + $colors = max(256, $this->call('imageColorsTotal', array($this->_im))); + for ($x = 0; $x < $colors; $x++) { + $src = $this->call('imageColorsForIndex', array($this->_im, $x)); + if (is_a($src, 'PEAR_Error')) { + return $src; + } + $r = min($src['red'] + $intensityY, 255); + $g = min($src['green'] + $intensityY, 255); + $b = max(($r + $g) / max($intensityB, 2), 0); + if (is_a($result = $this->call('imageColorSet', array($this->_im, $x, $r, $g, $b)), 'PEAR_Error')) { + return $result; + } + } + } + + /** + * Draws a text string on the image in a specified location, with + * the specified style information. + * + * @param string $string The text to draw. + * @param integer $x The left x coordinate of the start of the + * text string. + * @param integer $y The top y coordinate of the start of the text + * string. + * @param string $font The font identifier you want to use for the + * text (ignored for GD - font determined by + * $fontsize). + * @param string $color The color that you want the text displayed in. + * @param integer $direction An integer that specifies the orientation of + * the text. + * @param string $fontsize The font (size) to use. + * + * @return @TODO + */ + public function text($string, $x, $y, $font = 'monospace', $color = 'black', $direction = 0, $fontsize = 'small') + { + $c = $this->_allocateColor($color); + if (is_a($c, 'PEAR_Error')) { + return $c; + } + $f = $this->_getFont($fontsize); + switch ($direction) { + case -90: + case 270: + $result = $this->call('imageStringUp', array($this->_im, $f, $x, $y, $string, $c)); + break; + + case 0: + default: + $result = $this->call('imageString', array($this->_im, $f, $x, $y, $string, $c)); + } + + return $result; + } + + /** + * Draw a circle. + * + * @param integer $x The x co-ordinate of the centre. + * @param integer $y The y co-ordinate of the centre. + * @param integer $r The radius of the circle. + * @param string $color The line color of the circle. + * @param string $fill The color to fill the circle. + */ + public function circle($x, $y, $r, $color, $fill = null) + { + $c = $this->_allocateColor($color); + if (is_a($c, 'PEAR_Error')) { + return $c; + } + if (is_null($fill)) { + $result = $this->call('imageEllipse', array($this->_im, $x, $y, $r * 2, $r * 2, $c)); + } else { + if ($fill !== $color) { + $fillColor = $this->_allocateColor($fill); + if (is_a($fillColor, 'PEAR_Error')) { + return $fillColor; + } + if (is_a($result = $this->call('imageFilledEllipse', array($this->_im, $x, $y, $r * 2, $r * 2, $fillColor)), 'PEAR_Error')) { + return $result; + } + $result = $this->call('imageEllipse', array($this->_im, $x, $y, $r * 2, $r * 2, $c)); + } else { + $result = $this->call('imageFilledEllipse', array($this->_im, $x, $y, $r * 2, $r * 2, $c)); + } + } + if (is_a($result, 'PEAR_Error')) { + return $result; + } + } + + /** + * Draw a polygon based on a set of vertices. + * + * @param array $vertices An array of x and y labeled arrays + * (eg. $vertices[0]['x'], $vertices[0]['y'], ...). + * @param string $color The color you want to draw the polygon with. + * @param string $fill The color to fill the polygon. + */ + public function polygon($verts, $color, $fill = 'none') + { + $vertices = array(); + foreach ($verts as $vert) { + $vertices[] = $vert['x']; + $vertices[] = $vert['y']; + } + + if ($fill != 'none') { + $f = $this->_allocateColor($fill); + if (is_a($f, 'PEAR_Error')) { + return $f; + } + if (is_a($result = $this->call('imageFilledPolygon', array($this->_im, $vertices, count($verts), $f)), 'PEAR_Error')) { + return $result; + } + } + + if ($fill == 'none' || $fill != $color) { + $c = $this->_allocateColor($color); + if (is_a($c, 'PEAR_Error')) { + return $c; + } + if (is_a($result = $this->call('imagePolygon', array($this->_im, $vertices, count($verts), $c)), 'PEAR_Error')) { + return $result; + } + } + } + + /** + * Draw a rectangle. + * + * @param integer $x The left x-coordinate of the rectangle. + * @param integer $y The top y-coordinate of the rectangle. + * @param integer $width The width of the rectangle. + * @param integer $height The height of the rectangle. + * @param string $color The line color of the rectangle. + * @param string $fill The color to fill the rectangle with. + */ + public function rectangle($x, $y, $width, $height, $color = 'black', $fill = 'none') + { + if ($fill != 'none') { + $f = $this->_allocateColor($fill); + if (is_a($f, 'PEAR_Error')) { + return $f; + } + if (is_a($result = $this->call('imageFilledRectangle', array($this->_im, $x, $y, $x + $width, $y + $height, $f)), 'PEAR_Error')) { + return $result; + } + } + + if ($fill == 'none' || $fill != $color) { + $c = $this->_allocateColor($color); + if (is_a($c, 'PEAR_Error')) { + return $c; + } + if (is_a($result = $this->call('imageRectangle', array($this->_im, $x, $y, $x + $width, $y + $height, $c)), 'PEAR_Error')) { + return $result; + } + } + } + + /** + * Draw a rounded rectangle. + * + * @param integer $x The left x-coordinate of the rectangle. + * @param integer $y The top y-coordinate of the rectangle. + * @param integer $width The width of the rectangle. + * @param integer $height The height of the rectangle. + * @param integer $round The width of the corner rounding. + * @param string $color The line color of the rectangle. + * @param string $fill The color to fill the rounded rectangle with. + */ + public function roundedRectangle($x, $y, $width, $height, $round, $color = 'black', $fill = 'none') + { + if ($round <= 0) { + // Optimize out any calls with no corner rounding. + return $this->rectangle($x, $y, $width, $height, $color, $fill); + } + + $c = $this->_allocateColor($color); + if (is_a($c, 'PEAR_Error')) { + return $c; + } + + // Set corner points to avoid lots of redundant math. + $x1 = $x + $round; + $y1 = $y + $round; + + $x2 = $x + $width - $round; + $y2 = $y + $round; + + $x3 = $x + $width - $round; + $y3 = $y + $height - $round; + + $x4 = $x + $round; + $y4 = $y + $height - $round; + + $r = $round * 2; + + // Calculate the upper left arc. + $p1 = self::_arcPoints($round, 180, 225); + $p2 = self::_arcPoints($round, 225, 270); + + // Calculate the upper right arc. + $p3 = self::_arcPoints($round, 270, 315); + $p4 = self::_arcPoints($round, 315, 360); + + // Calculate the lower right arc. + $p5 = self::_arcPoints($round, 0, 45); + $p6 = self::_arcPoints($round, 45, 90); + + // Calculate the lower left arc. + $p7 = self::_arcPoints($round, 90, 135); + $p8 = self::_arcPoints($round, 135, 180); + + // Draw the corners - upper left, upper right, lower right, + // lower left. + if (is_a($result = $this->call('imageArc', array($this->_im, $x1, $y1, $r, $r, 180, 270, $c)), 'PEAR_Error')) { + return $result; + } + if (is_a($result = $this->call('imageArc', array($this->_im, $x2, $y2, $r, $r, 270, 360, $c)), 'PEAR_Error')) { + return $result; + } + if (is_a($result = $this->call('imageArc', array($this->_im, $x3, $y3, $r, $r, 0, 90, $c)), 'PEAR_Error')) { + return $result; + } + if (is_a($result = $this->call('imageArc', array($this->_im, $x4, $y4, $r, $r, 90, 180, $c)), 'PEAR_Error')) { + return $result; + } + + // Draw the connecting sides - top, right, bottom, left. + if (is_a($result = $this->call('imageLine', array($this->_im, $x1 + $p2['x2'], $y1 + $p2['y2'], $x2 + $p3['x1'], $y2 + $p3['y1'], $c)), 'PEAR_Error')) { + return $result; + } + if (is_a($result = $this->call('imageLine', array($this->_im, $x2 + $p4['x2'], $y2 + $p4['y2'], $x3 + $p5['x1'], $y3 + $p5['y1'], $c)), 'PEAR_Error')) { + return $result; + } + if (is_a($result = $this->call('imageLine', array($this->_im, $x3 + $p6['x2'], $y3 + $p6['y2'], $x4 + $p7['x1'], $y4 + $p7['y1'], $c)), 'PEAR_Error')) { + return $result; + } + if (is_a($result = $this->call('imageLine', array($this->_im, $x4 + $p8['x2'], $y4 + $p8['y2'], $x1 + $p1['x1'], $y1 + $p1['y1'], $c)), 'PEAR_Error')) { + return $result; + } + + if ($fill != 'none') { + $f = $this->_allocateColor($fill); + if (is_a($f, 'PEAR_Error')) { + return $f; + } + if (is_a($result = $this->call('imageFillToBorder', array($this->_im, $x + ($width / 2), $y + ($height / 2), $c, $f)), 'PEAR_Error')) { + return $result; + } + } + } + + /** + * Draw a line. + * + * @param integer $x0 The x co-ordinate of the start. + * @param integer $y0 The y co-ordinate of the start. + * @param integer $x1 The x co-ordinate of the end. + * @param integer $y1 The y co-ordinate of the end. + * @param string $color The line color. + * @param string $width The width of the line. + */ + public function line($x1, $y1, $x2, $y2, $color = 'black', $width = 1) + { + $c = $this->_allocateColor($color); + if (is_a($c, 'PEAR_Error')) { + return $c; + } + + // Don't need to do anything special for single-width lines. + if ($width == 1) { + $result = $this->call('imageLine', array($this->_im, $x1, $y1, $x2, $y2, $c)); + } elseif ($x1 == $x2) { + // For vertical lines, we can just draw a vertical + // rectangle. + $left = $x1 - floor(($width - 1) / 2); + $right = $x1 + floor($width / 2); + $result = $this->call('imageFilledRectangle', array($this->_im, $left, $y1, $right, $y2, $c)); + } elseif ($y1 == $y2) { + // For horizontal lines, we can just draw a horizontal + // filled rectangle. + $top = $y1 - floor($width / 2); + $bottom = $y1 + floor(($width - 1) / 2); + $result = $this->call('imageFilledRectangle', array($this->_im, $x1, $top, $x2, $bottom, $c)); + } else { + // Angled lines. + + // Make sure that the end points of the line are + // perpendicular to the line itself. + $a = atan2($y1 - $y2, $x2 - $x1); + $dx = (sin($a) * $width / 2); + $dy = (cos($a) * $width / 2); + + $verts = array($x2 + $dx, $y2 + $dy, $x2 - $dx, $y2 - $dy, $x1 - $dx, $y1 - $dy, $x1 + $dx, $y1 + $dy); + $result = $this->call('imageFilledPolygon', array($this->_im, $verts, count($verts) / 2, $c)); + } + + return $result; + } + + /** + * Draw a dashed line. + * + * @param integer $x0 The x co-ordinate of the start. + * @param integer $y0 The y co-ordinate of the start. + * @param integer $x1 The x co-ordinate of the end. + * @param integer $y1 The y co-ordinate of the end. + * @param string $color The line color. + * @param string $width The width of the line. + * @param integer $dash_length The length of a dash on the dashed line + * @param integer $dash_space The length of a space in the dashed line + */ + public function dashedLine($x0, $y0, $x1, $y1, $color = 'black', $width = 1, $dash_length = 2, $dash_space = 2) + { + $c = $this->_allocateColor($color); + if (is_a($c, 'PEAR_Error')) { + return $c; + } + $w = $this->_allocateColor('white'); + if (is_a($w, 'PEAR_Error')) { + return $w; + } + + // Set up the style array according to the $dash_* parameters. + $style = array(); + for ($i = 0; $i < $dash_length; $i++) { + $style[] = $c; + } + for ($i = 0; $i < $dash_space; $i++) { + $style[] = $w; + } + + if (is_a($result = $this->call('imageSetStyle', array($this->_im, $style)), 'PEAR_Error')) { + return $result; + } + if (is_a($result = $this->call('imageSetThickness', array($this->_im, $width)), 'PEAR_Error')) { + return $result; + } + return $this->call('imageLine', array($this->_im, $x0, $y0, $x1, $y1, IMG_COLOR_STYLED)); + } + + /** + * Draw a polyline (a non-closed, non-filled polygon) based on a + * set of vertices. + * + * @param array $vertices An array of x and y labeled arrays + * (eg. $vertices[0]['x'], $vertices[0]['y'], ...). + * @param string $color The color you want to draw the line with. + * @param string $width The width of the line. + */ + public function polyline($verts, $color, $width = 1) + { + $first = true; + foreach ($verts as $vert) { + if (!$first) { + if (is_a($result = $this->line($lastX, $lastY, $vert['x'], $vert['y'], $color, $width), 'PEAR_Error')) { + return $result; + } + } else { + $first = false; + } + $lastX = $vert['x']; + $lastY = $vert['y']; + } + } + + /** + * Draw an arc. + * + * @param integer $x The x co-ordinate of the centre. + * @param integer $y The y co-ordinate of the centre. + * @param integer $r The radius of the arc. + * @param integer $start The start angle of the arc. + * @param integer $end The end angle of the arc. + * @param string $color The line color of the arc. + * @param string $fill The fill color of the arc (defaults to none). + */ + public function arc($x, $y, $r, $start, $end, $color = 'black', $fill = null) + { + $c = $this->_allocateColor($color); + if (is_a($c, 'PEAR_Error')) { + return $c; + } + if (is_null($fill)) { + $result = $this->call('imageArc', array($this->_im, $x, $y, $r * 2, $r * 2, $start, $end, $c)); + } else { + if ($fill !== $color) { + $f = $this->_allocateColor($fill); + if (is_a($f, 'PEAR_Error')) { + return $f; + } + if (is_a($result = $this->call('imageFilledArc', array($this->_im, $x, $y, $r * 2, $r * 2, $start, $end, $f, IMG_ARC_PIE)), 'PEAR_Error')) { + return $result; + } + $result = $this->call('imageFilledArc', array($this->_im, $x, $y, $r * 2, $r * 2, $start, $end, $c, IMG_ARC_EDGED | IMG_ARC_NOFILL)); + } else { + $result = $this->call('imageFilledArc', array($this->_im, $x, $y, $r * 2, $r * 2, $start, $end, $c, IMG_ARC_PIE)); + } + } + return $result; + } + + /** + * Creates an image of the given size. + * If possible the function returns a true color image. + * + * @param integer $width The image width. + * @param integer $height The image height. + * + * @return resource|object PEAR Error The image handler or a PEAR_Error + * on error. + */ + public function create($width, $height) + { + $result = $this->call('imageCreateTrueColor', array($width, $height)); + if (!is_resource($result)) { + // @TODO: Throw an exception here instead. + $result = PEAR::raiseError(_("Could not create image.")); + } + + return $result; + } + + /** + * Wraps a call to a function of the gd extension. + * If the call produces an error, a PEAR_Error is returned, the function + * result otherwise. + * + * @param string $function The name of the function to wrap. + * @param array $params An array with all parameters for that function. + * + * @return mixed Either the function result or a PEAR_Error if an error + * occured when executing the function. + */ + public function call($function, $params = null) + { + unset($php_errormsg); + $track = ini_set('track_errors', 1); + $error_mask = E_ALL & ~E_WARNING & ~E_NOTICE; + error_reporting($error_mask); + $result = call_user_func_array($function, $params); + if ($track !== false) { + ini_set('track_errors', $track); + } + error_reporting($GLOBALS['conf']['debug_level']); + if (!empty($php_errormsg)) { + $error_msg = $php_errormsg; + require_once 'PEAR.php'; + $result = PEAR::raiseError($function . ': ' . $error_msg); + } + return $result; + } + +} diff --git a/framework/Image/lib/Horde/Image/im.php b/framework/Image/lib/Horde/Image/im.php new file mode 100644 index 000000000..9bd9baaca --- /dev/null +++ b/framework/Image/lib/Horde/Image/im.php @@ -0,0 +1,768 @@ + + * @author Mike Cochrane + * @author Michael J. Rubinsky + * @package Horde_Image + */ +class Horde_Image_im extends Horde_Image +{ + /** + * Capabilites of this driver. + * + * @var array + */ + protected $_capabilities = array('resize', + 'crop', + 'rotate', + 'grayscale', + 'flip', + 'mirror', + 'sepia', + 'canvas'); + + /** + * Operations to be performed before the source filename is specified on the + * command line. + * + * @var array + */ + protected $_operations = array(); + + /** + * Operations to be added after the source filename is specified on the + * command line. + * + * @var array + */ + protected $_postSrcOperations = array(); + + /** + * Reference to an Horde_Image_ImagickProxy object. + * + * @TODO: This needs to be public since some of the Effects need to + * access this and possibly null it out. This will be resolved + * when Imagick is pulled out into it's own driver. + * + * @var Imagick + */ + public $_imagick = null; + + /** + * An array of temporary filenames that need to be unlinked at the end of + * processing. Use addFileToClean() from client code (Effects) to add files + * to this array. + * + * @var array + */ + protected $_toClean = array(); + + /** + * Path to the convert binary + * + * @string + */ + protected $_convert = ''; + + /** + * Constructor. + */ + public function __construct($params, $context = array()) + { + parent::__construct($params, $context); + + if (empty($context['convert'])) { + throw new InvalidArgumentException('A path to the convert binary is required.'); + } + $this->_convert = $context['convert']; + + // TODO: Will be breaking out Imagick into it's own driver. + + // Imagick library doesn't play nice with outputting data for 0x0 + // images, so use 1x1 for our default if needed. + if (Util::loadExtension('imagick')) { + ini_set('imagick.locale_fix', 1); + require_once 'Horde/Image/imagick.php'; + $this->_width = max(array($this->_width, 1)); + $this->_height = max(array($this->_height, 1)); + // Use a proxy for the Imagick calls to keep exception catching + // code out of PHP4 compliant code. + $this->_imagick = new Horde_Image_ImagickProxy($this->_width, + $this->_height, + $this->_background, + $this->_type); + // Yea, it's wasteful to create the proxy (which creates a blank + // image) then overwrite it if we're passing in an image, but this + // will be fixed in Horde 4 when imagick is broken out into it's own + // proper driver. + if (!empty($params['filename'])) { + $this->loadFile($params['filename']); + } elseif(!empty($params['data'])) { + $this->loadString(md5($params['data']), $params['data']); + } else { + $this->_data = $this->_imagick->getImageBlob(); + } + + $this->_imagick->setImageFormat($this->_type); + } else { + if (!empty($params['filename'])) { + $this->loadFile($params['filename']); + } elseif (!empty($params['data'])) { + $this->loadString(md5($params['data']), $params['data']); + } else { + $cmd = "-size {$this->_width}x{$this->_height} xc:{$this->_background} +profile \"*\" {$this->_type}:__FILEOUT__"; + $this->executeConvertCmd($cmd); + } + } + } + + /** + * Load the image data from a string. Need to override this method + * in order to load the imagick object if we need to. + * + * @TODO: This can be nuked when imagick is broken out. + * + * @param string $id An arbitrary id for the image. + * @param string $image_data The data to use for the image. + */ + public function loadString($id, $image_data) + { + parent::loadString($id, $image_data); + if (!is_null($this->_imagick)) { + $this->_imagick->clear(); + $this->_imagick->readImageBlob($image_data); + $this->_imagick->setFormat($this->_type); + $this->_imagick->setIteratorIndex(0); + } + } + + /** + * Load the image data from a file. Need to override this method + * in order to load the imagick object if we need to. + * + * @TODO: Nuke when imagick is broken out. + * + * @param string $filename The full path and filename to the file to load + * the image data from. The filename will also be + * used for the image id. + * + * @return mixed PEAR Error if file does not exist or could not be loaded + * otherwise NULL if successful or already loaded. + */ + public function loadFile($filename) + { + parent::loadFile($filename); + if (!is_null($this->_imagick)) { + $this->_imagick->clear(); + $this->_imagick->readImageBlob($this->_data); + $this->_imagick->setIteratorIndex(0); + } + } + + /** + * Returns the raw data for this image. + * + * @param boolean $convert If true, the image data will be returned in the + * target format, even if no other image operations + * are present, otherwise, if no operations are + * present, the current raw data is returned + * unmodified. + * + * @return string The raw image data. + */ + public function raw($convert = false) + { + // Make sure _data is sync'd with imagick object + if (!is_null($this->_imagick)) { + $this->_data = $this->_imagick->getImageBlob(); + } + + if (!empty($this->_data)) { + // If there are no operations, and we already have data, don't + // bother writing out files, just return the current data. + if (!$convert && + !count($this->_operations) && + !count($this->_postSrcOperations)) { + return $this->_data; + } + + $tmpin = $this->toFile($this->_data); + } + + // Perform convert command if needed + if (count($this->_operations) || count($this->_postSrcOperations) || $convert) { + $tmpout = Util::getTempFile('img', false, $this->_tmpdir); + $command = $this->_convert . ' ' . implode(' ', $this->_operations) + . ' "' . $tmpin . '"\'[0]\' ' + . implode(' ', $this->_postSrcOperations) + . ' +profile "*" ' . $this->_type . ':"' . $tmpout . '" 2>&1'; + $this->_logDebug(sprintf("convert command executed by Horde_Image_im::raw(): %s", $command)); + exec($command, $output, $retval); + if ($retval) { + $this->_logErr(sprintf("Error running command: %s"), $command . "\n" . implode("\n", $output)); + } + + /* Empty the operations queue */ + $this->_operations = array(); + $this->_postSrcOperations = array(); + + /* Load the result */ + $this->_data = file_get_contents($tmpout); + + // Keep imagick object in sync if we need to. + // @TODO: Might be able to stop doing this once all operations + // are doable through imagick api. + if (!is_null($this->_imagick)) { + $this->_imagick->clear(); + $this->_imagick->readImageBlob($this->_data); + } + } + + @unlink($tmpin); + @unlink($tmpout); + + return $this->_data; + } + + /** + * Reset the image data. + */ + public function reset() + { + parent::reset(); + $this->_operations = array(); + $this->_postSrcOperations = array(); + if (is_object($this->_imagick)) { + $this->_imagick->clear(); + } + $this->_width = 0; + $this->_height = 0; + } + + /** + * Resize the current image. This operation takes place immediately. + * + * @param integer $width The new width. + * @param integer $height The new height. + * @param boolean $ratio Maintain original aspect ratio. + * @param boolean $keepProfile Keep the image meta data. + */ + public function resize($width, $height, $ratio = true, $keepProfile = false) + { + if (!is_null($this->_imagick)) { + $this->_imagick->thumbnailImage($width, $height, $ratio); + } else { + $resWidth = $width * 2; + $resHeight = $height * 2; + $this->_operations[] = "-size {$resWidth}x{$resHeight}"; + if ($ratio) { + $this->_postSrcOperations[] = (($keepProfile) ? "-resize" : "-thumbnail") . " {$width}x{$height}"; + } else { + $this->_postSrcOperations[] = (($keepProfile) ? "-resize" : "-thumbnail") . " {$width}x{$height}!"; + } + } + // Reset the width and height instance variables since after resize + // we don't know the *exact* dimensions yet (especially if we maintained + // aspect ratio. + // Refresh the data + $this->raw(); + $this->_width = 0; + $this->_height = 0; + } + + /** + * More efficient way of getting size if using imagick library. + * *ALWAYS* use getDimensions() to get image geometry...instance + * variables only cache geometry until it changes, then they go + * to zero. + * + */ + public function getDimensions() + { + if (!is_null($this->_imagick)) { + if ($this->_height == 0 && $this->_width == 0) { + $size = $this->_imagick->getImageGeometry(); + if (is_a($size, 'PEAR_Error')) { + return $size; + } + $this->_height = $size['height']; + $this->_width = $size['width']; + } + return array('width' => $this->_width, + 'height' => $this->_height); + } else { + return parent::getDimensions(); + } + } + + /** + * Crop the current image. + * + * @param integer $x1 x for the top left corner + * @param integer $y1 y for the top left corner + * @param integer $x2 x for the bottom right corner of the cropped image. + * @param integer $y2 y for the bottom right corner of the cropped image. + */ + public function crop($x1, $y1, $x2, $y2) + { + if (!is_null($this->_imagick)) { + $result = $this->_imagick->cropImage($x2 - $x1, $y2 - $y1, $x1, $y1); + $this->_imagick->setImagePage(0, 0, 0, 0); + } else { + $line = ($x2 - $x1) . 'x' . ($y2 - $y1) . '+' . $x1 . '+' . $y1; + $this->_operations[] = '-crop ' . $line . ' +repage'; + $result = true; + } + // Reset width/height since these might change + $this->raw(); + $this->_width = 0; + $this->_height = 0; + + return $result; + } + + /** + * Rotate the current image. + * + * @param integer $angle The angle to rotate the image by, + * in the clockwise direction. + * @param integer $background The background color to fill any triangles. + */ + public function rotate($angle, $background = 'white') + { + if (!is_null($this->_imagick)) { + return $this->_imagick->rotateImage($background, $angle); + } else { + $this->raw(); + $this->_operations[] = "-background $background -rotate {$angle}"; + $this->raw(); + } + // Reset width/height since these might have changed + $this->_width = 0; + $this->_height = 0; + } + + /** + * Flip the current image. + */ + public function flip() + { + if (!is_null($this->_imagick)) { + $this->_imagick->flipImage(); + } else { + $this->_operations[] = '-flip'; + } + } + + /** + * Mirror the current image. + */ + public function mirror() + { + if (!is_null($this->_imagick)) { + $this->_imagick->flopImage(); + } else { + $this->_operations[] = '-flop'; + } + } + + /** + * Convert the current image to grayscale. + */ + public function grayscale() + { + if (!is_null($this->_imagick)) { + $this->_imagick->setImageColorSpace(constant('Imagick::COLORSPACE_GRAY')); + } else { + $this->_postSrcOperations[] = '-colorspace GRAY'; + } + } + + /** + * Sepia filter. + * + * @param integer $threshold Extent of sepia effect. + */ + public function sepia($threshold = 85) + { + if (!is_null($this->_imagick)) { + $this->_imagick->sepiaToneImage($threshold); + } else { + $this->_operations[] = '-sepia-tone ' . $threshold . '%'; + } + } + + /** + * Draws a text string on the image in a specified location, with + * the specified style information. + * + * @TODO: Need to differentiate between the stroke (border) and the fill color, + * but this is a BC break, since we were just not providing a border. + * + * @param string $text The text to draw. + * @param integer $x The left x coordinate of the start of the text string. + * @param integer $y The top y coordinate of the start of the text string. + * @param string $font The font identifier you want to use for the text. + * @param string $color The color that you want the text displayed in. + * @param integer $direction An integer that specifies the orientation of the text. + * @param string $fontsize Size of the font (small, medium, large, giant) + */ + public function text($string, $x, $y, $font = '', $color = 'black', $direction = 0, $fontsize = 'small') + { + if (!is_null($this->_imagick)) { + $fontsize = self::getFontSize($fontsize); + + return $this->_imagick->text($string, $x, $y, $font, $color, $direction, $fontsize); + } else { + $string = addslashes('"' . $string . '"'); + $fontsize = self::getFontSize($fontsize); + $this->_postSrcOperations[] = "-fill $color " . (!empty($font) ? "-font $font" : '') . " -pointsize $fontsize -gravity northwest -draw \"text $x,$y $string\" -fill none"; + } + } + + /** + * Draw a circle. + * + * @param integer $x The x coordinate of the centre. + * @param integer $y The y coordinate of the centre. + * @param integer $r The radius of the circle. + * @param string $color The line color of the circle. + * @param string $fill The color to fill the circle. + */ + public function circle($x, $y, $r, $color, $fill = 'none') + { + if (!is_null($this->_imagick)) { + return $this->_imagick->circle($x, $y, $r, $color, $fill); + } else { + $xMax = $x + $r; + $this->_postSrcOperations[] = "-stroke $color -fill $fill -draw \"circle $x,$y $xMax,$y\" -stroke none -fill none"; + } + } + + /** + * Draw a polygon based on a set of vertices. + * + * @param array $vertices An array of x and y labeled arrays + * (eg. $vertices[0]['x'], $vertices[0]['y'], ...). + * @param string $color The color you want to draw the polygon with. + * @param string $fill The color to fill the polygon. + */ + public function polygon($verts, $color, $fill = 'none') + { + // TODO: For now, use only convert since ::polygon is called from other + // methods that are convert-only for now. + //if (!is_null($this->_imagick)) { + //return $this->_imagick->polygon($verts, $color, $fill); + //} else { + $command = ''; + foreach ($verts as $vert) { + $command .= sprintf(' %d,%d', $vert['x'], $vert['y']); + } + $this->_postSrcOperations[] = "-stroke $color -fill $fill -draw \"polygon $command\" -stroke none -fill none"; + //} + } + + /** + * Draw a rectangle. + * + * @param integer $x The left x-coordinate of the rectangle. + * @param integer $y The top y-coordinate of the rectangle. + * @param integer $width The width of the rectangle. + * @param integer $height The height of the rectangle. + * @param string $color The line color of the rectangle. + * @param string $fill The color to fill the rectangle. + */ + public function rectangle($x, $y, $width, $height, $color, $fill = 'none') + { + if (!is_null($this->_imagick)) { + $this->_imagick->rectangle($x, $y, $width, $height, $color, $fill); + } else { + $xMax = $x + $width; + $yMax = $y + $height; + $this->_postSrcOperations[] = "-stroke $color -fill $fill -draw \"rectangle $x,$y $xMax,$yMax\" -stroke none -fill none"; + } + } + + /** + * Draw a rounded rectangle. + * + * @param integer $x The left x-coordinate of the rectangle. + * @param integer $y The top y-coordinate of the rectangle. + * @param integer $width The width of the rectangle. + * @param integer $height The height of the rectangle. + * @param integer $round The width of the corner rounding. + * @param string $color The line color of the rectangle. + * @param string $fill The color to fill the rounded rectangle with. + */ + public function roundedRectangle($x, $y, $width, $height, $round, $color, $fill) + { + if (!is_null($this->_imagick)) { + $this->_imagick->roundedRectangle($x, $y, $width, $height, $round, $color, $fill); + } else { + $x1 = $x + $width; + $y1 = $y + $height; + $this->_postSrcOperations[] = "-stroke $color -fill $fill -draw \"roundRectangle $x,$y $x1,$y1 $round,$round\" -stroke none -fill none"; + + } + } + + /** + * Draw a line. + * + * @param integer $x0 The x coordinate of the start. + * @param integer $y0 The y coordinate of the start. + * @param integer $x1 The x coordinate of the end. + * @param integer $y1 The y coordinate of the end. + * @param string $color The line color. + * @param string $width The width of the line. + */ + public function line($x0, $y0, $x1, $y1, $color = 'black', $width = 1) + { + if (!is_null($this->_imagick)) { + return $this->_imagick->line($x0, $y0, $x1, $y1, $color, $width); + } else { + $this->_operations[] = "-stroke $color -strokewidth $width -draw \"line $x0,$y0 $x1,$y1\""; + } + } + + /** + * Draw a dashed line. + * + * @param integer $x0 The x co-ordinate of the start. + * @param integer $y0 The y co-ordinate of the start. + * @param integer $x1 The x co-ordinate of the end. + * @param integer $y1 The y co-ordinate of the end. + * @param string $color The line color. + * @param string $width The width of the line. + * @param integer $dash_length The length of a dash on the dashed line + * @param integer $dash_space The length of a space in the dashed line + */ + public function dashedLine($x0, $y0, $x1, $y1, $color = 'black', $width = 1, $dash_length = 2, $dash_space = 2) + { + if (!is_null($this->_imagick)) { + return $this->_imagick->dashedLine($x0, $y0, $x1, $y1, $color, + $width, $dash_length, + $dash_space); + } else { + $this->_operations[] = "-stroke $color -strokewidth $width -draw \"line $x0,$y0 $x1,$y1\""; + } + } + + /** + * Draw a polyline (a non-closed, non-filled polygon) based on a + * set of vertices. + * + * @param array $vertices An array of x and y labeled arrays + * (eg. $vertices[0]['x'], $vertices[0]['y'], ...). + * @param string $color The color you want to draw the line with. + * @param string $width The width of the line. + */ + public function polyline($verts, $color, $width = 1) + { + if (!is_null($this->_imagick)) { + return $this->_imagick->polyline($verts, $color, $width); + } else { + $command = ''; + foreach ($verts as $vert) { + $command .= sprintf(' %d,%d', $vert['x'], $vert['y']); + } + $this->_operations[] = "-stroke $color -strokewidth $width -fill none -draw \"polyline $command\" -strokewidth 1 -stroke none -fill none"; + } + } + + /** + * Draw an arc. + * + * @param integer $x The x coordinate of the centre. + * @param integer $y The y coordinate of the centre. + * @param integer $r The radius of the arc. + * @param integer $start The start angle of the arc. + * @param integer $end The end angle of the arc. + * @param string $color The line color of the arc. + * @param string $fill The fill color of the arc (defaults to none). + */ + public function arc($x, $y, $r, $start, $end, $color = 'black', $fill = 'none') + { + // Split up arcs greater than 180 degrees into two pieces. + $this->_postSrcOperations[] = "-stroke $color -fill $fill"; + $mid = round(($start + $end) / 2); + $x = round($x); + $y = round($y); + $r = round($r); + if ($mid > 90) { + $this->_postSrcOperations[] = "-draw \"ellipse $x,$y $r,$r $start,$mid\""; + $this->_postSrcOperations[] = "-draw \"ellipse $x,$y $r,$r $mid,$end\""; + } else { + $this->_postSrcOperations[] = "-draw \"ellipse $x,$y $r,$r $start,$end\""; + } + + // If filled, draw the outline. + if (!empty($fill)) { + list($x1, $y1) = $this->_circlePoint($start, $r * 2); + list($x2, $y2) = $this->_circlePoint($mid, $r * 2); + list($x3, $y3) = $this->_circlePoint($end, $r * 2); + + // This seems to result in slightly better placement of + // pie slices. + $x++; + $y++; + + $verts = array(array('x' => $x + $x3, 'y' => $y + $y3), + array('x' => $x, 'y' => $y), + array('x' => $x + $x1, 'y' => $y + $y1)); + + if ($mid > 90) { + $verts1 = array(array('x' => $x + $x2, 'y' => $y + $y2), + array('x' => $x, 'y' => $y), + array('x' => $x + $x1, 'y' => $y + $y1)); + $verts2 = array(array('x' => $x + $x3, 'y' => $y + $y3), + array('x' => $x, 'y' => $y), + array('x' => $x + $x2, 'y' => $y + $y2)); + + $this->polygon($verts1, $fill, $fill); + $this->polygon($verts2, $fill, $fill); + } else { + $this->polygon($verts, $fill, $fill); + } + + $this->polyline($verts, $color); + + $this->_postSrcOperations[] = '-stroke none -fill none'; + } + } + + public function applyEffects() + { + $this->raw(); + foreach ($this->_toClean as $tempfile) { + @unlink($tempfile); + } + } + + /** + * Method to execute a raw command directly in convert. Useful for executing + * more involved operations that may require multiple convert commands + * piped into each other for example. Really designed for use by im based + * Horde_Image_Effect objects.. + * + * The input and output files are quoted and substituted for __FILEIN__ and + * __FILEOUT__ respectfully. In order to support piped convert commands, the + * path to the convert command is substitued for __CONVERT__ (but the + * initial convert command is added automatically). + * + * @param string $cmd The command string, with substitutable tokens + * @param array $values Any values that should be substituted for tokens. + * + * @return + */ + public function executeConvertCmd($cmd, $values = array()) + { + // First, get a temporary file for the input + if (strpos($cmd, '__FILEIN__') !== false) { + $tmpin = $this->toFile($this->_data); + } else { + $tmpin = ''; + } + + // Now an output file + $tmpout = Util::getTempFile('img', false, $this->_tmpdir); + + // Substitue them in the cmd string + $cmd = str_replace(array('__FILEIN__', '__FILEOUT__', '__CONVERT__'), + array('"' . $tmpin . '"', '"' . $tmpout . '"', $this->_convert), + $cmd); + + //TODO: See what else needs to be replaced. + $cmd = $this->_convert . ' ' . $cmd . ' 2>&1'; + + // Log it + $this->_logDebug(sprintf("convert command executed by Horde_Image_im::executeConvertCmd(): %s", $cmd)); + exec($cmd, $output, $retval); + if ($retval) { + $this->_logErr(sprintf("Error running command: %s", $cmd . "\n" . implode("\n", $output))); + } + $this->_data = file_get_contents($tmpout); + + @unlink($tmpin); + @unlink($tmpout); + } + + + /** + * Return point size for font + */ + public static function getFontSize($fontsize) + { + switch ($fontsize) { + case 'medium': + $point = 18; + break; + case 'large': + $point = 24; + break; + case 'giant': + $point = 30; + break; + default: + $point = 12; + } + + return $point; + } + + + /** + * Get the version of the convert command available. This needs to be + * publicly visable since it's used by various Effects. + * + * @return A version string suitable for using in version_compare() + */ + public function getIMVersion() + { + static $version = null; + if (!is_array($version)) { + if (!is_null($this->_imagick)) { + $output = $this->_imagick->getVersion(); + $output[0] = $output['versionString']; + } else { + $commandline = $this->_convert . ' --version'; + exec($commandline, $output, $retval); + } + if (preg_match('/([0-9])\.([0-9])\.([0-9])/', $output[0], $matches)) { + $version = $matches; + return $matches; + } else { + return false; + } + } + return $version; + } + + public function addPostSrcOperation($operation) + { + $this->_postSrcOperations[] = $operation; + } + + public function addOperation($operation) + { + $this->_operations[] = $operation; + } + + public function addFileToClean($filename) + { + $this->_toClean[] = $filename; + } + + public function getConvertPath() + { + return $this->_convert; + } + +} \ No newline at end of file diff --git a/framework/Image/lib/Horde/Image/imagick.php b/framework/Image/lib/Horde/Image/imagick.php new file mode 100644 index 000000000..ca1270bf4 --- /dev/null +++ b/framework/Image/lib/Horde/Image/imagick.php @@ -0,0 +1,446 @@ + + * @package Horde_Image + */ +class Horde_Image_ImagickProxy +{ + /** + * Instance variable for our Imagick object. + * + * @var Imagick object + */ + protected $_imagick = null; + + /** + * Constructor. Instantiate our imagick object and set some defaults. + */ + public function __construct($width = 1, $height = 1, $bg = 'white', $format = 'png') + { + $this->_imagick = new Imagick(); + $this->_imagick->newImage($width, $height, new ImagickPixel($bg)); + $this->_imagick->setImageFormat($format); + } + + /** + * Clears the current imagick object and reloads it + * with the passed in binary data. + * + * @param string $image_data The data representing an image. + * + * @return mixed true || PEAR_Error + */ + public function loadString($image_data) + { + try { + if (!$this->_imagick->clear()) { + return PEAR::raiseError('Unable to clear the Imagick object'); + } + if (!$this->_imagick->readImageBlob($image_data)) { + return PEAR::raiseError(sprintf("Call to Imagick::readImageBlob failed on line %s of %s", __LINE__, __FILE__)); + } + return true; + } catch (ImagickException $e) { + return PEAR::raiseError($e->getMessage()); + } + } + + /** + * Rotates image as described. Don't pass through since we are not passing + * a ImagickPixel object from PHP4 code. + * + * @param string $bg Background color + * @param integer $angle Angle to rotate + * + * @return mixed true || PEAR_Error + */ + public function rotateImage($bg, $angle) + { + try { + if (!$this->_imagick->rotateImage(new ImagickPixel($bg), $angle)) { + return PEAR::raiseError(sprintf("Call to Imagick::rotateImage failed on line %s of %s", __LINE__, __FILE__)); + } + return true; + } catch (ImagickException $e) { + return PEAR::raiseError($e->getMessage()); + } + } + + /** + * Change image to a grayscale image. + * + * @return mixed true || PEAR_Error + */ + function grayscale() + { + try { + if (!$this->_imagick->setImageColorSpace(Imagick::COLORSPACE_GRAY)) { + return PEAR::raiseError(sprintf("Call to Imagick::setImageColorSpace failed on line %s of %s", __LINE__, __FILE__)); + } + return true; + } catch (ImagickException $e) { + return PEAR::raiseError($e->getMessage()); + } + } + + /** + * Places a string of text on this image with the specified properties + * + * @TODO + * + * @return mixed true || PEAR_Error + */ + function text($string, $x, $y, $font = 'ariel', $color = 'black', $direction = 0, $fontsize = 'small') + { + try { + $pixel = new ImagickPixel($color); + $draw = new ImagickDraw(); + $draw->setFillColor($pixel); + if (!empty($font)) { + $draw->setFont($font); + } + $draw->setFontSize($fontsize); + $draw->setGravity(Imagick::GRAVITY_NORTHWEST); + $res = $this->_imagick->annotateImage($draw, $x, $y, $direction, $string); + $draw->destroy(); + if (!$res) { + return PEAR::raiseError(sprintf("Call to Imagick::annotateImage failed on line %s of %s", __LINE__, __FILE__)); + } + return true; + } catch (ImagickException $e) { + return PEAR::raiseError($e->getMessage()); + } + } + + /** + * @TODO + * + * @return mixed true || PEAR_Error + */ + function circle($x, $y, $r, $color, $fill) + { + try { + $draw = new ImagickDraw(); + $draw->setFillColor(new ImagickPixel($fill)); + $draw->setStrokeColor(new ImagickPixel($color)); + $draw->circle($x, $y, $r + $x, $y); + $res = $this->_imagick->drawImage($draw); + $draw->destroy(); + if (!$res) { + return PEAR::raiseError(sprintf("Call to Imagick::drawImage failed on line %s of %s", __LINE__, __FILE__)); + } + return true; + } catch (ImagickException $e) { + return PEAR::raiseError($e->getMessage()); + } + } + + /** + * @TODO + * + * @return mixed true || PEAR_Error + */ + function polygon($verts, $color, $fill) + { + try { + $draw = new ImagickDraw(); + $draw->setFillColor(new ImagickPixel($fill)); + $draw->setStrokeColor(new ImagickPixel($color)); + $draw->polygon($verts); + $res = $this->_imagick->drawImage($draw); + $draw->destroy(); + if (!$res) { + return PEAR::raiseError(sprintf("Call to Imagick::drawImage failed on line %s of %s", __LINE__, __FILE__)); + } + return true; + } catch (ImagickException $e) { + return PEAR::raiseError($e->getMessage()); + } + } + + /** + * @TODO + * + * @return mixed true || Pear_Error + */ + function rectangle($x, $y, $width, $height, $color, $fill = 'none') + { + try { + $draw = new ImagickDraw(); + $draw->setStrokeColor(new ImagickPixel($color)); + $draw->setFillColor(new ImagickPixel($fill)); + $draw->rectangle($x, $y, $x + $width, $y + $height); + $res = $this->_imagick->drawImage($draw); + $draw->destroy(); + if (!$res) { + return PEAR::raiseError(sprintf("Call to Imagick::drawImage failed on line %s of %s", __LINE__, __FILE__)); + } + return true; + } catch (ImagickException $e) { + return PEAR::raiseError($e->getMessage()); + } + } + + /** + * Rounded Rectangle + * + * + */ + function roundedRectangle($x, $y, $width, $height, $round, $color, $fill) + { + $draw = new ImagickDraw(); + $draw->setStrokeColor(new ImagickPixel($color)); + $draw->setFillColor(new ImagickPixel($fill)); + $draw->roundRectangle($x, $y, $x + $width, $y + $height, $round, $round); + $res = $this->_imagick->drawImage($draw); + } + + /** + * @TODO + * + * @return mixed true || PEAR_Error + */ + function line($x0, $y0, $x1, $y1, $color, $width) + { + try { + $draw = new ImagickDraw(); + $draw->setStrokeColor(new ImagickPixel($color)); + $draw->setStrokeWidth($width); + $draw->line($x0, $y0, $x1, $y1); + $res = $this->_imagick->drawImage($draw); + $draw->destroy(); + if (!$res) { + return PEAR::raiseError(sprintf("Call to Imagick::drawImage failed on line %s of %s", __LINE__, __FILE__)); + } + return true; + } catch (ImagickException $e) { + return PEAR::raiseError($e->getMessage()); + } + } + + /** + * @TODO + * + * @return mixed true || PEAR_Error + */ + function dashedLine($x0, $y0, $x1, $y1, $color, $width, $dash_length, $dash_space) + { + try { + $draw = new ImagickDraw(); + $draw->setStrokeColor(new ImagickPixel($color)); + $draw->setStrokeWidth($width); + $draw->setStrokeDashArray(array($dash_length, $dash_space)); + $draw->line($x0, $y0, $x1, $y1); + $res = $this->_imagick->drawImage($draw); + $draw->destroy(); + if (!$res) { + return PEAR::raiseError(sprintf("Call to Imagick::drawImage failed on line %s of %s", __LINE__, __FILE__)); + } + return true; + } catch (ImagickException $e) { + return PEAR::raiseError($e->getMessage()); + } + } + + /** + * @TODO + * + * @return mixed true || PEAR_Error + */ + function polyline($verts, $color, $width) + { + try { + $draw = new ImagickDraw(); + $draw->setStrokeColor(new ImagickPixel($color)); + $draw->setStrokeWidth($width); + $draw->setFillColor(new ImagickPixel('none')); + $draw->polyline($verts); + $res = $this->_imagick->drawImage($draw); + $draw->destroy(); + if (!$res) { + return PEAR::raiseError(sprintf("Call to Imagick::drawImage failed on line %s of %s", __LINE__, __FILE__)); + } + return true; + } catch (ImagickException $e) { + return PEAR::raiseError($e->getMessage()); + } + } + + /** + * @TODO + * + * @return mixed true || PEAR_Error + */ + function setImageBackgroundColor($color) + { + try { + $res = $this->_imagick->setImageBackgroundColor(new ImagickPixel($color)); + if (!$res) { + return PEAR::raiseError(sprintf("Call to Imagick::setImageBackgroundColor failed on line %s of %s", __LINE__, __FILE__)); + } + return true; + } catch (ImagickException $e) { + return PEAR::raiseError($e->getMessage()); + } + } + + /** + * @TODO + * + * @return mixed true || PEAR_Error + */ + function compositeImage(&$imagickProxy, $constant, $x, $y, $channel = null) + { + try { + $res = $this->_imagick->compositeImage($imagickProxy->getIMObject(), + $constant, + $x, + $y, $channel); + if (!$res) { + return PEAR::raiseError(sprintf("Call to Imagick::compositeImage failed on line %s of %s", __LINE__, __FILE__)); + } + return true; + } catch (ImagickException $e) { + return PEAR::raiseError($e->getMessage()); + } + } + + /** + * @TODO + * + * @return mixed true || PEAR_Error + */ + function addImage(&$imagickProxy) + { + try { + $res = $this->_imagick->addImage($imagickProxy->getIMObject()); + if (!$res) { + return PEAR::raiseError(sprintf("Call to Imagick::drawImage failed on line %s of %s", __LINE__, __FILE__)); + } + return true; + } catch (ImagickException $e) { + return PEAR::raiseError($e->getMessage()); + } + } + + /** + * Add a border to this image. + * + * @param string $color The color of the border. + * @param integer $width The border width + * @param integer $height The border height + * + * @return mixed true || PEAR_Error + * + */ + function borderImage($color, $width, $height) + { + try { + // Jump through all there hoops to preserve any transparency. + $border = $this->_imagick->clone(); + $border->borderImage(new ImagickPixel($color), + $width, $height); + $border->compositeImage($this->_imagick, + constant('Imagick::COMPOSITE_COPY'), + $width, $height); + $this->_imagick->clear(); + $this->_imagick->addImage($border); + $border->destroy(); + return true; + } catch (ImagickException $e) { + return PEAR::raiseError($e->getMessage()); + } + } + + /** + * Return the raw Imagick object + * + * @return Imagick The Imagick object for this proxy. + */ + function &getIMObject() + { + return $this->_imagick; + } + + /** + * Produces a clone of this ImagickProxy object. + * + * @return mixed Horde_Image_ImagickProxy object || PEAR_Error + * + */ + function &cloneIM() + { + try { + $new = new Horde_Image_ImagickProxy(); + $new->clear(); + if (!$new->readImageBlob($this->getImageBlob())) { + return PEAR::raiseError(sprintf("Call to Imagick::readImageBlob failed on line %s of %s", __LINE__, __FILE__)); + } + return $new; + } catch (ImagickException $e) { + return PEAR::raiseError($e->getMessage()); + } + } + + /** + * + */ + function polaroidImage($angle = 0) + { + try { + $bg = new ImagickDraw(); + return $this->_imagick->polaroidImage($bg, $angle); + } catch (ImagickException $e) { + return PEAR::raiseError($e->getMessage()); + } + } + + /** + * Check if a particular method exists in the installed version of Imagick + * + * @param string $methodName The name of the method to check for. + * + * @return boolean + */ + function methodExists($methodName) + { + if (method_exists($this->_imagick, $methodName)) { + return true; + } else { + return false; + } + } + + /** + * Pass through any methods not explicitly handled above. + * Note that any methods that take any Imagick* object as a parameter + * should be called through it's own method as above so we can avoid + * having objects that might throw exceptions running in PHP4 code. + */ + function __call($method, $params) + { + try { + if (method_exists($this->_imagick, $method)) { + $result = call_user_func_array(array($this->_imagick, $method), $params); + } else { + return PEAR::raiseError(sprintf("Unable to execute %s. Your ImageMagick version may not support this feature.", $method)); + } + } catch (ImagickException $e) { + return PEAR::raiseError($e->getMessage()); + } + return $result; + } + +} diff --git a/framework/Image/lib/Horde/Image/png.php b/framework/Image/lib/Horde/Image/png.php new file mode 100644 index 000000000..fc009ed7a --- /dev/null +++ b/framework/Image/lib/Horde/Image/png.php @@ -0,0 +1,243 @@ + + * @since Horde 3.0 + * @package Horde_Image + */ +class Horde_Image_png extends Horde_Image { + + /** + * The array of pixel data. + * + * @var array + */ + var $_img = array(); + + /** + * Color depth (only 8 and 16 implemented). + * + * @var integer + */ + var $_colorDepth = 8; + + /** + * Color type (only 2 (true color) implemented). + * + * @var integer + */ + var $_colorType = 2; + + /** + * Compression method (0 is the only current valid value). + * + * @var integer + */ + var $_compressionMethod = 0; + + /** + * Filter method (0 is the only current valid value). + * + * @var integer + */ + var $_filterMethod = 0; + + /** + * Interlace method (only 0 (no interlace) implemented). + * + * @var integer + */ + var $_interlaceMethod = 0; + + /** + * PNG image constructor. + */ + function Horde_Image_png($params) + { + parent::Horde_Image($params); + + if (!empty($params['width'])) { + $this->rectangle(0, 0, $params['width'], $params['height'], $this->_background, $this->_background); + } + } + + function getContentType() + { + return 'image/png'; + } + + /** + * Return the raw data for this image. + * + * @return string The raw image data. + */ + function raw() + { + return + $this->_header() . + $this->_IHDR() . + + /* Say what created the image file. */ + $this->_tEXt('Software', 'Horde Framework Image_png Class') . + + /* Set the last modified date/time. */ + $this->_tIME() . + + $this->_IDAT() . + $this->_IEND(); + } + + /** + * Reset the image data. + */ + function reset() + { + parent::reset(); + $this->_img = array(); + } + + /** + * Draw a rectangle. + * + * @param integer $x The left x-coordinate of the rectangle. + * @param integer $y The top y-coordinate of the rectangle. + * @param integer $width The width of the rectangle. + * @param integer $height The height of the rectangle. + * @param string $color The line color of the rectangle. + * @param string $fill The color to fill the rectangle with. + */ + function rectangle($x, $y, $width, $height, $color = 'black', $fill = 'none') + { + list($r, $g, $b) = $this->getRGB($color); + if ($fill != 'none') { + list($fR, $fG, $fB) = $this->getRGB($fill); + } + + $x2 = $x + $width; + $y2 = $y + $height; + + for ($h = $y; $h <= $y2; $h++) { + for ($w = $x; $w <= $x2; $w++) { + // See if we're on an edge. + if ($w == $x || $h == $y || $w == $x2 || $h == $y2) { + $this->_img[$h][$w] = array('r' => $r, 'g' => $g, 'b' => $b); + } elseif ($fill != 'none') { + $this->_img[$h][$w] = array('r' => $fR, 'g' => $fG, 'b' => $fB); + } + } + } + } + + /** + * Create the PNG file header. + */ + function _header() + { + return pack('CCCCCCCC', 137, 80, 78, 71, 13, 10, 26, 10); + } + + /** + * Create Image Header block. + */ + function _IHDR() + { + $data = pack('a4NNCCCCC', 'IHDR', $this->_width, $this->_height, $this->_colorDepth, $this->_colorType, $this->_compressionMethod, $this->_filterMethod, $this->_interlaceMethod); + return pack('Na' . strlen($data) . 'N', strlen($data) - 4, $data, crc32($data)); + } + + /** + * Create IEND block. + */ + function _IEND() + { + $data = 'IEND'; + return pack('Na' . strlen($data) . 'N', strlen($data) - 4, $data, crc32($data)); + } + + /** + * Create Image Data block. + */ + function _IDAT() + { + $data = ''; + $prevscanline = null; + $filter = 0; + for ($i = 0; $i < $this->_height; $i++) { + $scanline = array(); + $data .= chr($filter); + for ($j = 0; $j < $this->_width; $j++) { + if ($this->_colorDepth == 8) { + $scanline[$j] = pack('CCC', $this->_img[$i][$j]['r'], $this->_img[$i][$j]['g'], $this->_img[$i][$j]['b']); + } elseif ($this->_colorDepth == 16) { + $scanline[$j] = pack('nnn', $this->_img[$i][$j]['r'] << 8, $this->_img[$i][$j]['g'] << 8, $this->_img[$i][$j]['b'] << 8); + } + + if ($filter == 0) { + /* No Filter. */ + $data .= $scanline[$j]; + } elseif ($filter == 2) { + /* Up Filter. */ + $pixel = $scanline[$j] - $prevscanline[$j]; + if ($this->_colorDepth == 8) { + $data .= pack('CCC', $pixel >> 16, ($pixel >> 8) & 0xFF, $pixel & 0xFF); + } elseif ($this->_colorDepth == 16) { + $data .= pack('nnn', ($pixel >> 32), ($pixel >> 16) & 0xFFFF, $pixel & 0xFFFF); + } + } + } + $prevscanline = $scanline; + } + $compressed = gzdeflate($data, 9); + + $data = 'IDAT' . pack('CCa' . strlen($compressed) . 'a4', 0x78, 0x01, $compressed, $this->_Adler32($data)); + return pack('Na' . strlen($data) . 'N', strlen($data) - 4, $data, crc32($data)); + } + + /** + * Create tEXt block. + */ + function _tEXt($keyword, $text) + { + $data = 'tEXt' . $keyword . "\0" . $text; + return pack('Na' . strlen($data) . 'N', strlen($data) - 4, $data, crc32($data)); + } + + /** + * Create last modified time block. + */ + function _tIME($date = null) + { + if (is_null($date)) { + $date = time(); + } + + $data = 'tIME' . pack('nCCCCC', intval(date('Y', $date)), intval(date('m', $date)), intval(date('j', $date)), intval(date('G', $date)), intval(date('i', $date)), intval(date('s', $date))); + return pack('Na' . strlen($data) . 'N', strlen($data) - 4, $data, crc32($data)); + } + + /** + * Calculate an Adler32 checksum for a string. + */ + function _Adler32($input) + { + $s1 = 1; + $s2 = 0; + $iMax = strlen($input); + for ($i = 0; $i < $iMax; $i++) { + $s1 = ($s1 + ord($input[$i])) % 0xFFF1; + $s2 = ($s2 + $s1) % 0xFFF1; + } + return pack('N', (($s2 << 16) | $s1)); + } + +} diff --git a/framework/Image/lib/Horde/Image/rgb.php b/framework/Image/lib/Horde/Image/rgb.php new file mode 100644 index 000000000..2d30976c9 --- /dev/null +++ b/framework/Image/lib/Horde/Image/rgb.php @@ -0,0 +1,446 @@ + array(0, 255, 255), + 'lime' => array(0, 255, 0), + 'teal' => array(0, 128, 128), + 'whitesmoke' => array(245, 245, 245), + 'gainsboro' => array(220, 220, 220), + 'oldlace' => array(253, 245, 230), + 'linen' => array(250, 240, 230), + 'antiquewhite' => array(250, 235, 215), + 'papayawhip' => array(255, 239, 213), + 'blanchedalmond' => array(255, 235, 205), + 'bisque' => array(255, 228, 196), + 'peachpuff' => array(255, 218, 185), + 'navajowhite' => array(255, 222, 173), + 'moccasin' => array(255, 228, 181), + 'cornsilk' => array(255, 248, 220), + 'ivory' => array(255, 255, 240), + 'lemonchiffon' => array(255, 250, 205), + 'seashell' => array(255, 245, 238), + 'mintcream' => array(245, 255, 250), + 'azure' => array(240, 255, 255), + 'aliceblue' => array(240, 248, 255), + 'lavender' => array(230, 230, 250), + 'lavenderblush' => array(255, 240, 245), + 'mistyrose' => array(255, 228, 225), + 'white' => array(255, 255, 255), + 'black' => array(0, 0, 0), + 'darkslategray' => array(47, 79, 79), + 'dimgray' => array(105, 105, 105), + 'slategray' => array(112, 128, 144), + 'lightslategray' => array(119, 136, 153), + 'gray' => array(190, 190, 190), + 'lightgray' => array(211, 211, 211), + 'midnightblue' => array(25, 25, 112), + 'navy' => array(0, 0, 128), + 'cornflowerblue' => array(100, 149, 237), + 'darkslateblue' => array(72, 61, 139), + 'slateblue' => array(106, 90, 205), + 'mediumslateblue' => array(123, 104, 238), + 'lightslateblue' => array(132, 112, 255), + 'mediumblue' => array(0, 0, 205), + 'royalblue' => array(65, 105, 225), + 'blue' => array(0, 0, 255), + 'dodgerblue' => array(30, 144, 255), + 'deepskyblue' => array(0, 191, 255), + 'skyblue' => array(135, 206, 235), + 'lightskyblue' => array(135, 206, 250), + 'steelblue' => array(70, 130, 180), + 'lightred' => array(211, 167, 168), + 'lightsteelblue' => array(176, 196, 222), + 'lightblue' => array(173, 216, 230), + 'powderblue' => array(176, 224, 230), + 'paleturquoise' => array(175, 238, 238), + 'darkturquoise' => array(0, 206, 209), + 'mediumturquoise' => array(72, 209, 204), + 'turquoise' => array(64, 224, 208), + 'cyan' => array(0, 255, 255), + 'lightcyan' => array(224, 255, 255), + 'cadetblue' => array(95, 158, 160), + 'mediumaquamarine' => array(102, 205, 170), + 'aquamarine' => array(127, 255, 212), + 'darkgreen' => array(0, 100, 0), + 'darkolivegreen' => array(85, 107, 47), + 'darkseagreen' => array(143, 188, 143), + 'seagreen' => array(46, 139, 87), + 'mediumseagreen' => array(60, 179, 113), + 'lightseagreen' => array(32, 178, 170), + 'palegreen' => array(152, 251, 152), + 'springgreen' => array(0, 255, 127), + 'lawngreen' => array(124, 252, 0), + 'green' => array(0, 255, 0), + 'chartreuse' => array(127, 255, 0), + 'mediumspringgreen' => array(0, 250, 154), + 'greenyellow' => array(173, 255, 47), + 'limegreen' => array(50, 205, 50), + 'yellowgreen' => array(154, 205, 50), + 'forestgreen' => array(34, 139, 34), + 'olivedrab' => array(107, 142, 35), + 'darkkhaki' => array(189, 183, 107), + 'khaki' => array(240, 230, 140), + 'palegoldenrod' => array(238, 232, 170), + 'lightgoldenrodyellow' => array(250, 250, 210), + 'lightyellow' => array(255, 255, 200), + 'yellow' => array(255, 255, 0), + 'gold' => array(255, 215, 0), + 'lightgoldenrod' => array(238, 221, 130), + 'goldenrod' => array(218, 165, 32), + 'darkgoldenrod' => array(184, 134, 11), + 'rosybrown' => array(188, 143, 143), + 'indianred' => array(205, 92, 92), + 'saddlebrown' => array(139, 69, 19), + 'sienna' => array(160, 82, 45), + 'peru' => array(205, 133, 63), + 'burlywood' => array(222, 184, 135), + 'beige' => array(245, 245, 220), + 'wheat' => array(245, 222, 179), + 'sandybrown' => array(244, 164, 96), + 'tan' => array(210, 180, 140), + 'chocolate' => array(210, 105, 30), + 'firebrick' => array(178, 34, 34), + 'brown' => array(165, 42, 42), + 'darksalmon' => array(233, 150, 122), + 'salmon' => array(250, 128, 114), + 'lightsalmon' => array(255, 160, 122), + 'orange' => array(255, 165, 0), + 'darkorange' => array(255, 140, 0), + 'coral' => array(255, 127, 80), + 'lightcoral' => array(240, 128, 128), + 'tomato' => array(255, 99, 71), + 'orangered' => array(255, 69, 0), + 'red' => array(255, 0, 0), + 'hotpink' => array(255, 105, 180), + 'deeppink' => array(255, 20, 147), + 'pink' => array(255, 192, 203), + 'lightpink' => array(255, 182, 193), + 'palevioletred' => array(219, 112, 147), + 'maroon' => array(176, 48, 96), + 'mediumvioletred' => array(199, 21, 133), + 'violetred' => array(208, 32, 144), + 'magenta' => array(255, 0, 255), + 'violet' => array(238, 130, 238), + 'plum' => array(221, 160, 221), + 'orchid' => array(218, 112, 214), + 'mediumorchid' => array(186, 85, 211), + 'darkorchid' => array(153, 50, 204), + 'darkviolet' => array(148, 0, 211), + 'blueviolet' => array(138, 43, 226), + 'purple' => array(160, 32, 240), + 'mediumpurple' => array(147, 112, 219), + 'thistle' => array(216, 191, 216), + 'snow1' => array(255, 250, 250), + 'snow2' => array(238, 233, 233), + 'snow3' => array(205, 201, 201), + 'snow4' => array(139, 137, 137), + 'seashell1' => array(255, 245, 238), + 'seashell2' => array(238, 229, 222), + 'seashell3' => array(205, 197, 191), + 'seashell4' => array(139, 134, 130), + 'AntiqueWhite1' => array(255, 239, 219), + 'AntiqueWhite2' => array(238, 223, 204), + 'AntiqueWhite3' => array(205, 192, 176), + 'AntiqueWhite4' => array(139, 131, 120), + 'bisque1' => array(255, 228, 196), + 'bisque2' => array(238, 213, 183), + 'bisque3' => array(205, 183, 158), + 'bisque4' => array(139, 125, 107), + 'peachPuff1' => array(255, 218, 185), + 'peachpuff2' => array(238, 203, 173), + 'peachpuff3' => array(205, 175, 149), + 'peachpuff4' => array(139, 119, 101), + 'navajowhite1' => array(255, 222, 173), + 'navajowhite2' => array(238, 207, 161), + 'navajowhite3' => array(205, 179, 139), + 'navajowhite4' => array(139, 121, 94), + 'lemonchiffon1' => array(255, 250, 205), + 'lemonchiffon2' => array(238, 233, 191), + 'lemonchiffon3' => array(205, 201, 165), + 'lemonchiffon4' => array(139, 137, 112), + 'ivory1' => array(255, 255, 240), + 'ivory2' => array(238, 238, 224), + 'ivory3' => array(205, 205, 193), + 'ivory4' => array(139, 139, 131), + 'honeydew' => array(193, 205, 193), + 'lavenderblush1' => array(255, 240, 245), + 'lavenderblush2' => array(238, 224, 229), + 'lavenderblush3' => array(205, 193, 197), + 'lavenderblush4' => array(139, 131, 134), + 'mistyrose1' => array(255, 228, 225), + 'mistyrose2' => array(238, 213, 210), + 'mistyrose3' => array(205, 183, 181), + 'mistyrose4' => array(139, 125, 123), + 'azure1' => array(240, 255, 255), + 'azure2' => array(224, 238, 238), + 'azure3' => array(193, 205, 205), + 'azure4' => array(131, 139, 139), + 'slateblue1' => array(131, 111, 255), + 'slateblue2' => array(122, 103, 238), + 'slateblue3' => array(105, 89, 205), + 'slateblue4' => array(71, 60, 139), + 'royalblue1' => array(72, 118, 255), + 'royalblue2' => array(67, 110, 238), + 'royalblue3' => array(58, 95, 205), + 'royalblue4' => array(39, 64, 139), + 'dodgerblue1' => array(30, 144, 255), + 'dodgerblue2' => array(28, 134, 238), + 'dodgerblue3' => array(24, 116, 205), + 'dodgerblue4' => array(16, 78, 139), + 'steelblue1' => array(99, 184, 255), + 'steelblue2' => array(92, 172, 238), + 'steelblue3' => array(79, 148, 205), + 'steelblue4' => array(54, 100, 139), + 'deepskyblue1' => array(0, 191, 255), + 'deepskyblue2' => array(0, 178, 238), + 'deepskyblue3' => array(0, 154, 205), + 'deepskyblue4' => array(0, 104, 139), + 'skyblue1' => array(135, 206, 255), + 'skyblue2' => array(126, 192, 238), + 'skyblue3' => array(108, 166, 205), + 'skyblue4' => array(74, 112, 139), + 'lightskyblue1' => array(176, 226, 255), + 'lightskyblue2' => array(164, 211, 238), + 'lightskyblue3' => array(141, 182, 205), + 'lightskyblue4' => array(96, 123, 139), + 'slategray1' => array(198, 226, 255), + 'slategray2' => array(185, 211, 238), + 'slategray3' => array(159, 182, 205), + 'slategray4' => array(108, 123, 139), + 'lightsteelblue1' => array(202, 225, 255), + 'lightsteelblue2' => array(188, 210, 238), + 'lightsteelblue3' => array(162, 181, 205), + 'lightsteelblue4' => array(110, 123, 139), + 'lightblue1' => array(191, 239, 255), + 'lightblue2' => array(178, 223, 238), + 'lightblue3' => array(154, 192, 205), + 'lightblue4' => array(104, 131, 139), + 'lightcyan1' => array(224, 255, 255), + 'lightcyan2' => array(209, 238, 238), + 'lightcyan3' => array(180, 205, 205), + 'lightcyan4' => array(122, 139, 139), + 'paleturquoise1' => array(187, 255, 255), + 'paleturquoise2' => array(174, 238, 238), + 'paleturquoise3' => array(150, 205, 205), + 'paleturquoise4' => array(102, 139, 139), + 'cadetblue1' => array(152, 245, 255), + 'cadetblue2' => array(142, 229, 238), + 'cadetblue3' => array(122, 197, 205), + 'cadetblue4' => array(83, 134, 139), + 'turquoise1' => array(0, 245, 255), + 'turquoise2' => array(0, 229, 238), + 'turquoise3' => array(0, 197, 205), + 'turquoise4' => array(0, 134, 139), + 'cyan1' => array(0, 255, 255), + 'cyan2' => array(0, 238, 238), + 'cyan3' => array(0, 205, 205), + 'cyan4' => array(0, 139, 139), + 'darkslategray1' => array(151, 255, 255), + 'darkslategray2' => array(141, 238, 238), + 'darkslategray3' => array(121, 205, 205), + 'darkslategray4' => array(82, 139, 139), + 'aquamarine1' => array(127, 255, 212), + 'aquamarine2' => array(118, 238, 198), + 'aquamarine3' => array(102, 205, 170), + 'aquamarine4' => array(69, 139, 116), + 'darkseagreen1' => array(193, 255, 193), + 'darkseagreen2' => array(180, 238, 180), + 'darkseagreen3' => array(155, 205, 155), + 'darkseagreen4' => array(105, 139, 105), + 'seagreen1' => array(84, 255, 159), + 'seagreen2' => array(78, 238, 148), + 'seagreen3' => array(67, 205, 128), + 'seagreen4' => array(46, 139, 87), + 'palegreen1' => array(154, 255, 154), + 'palegreen2' => array(144, 238, 144), + 'palegreen3' => array(124, 205, 124), + 'palegreen4' => array(84, 139, 84), + 'springgreen1' => array(0, 255, 127), + 'springgreen2' => array(0, 238, 118), + 'springgreen3' => array(0, 205, 102), + 'springgreen4' => array(0, 139, 69), + 'chartreuse1' => array(127, 255, 0), + 'chartreuse2' => array(118, 238, 0), + 'chartreuse3' => array(102, 205, 0), + 'chartreuse4' => array(69, 139, 0), + 'olivedrab1' => array(192, 255, 62), + 'olivedrab2' => array(179, 238, 58), + 'olivedrab3' => array(154, 205, 50), + 'olivedrab4' => array(105, 139, 34), + 'darkolivegreen1' => array(202, 255, 112), + 'darkolivegreen2' => array(188, 238, 104), + 'darkolivegreen3' => array(162, 205, 90), + 'darkolivegreen4' => array(110, 139, 61), + 'khaki1' => array(255, 246, 143), + 'khaki2' => array(238, 230, 133), + 'khaki3' => array(205, 198, 115), + 'khaki4' => array(139, 134, 78), + 'lightgoldenrod1' => array(255, 236, 139), + 'lightgoldenrod2' => array(238, 220, 130), + 'lightgoldenrod3' => array(205, 190, 112), + 'lightgoldenrod4' => array(139, 129, 76), + 'yellow1' => array(255, 255, 0), + 'yellow2' => array(238, 238, 0), + 'yellow3' => array(205, 205, 0), + 'yellow4' => array(139, 139, 0), + 'gold1' => array(255, 215, 0), + 'gold2' => array(238, 201, 0), + 'gold3' => array(205, 173, 0), + 'gold4' => array(139, 117, 0), + 'goldenrod1' => array(255, 193, 37), + 'goldenrod2' => array(238, 180, 34), + 'goldenrod3' => array(205, 155, 29), + 'goldenrod4' => array(139, 105, 20), + 'darkgoldenrod1' => array(255, 185, 15), + 'darkgoldenrod2' => array(238, 173, 14), + 'darkgoldenrod3' => array(205, 149, 12), + 'darkgoldenrod4' => array(139, 101, 8), + 'rosybrown1' => array(255, 193, 193), + 'rosybrown2' => array(238, 180, 180), + 'rosybrown3' => array(205, 155, 155), + 'rosybrown4' => array(139, 105, 105), + 'indianred1' => array(255, 106, 106), + 'indianred2' => array(238, 99, 99), + 'indianred3' => array(205, 85, 85), + 'indianred4' => array(139, 58, 58), + 'sienna1' => array(255, 130, 71), + 'sienna2' => array(238, 121, 66), + 'sienna3' => array(205, 104, 57), + 'sienna4' => array(139, 71, 38), + 'burlywood1' => array(255, 211, 155), + 'burlywood2' => array(238, 197, 145), + 'burlywood3' => array(205, 170, 125), + 'burlywood4' => array(139, 115, 85), + 'wheat1' => array(255, 231, 186), + 'wheat2' => array(238, 216, 174), + 'wheat3' => array(205, 186, 150), + 'wheat4' => array(139, 126, 102), + 'tan1' => array(255, 165, 79), + 'tan2' => array(238, 154, 73), + 'tan3' => array(205, 133, 63), + 'tan4' => array(139, 90, 43), + 'chocolate1' => array(255, 127, 36), + 'chocolate2' => array(238, 118, 33), + 'chocolate3' => array(205, 102, 29), + 'chocolate4' => array(139, 69, 19), + 'firebrick1' => array(255, 48, 48), + 'firebrick2' => array(238, 44, 44), + 'firebrick3' => array(205, 38, 38), + 'firebrick4' => array(139, 26, 26), + 'brown1' => array(255, 64, 64), + 'brown2' => array(238, 59, 59), + 'brown3' => array(205, 51, 51), + 'brown4' => array(139, 35, 35), + 'salmon1' => array(255, 140, 105), + 'salmon2' => array(238, 130, 98), + 'salmon3' => array(205, 112, 84), + 'salmon4' => array(139, 76, 57), + 'lightsalmon1' => array(255, 160, 122), + 'lightsalmon2' => array(238, 149, 114), + 'lightsalmon3' => array(205, 129, 98), + 'lightsalmon4' => array(139, 87, 66), + 'orange1' => array(255, 165, 0), + 'orange2' => array(238, 154, 0), + 'orange3' => array(205, 133, 0), + 'orange4' => array(139, 90, 0), + 'darkorange1' => array(255, 127, 0), + 'darkorange2' => array(238, 118, 0), + 'darkorange3' => array(205, 102, 0), + 'darkorange4' => array(139, 69, 0), + 'coral1' => array(255, 114, 86), + 'coral2' => array(238, 106, 80), + 'coral3' => array(205, 91, 69), + 'coral4' => array(139, 62, 47), + 'tomato1' => array(255, 99, 71), + 'tomato2' => array(238, 92, 66), + 'tomato3' => array(205, 79, 57), + 'tomato4' => array(139, 54, 38), + 'orangered1' => array(255, 69, 0), + 'orangered2' => array(238, 64, 0), + 'orangered3' => array(205, 55, 0), + 'orangered4' => array(139, 37, 0), + 'deeppink1' => array(255, 20, 147), + 'deeppink2' => array(238, 18, 137), + 'deeppink3' => array(205, 16, 118), + 'deeppink4' => array(139, 10, 80), + 'hotpink1' => array(255, 110, 180), + 'hotpink2' => array(238, 106, 167), + 'hotpink3' => array(205, 96, 144), + 'hotpink4' => array(139, 58, 98), + 'pink1' => array(255, 181, 197), + 'pink2' => array(238, 169, 184), + 'pink3' => array(205, 145, 158), + 'pink4' => array(139, 99, 108), + 'lightpink1' => array(255, 174, 185), + 'lightpink2' => array(238, 162, 173), + 'lightpink3' => array(205, 140, 149), + 'lightpink4' => array(139, 95, 101), + 'palevioletred1' => array(255, 130, 171), + 'palevioletred2' => array(238, 121, 159), + 'palevioletred3' => array(205, 104, 137), + 'palevioletred4' => array(139, 71, 93), + 'maroon1' => array(255, 52, 179), + 'maroon2' => array(238, 48, 167), + 'maroon3' => array(205, 41, 144), + 'maroon4' => array(139, 28, 98), + 'violetred1' => array(255, 62, 150), + 'violetred2' => array(238, 58, 140), + 'violetred3' => array(205, 50, 120), + 'violetred4' => array(139, 34, 82), + 'magenta1' => array(255, 0, 255), + 'magenta2' => array(238, 0, 238), + 'magenta3' => array(205, 0, 205), + 'magenta4' => array(139, 0, 139), + 'mediumred' => array(140, 34, 34), + 'orchid1' => array(255, 131, 250), + 'orchid2' => array(238, 122, 233), + 'orchid3' => array(205, 105, 201), + 'orchid4' => array(139, 71, 137), + 'plum1' => array(255, 187, 255), + 'plum2' => array(238, 174, 238), + 'plum3' => array(205, 150, 205), + 'plum4' => array(139, 102, 139), + 'mediumorchid1' => array(224, 102, 255), + 'mediumorchid2' => array(209, 95, 238), + 'mediumorchid3' => array(180, 82, 205), + 'mediumorchid4' => array(122, 55, 139), + 'darkorchid1' => array(191, 62, 255), + 'darkorchid2' => array(178, 58, 238), + 'darkorchid3' => array(154, 50, 205), + 'darkorchid4' => array(104, 34, 139), + 'purple1' => array(155, 48, 255), + 'purple2' => array(145, 44, 238), + 'purple3' => array(125, 38, 205), + 'purple4' => array(85, 26, 139), + 'mediumpurple1' => array(171, 130, 255), + 'mediumpurple2' => array(159, 121, 238), + 'mediumpurple3' => array(137, 104, 205), + 'mediumpurple4' => array(93, 71, 139), + 'thistle1' => array(255, 225, 255), + 'thistle2' => array(238, 210, 238), + 'thistle3' => array(205, 181, 205), + 'thistle4' => array(139, 123, 139), + 'gray1' => array(10, 10, 10), + 'gray2' => array(40, 40, 30), + 'gray3' => array(70, 70, 70), + 'gray4' => array(100, 100, 100), + 'gray5' => array(130, 130, 130), + 'gray6' => array(160, 160, 160), + 'gray7' => array(190, 190, 190), + 'gray8' => array(210, 210, 210), + 'gray9' => array(240, 240, 240), + 'darkgray' => array(100, 100, 100), + 'darkblue' => array(0, 0, 139), + 'darkcyan' => array(0, 139, 139), + 'darkmagenta' => array(139, 0, 139), + 'darkred' => array(139, 0, 0), + 'silver' => array(192, 192, 192), + 'eggplant' => array(144, 176, 168), + 'lightgreen' => array(144, 238, 144) +); diff --git a/framework/Image/lib/Horde/Image/svg.php b/framework/Image/lib/Horde/Image/svg.php new file mode 100644 index 000000000..73a8ed769 --- /dev/null +++ b/framework/Image/lib/Horde/Image/svg.php @@ -0,0 +1,338 @@ + + * @package Horde_Image + */ +class Horde_Image_svg extends Horde_Image +{ + protected $_svg; + + /** + * Capabilites of this driver. + * + * @var array + */ + protected $_capabilities = array('canvas'); + + public function __construct($params) + { + parent::__construct($params); + $this->_svg = new XML_SVG_Document(array('width' => $this->_width, + 'height' => $this->_height)); + } + + public function getContentType() + { + return 'image/svg+xml'; + } + + public function display() + { + $this->_svg->printElement(); + } + + /** + * Return the raw data for this image. + * + * @return string The raw image data. + */ + public function raw() + { + return $this->_svg->bufferObject(); + } + + private function _createSymbol($s, $id) + { + $s->setParam('id', $id); + $defs = new XML_SVG_Defs(); + $defs->addChild($s); + $this->_svg->addChild($defs); + } + + private function _createDropShadow($id = 'dropShadow') + { + $defs = new XML_SVG_Defs(); + $filter = new XML_SVG_Filter(array('id' => $id)); + $filter->addPrimitive('GaussianBlur', array('in' => 'SourceAlpha', + 'stdDeviation' => 2, + 'result' => 'blur')); + $filter->addPrimitive('Offset', array('in' => 'blur', + 'dx' => 4, + 'dy' => 4, + 'result' => 'offsetBlur')); + $merge = new XML_SVG_FilterPrimitive('Merge'); + $merge->addMergeNode('offsetBlur'); + $merge->addMergeNode('SourceGraphic'); + + $filter->addChild($merge); + $defs->addChild($filter); + $this->_svg->addChild($defs); + } + + /** + * Draws a text string on the image in a specified location, with + * the specified style information. + * + * @param string $text The text to draw. + * @param integer $x The left x coordinate of the start of the text string. + * @param integer $y The top y coordinate of the start of the text string. + * @param string $font The font identifier you want to use for the text. + * @param string $color The color that you want the text displayed in. + * @param integer $direction An integer that specifies the orientation of the text. + */ + public function text($string, $x, $y, $font = 'monospace', $color = 'black', $direction = 0) + { + $height = 12; + $style = 'font-family:' . $font . ';font-height:' . $height . 'px;fill:' . $this->getHexColor($color) . ';text-anchor:start;'; + $transform = 'rotate(' . $direction . ',' . $x . ',' . $y . ')'; + $this->_svg->addChild(new XML_SVG_Text(array('text' => $string, + 'x' => (int)$x, + 'y' => (int)$y + $height, + 'transform' => $transform, + 'style' => $style))); + } + + /** + * Draw a circle. + * + * @param integer $x The x coordinate of the centre. + * @param integer $y The y coordinate of the centre. + * @param integer $r The radius of the circle. + * @param string $color The line color of the circle. + * @param string $fill The color to fill the circle. + */ + public function circle($x, $y, $r, $color, $fill = null) + { + if (!empty($fill)) { + $style = 'fill:' . $this->getHexColor($fill) . '; '; + } else { + $style = 'fill:none;'; + } + $style .= 'stroke:' . $this->getHexColor($color) . '; stroke-width:1'; + + $this->_svg->addChild(new XML_SVG_Circle(array('cx' => $x, + 'cy' => $y, + 'r' => $r, + 'style' => $style))); + } + + /** + * Draw a polygon based on a set of vertices. + * + * @param array $vertices An array of x and y labeled arrays + * (eg. $vertices[0]['x'], $vertices[0]['y'], ...). + * @param string $color The color you want to draw the polygon with. + * @param string $fill The color to fill the polygon. + */ + public function polygon($verts, $color, $fill = null) + { + if (!empty($fill)) { + $style = 'fill:' . $this->getHexColor($fill) . '; '; + } else { + $style = 'fill:none;'; + } + $style .= 'stroke:' . $this->getHexColor($color) . '; stroke-width:1'; + + $points = ''; + foreach ($verts as $v) { + $points .= $v['x'] . ',' . $v['y'] . ' '; + } + $points = trim($points); + + $this->_svg->addChild(new XML_SVG_Polygon(array('points' => $points, + 'style' => $style))); + } + + /** + * Draw a rectangle. + * + * @param integer $x The left x-coordinate of the rectangle. + * @param integer $y The top y-coordinate of the rectangle. + * @param integer $width The width of the rectangle. + * @param integer $height The height of the rectangle. + * @param string $color The line color of the rectangle. + * @param string $fill The color to fill the rectangle. + */ + public function rectangle($x, $y, $width, $height, $color, $fill = null) + { + if (!empty($fill)) { + $style = 'fill:' . $this->getHexColor($fill) . '; '; + } else { + $style = 'fill:none;'; + } + $style .= 'stroke:' . $this->getHexColor($color) . '; stroke-width:1'; + + $this->_svg->addChild(new XML_SVG_Rect(array('x' => $x, + 'y' => $y, + 'width' => $width, + 'height' => $height, + 'style' => $style))); + } + + /** + * Draw a rectangle. + * + * @param integer $x The left x-coordinate of the rectangle. + * @param integer $y The top y-coordinate of the rectangle. + * @param integer $width The width of the rectangle. + * @param integer $height The height of the rectangle. + * @param integer $round The width of the corner rounding. + * @param string $color The line color of the rectangle. + * @param string $fill The color to fill the rectangle. + */ + public function roundedRectangle($x, $y, $width, $height, $round, $color, $fill) + { + if (!empty($fill)) { + $style = 'fill:' . $this->getHexColor($fill) . '; '; + } else { + $style = 'fill:none;'; + } + $style .= 'stroke:' . $this->getHexColor($color) . '; stroke-width:1'; + + $this->_svg->addChild(new XML_SVG_Rect(array('x' => $x, + 'y' => $y, + 'rx' => $round, + 'ry' => $round, + 'width' => $width, + 'height' => $height, + 'style' => $style))); + } + + /** + * Draw a line. + * + * @param integer $x0 The x coordinate of the start. + * @param integer $y0 The y coordinate of the start. + * @param integer $x1 The x coordinate of the end. + * @param integer $y1 The y coordinate of the end. + * @param string $color The line color. + * @param string $width The width of the line. + */ + public function line($x1, $y1, $x2, $y2, $color = 'black', $width = 1) + { + $style = 'stroke:' . $this->getHexColor($color) . '; stroke-width:' . (int)$width; + $this->_svg->addChild(new XML_SVG_Line(array('x1' => $x1, + 'y1' => $y1, + 'x2' => $x2, + 'y2' => $y2, + 'style' => $style))); + } + + /** + * Draw a dashed line. + * + * @param integer $x0 The x coordinate of the start. + * @param integer $y0 The y coordinate of the start. + * @param integer $x1 The x coordinate of the end. + * @param integer $y1 The y coordinate of the end. + * @param string $color The line color. + * @param string $width The width of the line. + * @param integer $dash_length The length of a dash on the dashed line + * @param integer $dash_space The length of a space in the dashed line + */ + public function dashedLine($x1, $y1, $x2, $y2, $color = 'black', $width = 1, $dash_length = 2, $dash_space = 2) + { + $style = 'stroke:' . $this->getHexColor($color) . '; stroke-width:' . (int)$width . '; stroke-dasharray:' . $dash_length . ',' . $dash_space . ';'; + $this->_svg->addChild(new XML_SVG_Line(array('x1' => $x1, + 'y1' => $y1, + 'x2' => $x2, + 'y2' => $y2, + 'style' => $style))); + } + + /** + * Draw a polyline (a non-closed, non-filled polygon) based on a + * set of vertices. + * + * @param array $vertices An array of x and y labeled arrays + * (eg. $vertices[0]['x'], $vertices[0]['y'], ...). + * @param string $color The color you want to draw the line with. + * @param string $width The width of the line. + */ + public function polyline($verts, $color, $width = 1) + { + $style = 'stroke:' . $this->getHexColor($color) . '; stroke-width:' . $width . ';fill:none;'; + + // Calculate the path entry. + $path = ''; + + $first = true; + foreach ($verts as $vert) { + if ($first) { + $first = false; + $path .= 'M ' . $vert['x'] . ',' . $vert['y']; + } else { + $path .= ' L ' . $vert['x'] . ',' . $vert['y']; + } + } + + $this->_svg->addChild(new XML_SVG_Path(array('d' => $path, + 'style' => $style))); + } + + /** + * Draw an arc. + * + * @param integer $x The x coordinate of the centre. + * @param integer $y The y coordinate of the centre. + * @param integer $r The radius of the arc. + * @param integer $start The start angle of the arc. + * @param integer $end The end angle of the arc. + * @param string $color The line color of the arc. + * @param string $fill The fill color of the arc (defaults to none). + */ + public function arc($x, $y, $r, $start, $end, $color = 'black', $fill = null) + { + if (!empty($fill)) { + $style = 'fill:' . $this->getHexColor($fill) . '; '; + } else { + $style = 'fill:none;'; + } + $style .= 'stroke:' . $this->getHexColor($color) . '; stroke-width:1'; + + $mid = round(($start + $end) / 2); + + // Calculate the path entry. + $path = ''; + + // If filled, draw the outline. + if (!empty($fill)) { + // Start at the center of the ellipse the arc is on. + $path .= "M $x,$y "; + + // Draw out to ellipse edge. + list($arcX, $arcY) = $this->_circlePoint($start, $r * 2); + $path .= 'L ' . round($x + $arcX) . ',' . + round($y + $arcY) . ' '; + } + + // Draw arcs. + list($arcX, $arcY) = $this->_circlePoint($mid, $r * 2); + $path .= "A $r,$r 0 0 1 " . + round($x + $arcX) . ',' . + round($y + $arcY) . ' '; + + list($arcX, $arcY) = $this->_circlePoint($end, $r * 2); + $path .= "A $r,$r 0 0 1 " . + round($x + $arcX) . ',' . + round($y + $arcY) . ' '; + + // If filled, close the outline. + if (!empty($fill)) { + $path .= 'Z'; + } + + $path = trim($path); + + $this->_svg->addChild(new XML_SVG_Path(array('d' => $path, + 'style' => $style))); + } + +} \ No newline at end of file diff --git a/framework/Image/lib/Horde/Image/swf.php b/framework/Image/lib/Horde/Image/swf.php new file mode 100644 index 000000000..1cb5cb73f --- /dev/null +++ b/framework/Image/lib/Horde/Image/swf.php @@ -0,0 +1,532 @@ + + * @since Horde 3.0 + * @package Horde_Image + */ +class Horde_Image_swf extends Horde_Image { + + /** + * Capabilites of this driver. + * + * @var array + */ + var $_capabilities = array('canvas'); + + /** + * SWF root movie. + * + * @var resource + */ + var $_movie; + + function Horde_Image_swf($params) + { + parent::Horde_Image($params); + + $this->_movie = new SWFMovie(); + $this->_movie->setDimension($this->_width, $this->_height); + + // FIXME: honor the 'background' parameter here. + $this->_movie->setBackground(0xff, 0xff, 0xff); + $this->_movie->setRate(30); + } + + function getContentType() + { + return 'application/x-shockwave-flash'; + } + + /** + * Display the movie. + */ + function display() + { + $this->headers(); + $this->_movie->output(); + } + + /** + * Return the raw data for this image. + * + * @return string The raw image data. + */ + function raw() + { + ob_start(); + $this->_movie->output(); + $data = ob_get_contents(); + ob_end_clean(); + + return $data; + } + + /** + * Creates a color that can be accessed in this object. When a + * color is set, the rgba values are returned in an array. + * + * @param string $name The name of the color. + * + * @return array The red, green, blue, alpha values of the color. + */ + function allocateColor($name) + { + list($r, $g, $b) = $this->getRGB($name); + return array('red' => $r, + 'green' => $g, + 'blue' => $b, + 'alpha' => 255); + } + + function getFont($font) + { + switch ($font) { + case 'sans-serif': + return '_sans'; + + case 'serif': + return '_serif'; + + case 'monospace': + return '_typewriter'; + + default: + return $font; + } + } + + /** + * Draws a text string on the image in a specified location, with + * the specified style information. + * + * @param string $text The text to draw. + * @param integer $x The left x coordinate of the start of the text string. + * @param integer $y The top y coordinate of the start of the text string. + * @param string $font The font identifier you want to use for the text. + * @param string $color The color that you want the text displayed in. + * @param integer $direction An integer that specifies the orientation of the text. + */ + function text($string, $x, $y, $font = 'monospace', $color = 'black', $direction = 0) + { + $color = $this->allocateColor($color); + + if (!strncasecmp(PHP_OS, 'WIN', 3)) { + $text = new SWFTextField(SWFTEXTFIELD_NOEDIT); + } else { + $text = new SWFText(); + } + $text->setColor($color['red'], $color['green'], $color['blue'], $color['alpha']); + $text->addString($string); + $text->setFont(new SWFFont($this->getFont($font))); + + $t = $this->_movie->add($text); + $t->moveTo($x, $y); + $t->rotate($direction); + + return $t; + } + + /** + * Draw a circle. + * + * @param integer $x The x co-ordinate of the centre. + * @param integer $y The y co-ordinate of the centre. + * @param integer $r The radius of the circle. + * @param string $color The line color of the circle. + * @param string $fill The color to fill the circle. + */ + function circle($x, $y, $r, $color, $fill = 'none') + { + $s = new SWFShape(); + $color = $this->allocateColor($color); + $s->setLine(1, $color['red'], $color['green'], $color['blue'], $color['alpha']); + + if ($fill != 'none') { + $fillColor = $this->allocateColor($fill); + $f = $s->addFill($fillColor['red'], $fillColor['green'], $fillColor['blue'], $fillColor['alpha']); + $s->setRightFill($f); + } + + $a = $r * 0.414213562; // = tan(22.5 deg) + $b = $r * 0.707106781; // = sqrt(2)/2 = sin(45 deg) + + $s->movePenTo($x + $r, $y); + + $s->drawCurveTo($x + $r, $y - $a, $x + $b, $y - $b); + $s->drawCurveTo($x + $a, $y - $r, $x, $y - $r); + $s->drawCurveTo($x - $a, $y - $r, $x - $b, $y - $b); + $s->drawCurveTo($x - $r, $y - $a, $x - $r, $y); + $s->drawCurveTo($x - $r, $y + $a, $x - $b, $y + $b); + $s->drawCurveTo($x - $a, $y + $r, $x, $y + $r); + $s->drawCurveTo($x + $a, $y + $r, $x + $b, $y + $b); + $s->drawCurveTo($x + $r, $y + $a, $x + $r, $y); + + return $this->_movie->add($s); + } + + /** + * Draw a polygon based on a set of vertices. + * + * @param array $vertices An array of x and y labeled arrays + * (eg. $vertices[0]['x'], $vertices[0]['y'], ...). + * @param string $color The color you want to draw the polygon with. + * @param string $fill The color to fill the polygon. + */ + function polygon($verts, $color, $fill = 'none') + { + $color = $this->allocateColor($color); + + if (is_array($color) && is_array($verts) && (sizeof($verts) > 2)) { + $shape = new SWFShape(); + $shape->setLine(1, $color['red'], $color['green'], $color['blue'], $color['alpha']); + + if ($fill != 'none') { + $fillColor = $this->allocateColor($fill); + $f = $shape->addFill($fillColor['red'], $fillColor['green'], $fillColor['blue'], $fillColor['alpha']); + $shape->setRightFill($f); + } + + $first_done = false; + foreach ($verts as $value) { + if (!$first_done) { + $shape->movePenTo($value['x'], $value['y']); + $first_done = true; + $first_x = $value['x']; + $first_y = $value['y']; + } + $shape->drawLineTo($value['x'], $value['y']); + } + $shape->drawLineTo($first_x, $first_y); + + return $this->_movie->add($shape); + } else { + // If the color is an array and the vertices is a an array + // of more than 2 points. + return false; + } + } + + /** + * Draw a rectangle. + * + * @param integer $x The left x-coordinate of the rectangle. + * @param integer $y The top y-coordinate of the rectangle. + * @param integer $width The width of the rectangle. + * @param integer $height The height of the rectangle. + * @param string $color The line color of the rectangle. + * @param string $fill The color to fill the rectangle. + */ + function rectangle($x, $y, $width, $height, $color, $fill = 'none') + { + $verts[0] = array('x' => $x, 'y' => $y); + $verts[1] = array('x' => $x + $width, 'y' => $y); + $verts[2] = array('x' => $x + $width, 'y' => $y + $height); + $verts[3] = array('x' => $x, 'y' => $y + $height); + + return $this->polygon($verts, $color, $fill); + } + + /** + * Draw a rectangle. + * + * @param integer $x The left x-coordinate of the rectangle. + * @param integer $y The top y-coordinate of the rectangle. + * @param integer $width The width of the rectangle. + * @param integer $height The height of the rectangle. + * @param integer $round The width of the corner rounding. + * @param string $color The line color of the rectangle. + * @param string $fill The color to fill the rectangle. + */ + function roundedRectangle($x, $y, $width, $height, $round, $color = 'black', $fill = 'none') + { + if ($round <= 0) { + // Optimize out any calls with no corner rounding. + return $this->rectangle($x, $y, $width, $height, $color, $fill); + } + + $s = new SWFShape(); + $color = $this->allocateColor($color); + $s->setLine(1, $color['red'], $color['green'], $color['blue'], $color['alpha']); + + if ($fill != 'none') { + $fillColor = $this->allocateColor($fill); + $f = $s->addFill($fillColor['red'], $fillColor['green'], $fillColor['blue'], $fillColor['alpha']); + $s->setRightFill($f); + } + + // Set corner points to avoid lots of redundant math. + $x1 = $x + $round; + $y1 = $y + $round; + + $x2 = $x + $width - $round; + $y2 = $y + $round; + + $x3 = $x + $width - $round; + $y3 = $y + $height - $round; + + $x4 = $x + $round; + $y4 = $y + $height - $round; + + // Start in the upper left. + $p1 = $this->_arcPoints($round, 180, 225); + $p2 = $this->_arcPoints($round, 225, 270); + + // Start at the lower left corner of the top left curve. + $s->movePenTo($x1 + $p1['x1'], $y1 + $p1['y1']); + + // Draw the upper left corner. + $s->drawCurveTo($x1 + $p1['x3'], $y1 + $p1['y3'], $x1 + $p1['x2'], $y1 + $p1['y2']); + $s->drawCurveTo($x1 + $p2['x3'], $y1 + $p2['y3'], $x1 + $p2['x2'], $y1 + $p2['y2']); + + // Calculate the upper right points. + $p3 = $this->_arcPoints($round, 270, 315); + $p4 = $this->_arcPoints($round, 315, 360); + + // Connect the top left and right curves. + $s->drawLineTo($x2 + $p3['x1'], $y2 + $p3['y1']); + + // Draw the upper right corner. + $s->drawCurveTo($x2 + $p3['x3'], $y2 + $p3['y3'], $x2 + $p3['x2'], $y2 + $p3['y2']); + $s->drawCurveTo($x2 + $p4['x3'], $y2 + $p4['y3'], $x2 + $p4['x2'], $y2 + $p4['y2']); + + // Calculate the lower right points. + $p5 = $this->_arcPoints($round, 0, 45); + $p6 = $this->_arcPoints($round, 45, 90); + + // Connect the top right and lower right curves. + $s->drawLineTo($x3 + $p5['x1'], $y3 + $p5['y1']); + + // Draw the lower right corner. + $s->drawCurveTo($x3 + $p5['x3'], $y3 + $p5['y3'], $x3 + $p5['x2'], $y3 + $p5['y2']); + $s->drawCurveTo($x3 + $p6['x3'], $y3 + $p6['y3'], $x3 + $p6['x2'], $y3 + $p6['y2']); + + // Calculate the lower left points. + $p7 = $this->_arcPoints($round, 90, 135); + $p8 = $this->_arcPoints($round, 135, 180); + + // Connect the bottom right and bottom left curves. + $s->drawLineTo($x4 + $p7['x1'], $y4 + $p7['y1']); + + // Draw the lower left corner. + $s->drawCurveTo($x4 + $p7['x3'], $y4 + $p7['y3'], $x4 + $p7['x2'], $y4 + $p7['y2']); + $s->drawCurveTo($x4 + $p8['x3'], $y4 + $p8['y3'], $x4 + $p8['x2'], $y4 + $p8['y2']); + + // Close the shape. + $s->drawLineTo($x1 + $p1['x1'], $y1 + $p1['y1']); + + return $this->_movie->add($s); + } + + /** + * Draw a line. + * + * @param integer $x0 The x co-ordinate of the start. + * @param integer $y0 The y co-ordinate of the start. + * @param integer $x1 The x co-ordinate of the end. + * @param integer $y1 The y co-ordinate of the end. + * @param string $color The line color. + * @param string $width The width of the line. + */ + function line($x1, $y1, $x2, $y2, $color = 'black', $width = 1) + { + $color = $this->allocateColor($color); + + if (is_array($color)) { + $shape = new SWFShape(); + $shape->setLine($width, $color['red'], $color['green'], $color['blue'], $color['alpha']); + $shape->movePenTo($x1, $y1); + $shape->drawLineTo($x2, $y2); + + return $this->_movie->add($shape); + } else { + return false; + } + } + + /** + * Draw a dashed line. + * + * @param integer $x0 The x co-ordinate of the start. + * @param integer $y0 The y co-ordinate of the start. + * @param integer $x1 The x co-ordinate of the end. + * @param integer $y1 The y co-ordinate of the end. + * @param string $color The line color. + * @param string $width The width of the line. + * @param integer $dash_length The length of a dash on the dashed line + * @param integer $dash_space The length of a space in the dashed line + */ + function dashedLine($x0, $y0, $x1, $y1, $color = 'black', $width = 1, $dash_length = 2, $dash_space = 2) + { + // Get the length of the line in pixels. + $line_length = max(ceil(sqrt(pow(($x1 - $x0), 2) + pow(($y1 - $y0), 2))), 2); + + $cosTheta = ($x1 - $x0) / $line_length; + $sinTheta = ($y1 - $y0) / $line_length; + $lastx = $x0; + $lasty = $y0; + + // Draw the dashed line. + for ($i = 0; $i < $line_length; $i += ($dash_length + $dash_space)) { + $x = ($dash_length * $cosTheta) + $lastx; + $y = ($dash_length * $sinTheta) + $lasty; + + $this->line($lastx, $lasty, $x, $y, $color); + + $lastx = $x + ($dash_space * $cosTheta); + $lasty = $y + ($dash_space * $sinTheta); + } + } + + /** + * Draw a polyline (a non-closed, non-filled polygon) based on a + * set of vertices. + * + * @param array $vertices An array of x and y labeled arrays + * (eg. $vertices[0]['x'], $vertices[0]['y'], ...). + * @param string $color The color you want to draw the line with. + * @param string $width The width of the line. + */ + function polyline($verts, $color, $width = 1) + { + $color = $this->allocateColor($color); + + $shape = new SWFShape(); + $shape->setLine($width, $color['red'], $color['green'], $color['blue'], $color['alpha']); + + $first_done = false; + foreach ($verts as $value) { + if (!$first_done) { + $shape->movePenTo($value['x'], $value['y']); + $first_done = true; + } + $shape->drawLineTo($value['x'], $value['y']); + } + + return $this->_movie->add($shape); + } + + /** + * Draw an arc. + * + * @param integer $x The x co-ordinate of the centre. + * @param integer $y The y co-ordinate of the centre. + * @param integer $r The radius of the arc. + * @param integer $start The start angle of the arc. + * @param integer $end The end angle of the arc. + * @param string $color The line color of the arc. + * @param string $fill The fill color of the arc. + */ + function arc($x, $y, $r, $start, $end, $color = 'black', $fill = 'none') + { + $s = new SWFShape(); + $color = $this->allocateColor($color); + $s->setLine(1, $color['red'], $color['green'], $color['blue'], $color['alpha']); + + if ($fill != 'none') { + $fillColor = $this->allocateColor($fill); + $f = $s->addFill($fillColor['red'], $fillColor['green'], $fillColor['blue'], $fillColor['alpha']); + $s->setRightFill($f); + } + + if ($end - $start <= 45) { + $pts = $this->_arcPoints($r, $start, $end); + $s->movePenTo($x, $y); + $s->drawLineTo($pts['x1'] + $x, $pts['y1'] + $y); + $s->drawCurveTo($pts['x3'] + $x, $pts['y3'] + $y, $pts['x2'] + $x, $pts['y2'] + $y); + $s->drawLineTo($x, $y); + } else { + $sections = ceil(($end - $start) / 45); + for ($i = 0; $i < $sections; $i++) { + $pts = $this->_arcPoints($r, $start + ($i * 45), ($start + (($i + 1) * 45) > $end) + ? $end + : ($start + (($i + 1) * 45))); + + // If we are on the first section, move the pen to the + // centre and draw out to the edge. + if ($i == 0 && $fill != 'none') { + $s->movePenTo($x, $y); + $s->drawLineTo($pts['x1'] + $x, $pts['y1'] + $y); + } else { + $s->movePenTo($pts['x1'] + $x, $pts['y1'] + $y); + } + + // Draw the arc. + $s->drawCurveTo($pts['x3'] + $x, $pts['y3'] + $y, $pts['x2'] + $x, $pts['y2'] + $y); + } + + if ($fill != 'none') { + // Draw a line from the edge back to the centre to close + // off the segment. + $s->drawLineTo($x, $y); + } + } + + return $this->_movie->add($s); + } + + /** + * Draw a rectangle filled with a gradient from $color1 to + * $color2. + * + * @param integer $x The left x-coordinate of the rectangle. + * @param integer $y The top y-coordinate of the rectangle. + * @param integer $width The width of the rectangle. + * @param integer $height The height of the rectangle. + * @param string $color The outline color of the rectangle. + * @param string $fill1 The name of the start color for the gradient. + * @param string $fill2 The name of the end color for the gradient. + */ + function gradientRectangle($x, $y, $width, $height, $color = 'black', $fill1 = 'black', $fill2 = 'white') + { + $s = new SWFShape(); + + if ($color != 'none') { + $color = $this->allocateColor($color); + $s->setLine(1, $color['red'], $color['green'], $color['blue'], $color['alpha']); + } + + $fill1 = $this->allocateColor($fill1); + $fill2 = $this->allocateColor($fill2); + $gradient = new SWFGradient(); + $gradient->addEntry(0.0, $fill1['red'], $fill1['green'], $fill1['blue'], $fill1['alpha']); + $gradient->addEntry(1.0, $fill2['red'], $fill2['green'], $fill2['blue'], $fill2['alpha']); + + $f = $s->addFill($gradient, SWFFILL_LINEAR_GRADIENT); + $f->scaleTo($width / $this->_width); + $f->moveTo($x, $y); + $s->setRightFill($f); + + $verts[0] = array('x' => $x, 'y' => $y); + $verts[1] = array('x' => $x + $width, 'y' => $y); + $verts[2] = array('x' => $x + $width, 'y' => $y + $height); + $verts[3] = array('x' => $x, 'y' => $y + $height); + + $first_done = false; + foreach ($verts as $vert) { + if (!$first_done) { + $s->movePenTo($vert['x'], $vert['y']); + $first_done = true; + $first_x = $vert['x']; + $first_y = $vert['y']; + } + $s->drawLineTo($vert['x'], $vert['y']); + } + $s->drawLineTo($first_x, $first_y); + + return $this->_movie->add($s); + } + +} diff --git a/framework/Image/package.xml b/framework/Image/package.xml new file mode 100644 index 000000000..42a1c85f7 --- /dev/null +++ b/framework/Image/package.xml @@ -0,0 +1,146 @@ + + + Horde_Image + pear.horde.org + Horde Image API + This package provides an Image utility API, with backends for: +* GD +* GIF +* PNG +* SVG +* SWF +* ImageMagick convert command line tool +* Imagick Extension + + + Chuck Hagenbuch + chuck + chuck@horde.org + yes + + + Michael J. Rubinsky + mrubinsk + mrubinsk@horde.org + yes + + 2009-05-24 + + + 0.1.0 + 0.1.0 + + + alpha + alpha + + LGPL + Initial Horde 4 package + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5.2.0 + + + 1.5.0 + + + Util + pear.horde.org + + + + + XML_SVG + pear.php.net + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0.0.1 + 0.0.1 + + + alpha + alpha + + 2004-01-01 + LGPL + Initial release as a PEAR package + + + + \ No newline at end of file diff --git a/framework/Image/tests/.htaccess b/framework/Image/tests/.htaccess new file mode 100644 index 000000000..605d2f4ca --- /dev/null +++ b/framework/Image/tests/.htaccess @@ -0,0 +1 @@ +Allow from all diff --git a/framework/Image/tests/gd.php b/framework/Image/tests/gd.php new file mode 100644 index 000000000..d29ad1255 --- /dev/null +++ b/framework/Image/tests/gd.php @@ -0,0 +1,24 @@ + 400, 'width' => 400)); + +$image->rectangle(30, 30, 100, 60, 'black', 'yellow'); +$image->roundedRectangle(30, 30, 100, 60, 15, 'black', 'red'); +$image->circle(30, 30, 30, 'black', 'blue'); +$image->polygon(array(array('x' => 30, 'y' => 50), array('x' => 40, 'y' => 60), array('x' => 50, 'y' => 40)), 'green', 'green'); +$image->arc(100, 100, 100, 0, 70, 'black', 'green'); +$image->brush(100, 300, 'red', 'circle'); + +$image->line(0, 200, 500, 200, 'darkblue', 2); +$image->line(200, 200, 200, 500, 'darkblue', 2); + +$image->polyline(array(array('x' => 130, 'y' => 150), array('x' => 140, 'y' => 160), array('x' => 150, 'y' => 140)), 'black', 5); + +$image->text('Hello World', 100, 100, 'arial', 'purple'); + +$image->display(); diff --git a/framework/Image/tests/im.php b/framework/Image/tests/im.php new file mode 100644 index 000000000..46b5902c7 --- /dev/null +++ b/framework/Image/tests/im.php @@ -0,0 +1,337 @@ + tag on another page. Set the test parameter to one of the + * cases below. + * + * + * @package Horde_Image + */ +require_once dirname(__FILE__) . '/../../../lib/base.php'; + +$driver = Util::getFormData('driver', 'im'); +$test = Util::getFormData('test'); +switch ($test) { +case 'testInitialState': + // Solid blue background color - basically tests initial state of the + // Horde_Image object. + $image = getImageObject(array('height' => '200', + 'width' => '200', + 'background' => 'blue')); + $image->display(); + exit; + break; + +case 'testInitialStateAfterLoad': + // Test loading an image from file directly. + $image = getImageObject(array('filename' => 'img1.jpg')); + $image->display(); + break; + +case 'testResize': + $image = getImageObject(array('filename' => 'img2.jpg')); + $image->resize(150, 150); + $image->display(); + break; + +case 'testPrimitivesTransparentBG': + // Transparent PNG image with various primitives. + $image = getImageObject(array('height' => '200', + 'width' => '200', + 'background' => 'none')); + $image->rectangle(30, 30, 100, 60, 'black', 'yellow'); + $image->roundedRectangle(30, 30, 100, 60, 15, 'black', 'red'); + $image->circle(30, 30, 30, 'black', 'blue'); + $image->display(); + break; + +case 'testTransparentPrimitivesReversed': + // Transparent PNG image with various primitives. + // Circle should appear *under* the rectangles... + $image = getImageObject(array('height' => '200', + 'width' => '200', + 'background' => 'none')); + $image->circle(30, 30, 30, 'black', 'blue'); + $image->rectangle(30, 30, 100, 60, 'black', 'yellow'); + $image->roundedRectangle(30, 30, 100, 60, 15, 'black', 'red'); + $image->display(); + break; + +case 'testTransparentBGWithBorder': + // Same as above, but with border. + $image = getImageObject(array('height' => '200', + 'width' => '200', + 'background' => 'none')); + $image->rectangle(30, 30, 100, 60, 'black', 'yellow'); + $image->roundedRectangle(30, 30, 100, 60, 15, 'black', 'red'); + $image->circle(30, 30, 30, 'black', 'blue'); + $image->addEffect('border', array('bordercolor' => 'blue', + 'borderwidth' => 1)); + $image->display(); + break; + + +case 'testAnnotateImage': + $image = getImageObject(array('filename' => 'img1.jpg')); + $image->resize(300,300); + $image->text("Hello World", 1, 150, '', 'blue', 0, 'large'); + $image->display(); + break; + +case 'testPolylineCircleLineText': + // Various other primitives. Using different colors and strokewidths + // to make sure that they get reset after each call - so we don't + // inadvetantly apply a color/stroke/etc setting to a primitive + // further down the line... + $image = getImageObject(array('height' => '200', + 'width' => '200', + 'background' => 'none')); + // Pie slice. Black outline, green fill + $image->polygon(array(array('x' => 30, 'y' => 50), + array('x' => 40, 'y' => 60), + array('x' => 50, 'y' => 40)), + 'black', 'green'); + + // Yellow 'pizza slice' with blue outline + $image->arc(50, 50, 100, 0, 70, 'blue', 'yellow'); + + // Small red circle dot. + $image->brush(80, 150, 'red', 'circle'); + + // Thicker verticle green line + $image->line(5, 30, 5, 200, 'green', 5); + + //Thinner verticle blue line + $image->line(20, 60, 20, 200, 'blue', 2); + + // Yellow checkmark + $image->polyline(array(array('x' => 130, 'y' => 150), + array('x' => 140, 'y' => 160), + array('x' => 150, 'y' => 140)), + 'yellow', 4); + + $image->text('Hello World', 60, 10, 'Arial', 'black', 0, 'large'); + $image->display(); + break; + +case 'testRoundCorners': + // Tests resizing, and rounding corners with appropriate background maintained. + $image = getImageObject(array('filename' => 'img1.jpg')); + $image->resize(150,150); + $image->addEffect('round_corners', + array('border' => 2, + 'bordercolor' => '#333', + 'background' => 'none')); + $image->applyEffects(); + $image->display(); + break; +case 'testRoundCornersRedBG': + // Tests resizing, and rounding corners with appropriate background maintained. + $image = getImageObject(array('filename' => 'img1.jpg')); + $image->resize(150,150); + $image->addEffect('round_corners', + array('border' => 2, + 'bordercolor' => '#333', + 'background' => 'red')); + $image->applyEffects(); + $image->display(); + break; +case 'testRoundCornersDropShadowTransparentBG': + $image = getImageObject(array('filename' => 'img1.jpg')); + $image->resize(150,150); + $image->addEffect('round_corners', + array('border' => 2, + 'bordercolor' => '#333')); + $image->addEffect('drop_shadow', + array('background' => 'none', + 'padding' => 5, + 'distance' => 5, + 'fade' => 3)); + $image->display(); + break; + +case 'testRoundCornersDropShadowYellowBG': + $image = getImageObject(array('filename' => 'img1.jpg')); + $image->resize(150,150); + $image->addEffect('round_corners', + array('border' => 2, + 'bordercolor' => '#333')); + $image->addEffect('drop_shadow', + array('background' => 'yellow', + 'padding' => 5, + 'distance' => 5, + 'fade' => 3)); + $image->display(); + break; + +case 'testBorderedDropShadowTransparentBG': + $image = getImageObject(array('filename' => 'img1.jpg', + 'background' => 'none')); + $image->resize(150,150); + $image->addEffect('border', array('bordercolor' => '#333', 'borderwidth' => 1)); + $image->addEffect('drop_shadow', + array('background' => 'none', + 'padding' => 5, + 'distance' => '8', + 'fade' => 2)); + $image->display(); + break; + +case 'testBorderedDropShadowBlueBG': + $image = getImageObject(array('filename' => 'img1.jpg', + 'background' => 'none')); + $image->resize(150,150); + $image->addEffect('border', array('bordercolor' => '#333', 'borderwidth' => 1)); + $image->addEffect('drop_shadow', + array('background' => 'blue', + 'padding' => 5, + 'distance' => '8', + 'fade' => 2)); + $image->display(); + break; + +case 'testPolaroidTransparentBG': + $image = getImageObject(array('filename' => 'img1.jpg')); + $image->resize(150, 150); + $image->addEffect('polaroid_image', + array('background' => 'none', + 'padding' => 5)); + $image->display(); + break; + +case 'testPolaroidBlueBG': + $image = getImageObject(array('filename' => 'img1.jpg')); + $image->resize(150, 150); + $image->addEffect('polaroid_image', + array('background' => 'blue', + 'padding' => 5)); + $image->display(); + break; + +case 'testPlainstackTransparentBG': + $imgs = array(getImageObject(array('filename' => 'img1.jpg')), + getImageObject(array('filename' => 'img2.jpg')), + getImageObject(array('filename' => 'img3.jpg'))); + $baseImg = getImageObject(array('width' => 1, + 'height' => 1, + 'background' => 'none')); + + $baseImg->addEffect('photo_stack', + array('images' => $imgs, + 'resize_height' => 150, + 'padding' => 0, + 'background' => 'none', + 'type' => 'plain')); + $baseImg->applyEffects(); + $baseImg->display(); + break; + +case 'testPlainstackBlueBG': + $imgs = array(getImageObject(array('filename' => 'img1.jpg')), + getImageObject(array('filename' => 'img2.jpg')), + getImageObject(array('filename' => 'img3.jpg'))); + $baseImg = getImageObject(array('width' => 1, + 'height' => 1, + 'background' => 'none')); + + $baseImg->addEffect('photo_stack', + array('images' => $imgs, + 'resize_height' => 150, + 'padding' => 0, + 'background' => 'blue', + 'type' => 'plain')); + $baseImg->applyEffects(); + $baseImg->display(); + break; + +case 'testRoundstackTransparentBG': + $imgs = array(getImageObject(array('filename' => 'img1.jpg')), + getImageObject(array('filename' => 'img2.jpg')), + getImageObject(array('filename' => 'img3.jpg'))); + $baseImg = getImageObject(array('width' => 1, + 'height' => 1, + 'background' => 'none')); + + $baseImg->addEffect('photo_stack', + array('images' => $imgs, + 'resize_height' => 150, + 'padding' => 0, + 'background' => 'none', + 'type' => 'rounded')); + $baseImg->applyEffects(); + $baseImg->display(); + break; + +case 'testRoundstackBlueBG': + $imgs = array(getImageObject(array('filename' => 'img1.jpg')), + getImageObject(array('filename' => 'img2.jpg')), + getImageObject(array('filename' => 'img3.jpg'))); + $baseImg = getImageObject(array('width' => 1, + 'height' => 1, + 'background' => 'none')); + + $baseImg->addEffect('photo_stack', + array('images' => $imgs, + 'resize_height' => 150, + 'padding' => 0, + 'background' => 'blue', + 'type' => 'rounded')); + $baseImg->applyEffects(); + $baseImg->display(); + break; + +case 'testPolaroidstackTransparentBG': + $imgs = array(getImageObject(array('filename' => 'img1.jpg')), + getImageObject(array('filename' => 'img2.jpg')), + getImageObject(array('filename' => 'img3.jpg'))); + $baseImg = getImageObject(array('width' => 1, + 'height' => 1, + 'background' => 'none')); + + $baseImg->addEffect('photo_stack', + array('images' => $imgs, + 'resize_height' => 150, + 'padding' => 0, + 'background' => 'none', + 'type' => 'polaroid')); + $baseImg->applyEffects(); + $baseImg->display(); + break; + +case 'testPolaroidstackBlueBG': + $imgs = array(getImageObject(array('filename' => 'img1.jpg')), + getImageObject(array('filename' => 'img2.jpg')), + getImageObject(array('filename' => 'img3.jpg'))); + $baseImg = getImageObject(array('width' => 1, + 'height' => 1, + 'background' => 'none')); + + $baseImg->addEffect('photo_stack', + array('images' => $imgs, + 'resize_height' => 150, + 'padding' => 0, + 'background' => 'blue', + 'type' => 'polaroid')); + $baseImg->applyEffects(); + $baseImg->display(); + break; +} + +/** + * Obtain a Horde_Image object + * + * @param array $params Any additional parameters + * + * @return Horde_Image object | PEAR_Error + */ +function getImageObject($params = array()) +{ + global $conf; + + $context = array('tmpdir' => Horde::getTempDir()); + if (!empty($conf['image']['convert'])) { + $context['convert'] = $conf['image']['convert']; + } + $params['context'] = $context; + return Horde_Image::factory('im', $params); +} \ No newline at end of file diff --git a/framework/Image/tests/img1.jpg b/framework/Image/tests/img1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..f38c593bc5f88bb4f78b2092826258744463d407 GIT binary patch literal 33427 zcmb4KWlSARu)Vn3#oa0H?i6=-C~g;bcZ%x;E>_$r?(Qzdo#HM<3q||-{dvjz`DT;N zB$J#y*<`Z2XJ-Gd{oMs%D#*yo0HC0t0CN8Z;O{0t5&#GL&tU$W;o;!m5z!D45fBhD zQBaZ4urYD4ftWxb4n8R%4ju^}5J*H#L_$VRNlA%ANb`w?f{v7elHxxQC^&d{L&RLA9;X{1@gd$%eV zsvA0q|B=B{Qv^xuW6ARam1-2pWfl_uLhE?*8gfd}#9^OToAPM7&`b)pCM z&`y1dY<|i(a=HCXtYtTVc=^h%~gd*?w(Iym;PT9jTO2_zQUY3#iwyOFLkm zhmS2y@<`U$KI#(&X)dbWl5p}hF5aRtT`wJ#NMuTyeUz{?y~ORcmzQZAT2pH@%CpPC zf6oE6ezY$bhS`-QN+fH`W>tus(!9?o1yyXm)qC0nel2gcfo5RnlF+Q02Ef+T>(qwX zmFFe)G896nOFb`TQxIx7oolC5Pq9hW<+7H}%^ltN+G;;(YP@2PE+b8JmHcAQXa0hX zi^kkoDrU1*Z|5Za2y2nmoOniZ(a7eVe-@XhuL4Gtrs19|v7TWGrLG(nWT17g@RpbG z&mF%Rv_t1)W}m7sX`<@S!Jak+t`ej)Kjpic^_~Ft4e~hUGC0c(@-7)m9P~^L)qhmb zWQz#?csl#KG~2Z1%QO(5W(pk#X*=eC&Lefr3`a?^=G|V)AXrzV{MOp5cV3iPR;t?@ z+FF;Nh%mxzHVMBjvm&%lf;YF!l5K4)N2AYVdk#s|@bu^QALc!DUY$0?d0{@PWXS2* z;1`)u3T8%2;5OJ1E=z5aR}_NkFmBFY+7Ej!xnF5+U8W|Ls<=1{%bUE4hvU!7R;X$) z`Fy1grCvc#Q=XrPiyJ7Z>D^WB>;hMJ5tE_YB;fi87-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t-=lZxR}5UeqNigoN@Y^VofBL#hCI4Jv~KhGWMThuUO8H9H26pfx!c=8~p18vjvdk z{Jl9fP)nmeNjU8tR*0)Lj9bQVkde=~{cB@gK24pGKr$Szae_v})Q(R|=ac)RX#O%W zZ)cILA(J>FNC3e-3~iD6RecghI^rG%_~gz9qMUzIT?#2hn6}$Td4J)JKIg#^YBEc4 z=3P$kFjfIoV~Dbm#&eJ}l50NuNV2@}q}r|0G>;CeC7MK7h{8s!s(9x-p7`gbbE!Hm z8=V}5{k$-I98jjjGB?YTdN}TR??F4Ci`W3$7z7Wd4N^LBr%10Q{HA7PL`9NS8wN_R z1aXo`rP|-z*));H`^4duyw95*vONgxTeu|?o4L_#XOd;}7=UDu1`04Z#yG1mUR=fH z%N)!e84IHW$RnrptaQ!oqjG&~Q=e3o<+^5%$#)QtHYs7w2Vd5@?H5tFO&-!=w{yY? z;N$SW`Bcp$l_M;gV=pfyyt4~%11ps!dB;F~ed^AUqFCHp!#k@2>$_;i&`Inu?ODrR z4R&ZYl>#mnM;ld?e5g(i0sbFhLNu6)GYg4Sx`@e8fbAK;{51}3GV5rks#%F_pz|k` z`A-~J$N~3C2Ic^MAP)w(4;9GY52G%4^4t1Wye}zind_qv$s}{jByP&_&Rtj>6>Xpb zD@xMlZD&xL>iD6QE2}a_sALDO><&-8YTYX{i*8iPmKus#9r5YbjK%pZA0%TK;fEaO z>IH7Wa|tj*@G$=N52?j1lR z3}JvjaBCM*vWhu15RBkjkKK&>_om@nBPT}JhvX(ZD`Ki+k|?qW_8;bIZY7dKAuhnQ zvo1mC2Lm3J$hRhMlfd25JU?S`q{(pYF8J+bmpg&n$q-?jk6yKexRTCGqM$d+z$7my Q4^ORBE_!UvdQG4I+2--O?f?J) literal 0 HcmV?d00001 diff --git a/framework/Image/tests/img3.jpg b/framework/Image/tests/img3.jpg new file mode 100644 index 0000000000000000000000000000000000000000..0527559959b2796e7f106d289ae2418acf6b65df GIT binary patch literal 29123 zcmb4JgIA_swEp6kZQ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ic^MAP)w(4;9GY52G%4^4t1Wye}zind_qv$s}{jByP&_&Rtj>6>Xpb zD@xMlZD&xL>iD6QE2}a_sALDO><&-8YTYX{i*8iPmKus#9r5YbjK%pZA0%TK;fEaO z>IH7Wa|tj*@G$=N52?j1lR z3}JvjaBCM*vWhu15RBkjkKK&>_om@nBPT}JhvX(ZD`Ki+k|?qW_8;bIZY7dKAuhnQ zvo1mC2Lm3J$hRhMlfd25JU?S`q{(pYF8J+bmpg&n$q-?jk6yKexRTCGqM$d+z$7my Q4^ORBE_!UvdQG4I+2--O?f?J) literal 0 HcmV?d00001 diff --git a/framework/Image/tests/runtest.php b/framework/Image/tests/runtest.php new file mode 100644 index 000000000..ea21ec171 --- /dev/null +++ b/framework/Image/tests/runtest.php @@ -0,0 +1,44 @@ + 'Test initial state. Solid blue square', + 'testPrimitivesTransparentBG' => 'Transparent background, various primitives. Cirlce should be above the rectangles.', + 'testTransparentBGWithBorder' => 'Test transparent background with border preserving transparency.', + 'testTransparentPrimitivesReversed' => 'Test ordering of primitives. This should show the circle *below* the rectangles.', + 'testAnnotateImage' => 'Annotate Image with Hello World in center left', + 'testPolylineCircleLineText' => 'various other primitives, as well as state of stroke color, width etc...', + 'testRoundCorners' => 'Rounded corners with transparent background.', + 'testRoundCornersRedBG' => 'Rounded corners with red background.', + 'testRoundCornersDropShadowTransparentBG' => 'Rounded corners with a drop shadow on a transparent background.', + 'testRoundCornersDropShadowYellowBG' => 'Rounded corners, with a drop shadow on a yellow background', + 'testBorderedDropShadowTransparentBG' => 'Thumbnail with border and drop shadow over a transparent background.', + 'testBorderedDropShadowBlueBG' => 'Thumbnail with border, drop shadow over a blue background.', + 'testPolaroidTransparentBG' => 'Polaroid effect with transparent background.', + 'testPolaroidBlueBG' => 'Polaroid effect with blue background.', + 'testPlainstackTransparentBG' => 'Thumbnail stack on transparent background.', + 'testPlainstackBlueBG' => 'Thumbnail stack on a blue background.', + 'testRoundstackTransparentBG' => 'Thumbnail stack with rounded borders on a transparent background', + 'testRoundstackBlueBG' => 'Thumbnail stack, rounded corners on a blue background', + 'testPolaroidstackTransparentBG' => 'Polaroid stack on a transparent background.', + 'testPolaroidstackBlueBG' => 'Polaroid stack on a blue background', + //'testInitialStateAfterLoad' => 'Initial state after loading an existing image.', + 'testResize' => 'Test resize method.', +); +?> + + + Horde_Image Tests + + +'; +foreach ($allTests as $name => $description) { + echo '' . $description . '' . Horde::img('im.php?test=' . $name, '', '', '') . ''; +} +echo ''; +?> \ No newline at end of file diff --git a/framework/Image/tests/svg.php b/framework/Image/tests/svg.php new file mode 100644 index 000000000..af44b65a4 --- /dev/null +++ b/framework/Image/tests/svg.php @@ -0,0 +1,24 @@ + 400, 'width' => 400)); + +$image->rectangle(30, 30, 100, 60, 'black', 'yellow'); +$image->roundedRectangle(30, 30, 100, 60, 15, 'black', 'red'); +$image->circle(30, 30, 30, 'black', 'blue'); +$image->polygon(array(array('x' => 30, 'y' => 50), array('x' => 40, 'y' => 60), array('x' => 50, 'y' => 40)), 'green', 'green'); +$image->arc(100, 100, 100, 0, 70, 'black', 'green'); +$image->brush(100, 300, 'red', 'circle'); + +$image->line(0, 200, 500, 200, 'darkblue', 2); +$image->line(200, 200, 200, 500, 'darkblue', 2); + +$image->polyline(array(array('x' => 130, 'y' => 150), array('x' => 140, 'y' => 160), array('x' => 150, 'y' => 140)), 'black', 5); + +$image->text('Hello World', 100, 100, 'arial', 'purple'); + +$image->display(); diff --git a/framework/Image/tests/swf.php b/framework/Image/tests/swf.php new file mode 100644 index 000000000..5a50d59ff --- /dev/null +++ b/framework/Image/tests/swf.php @@ -0,0 +1,24 @@ + 400, 'width' => 400)); + +$image->rectangle(30, 30, 100, 60, 'black', 'yellow'); +$image->roundedRectangle(30, 30, 100, 60, 15, 'black', 'red'); +$image->circle(30, 30, 30, 'black', 'blue'); +$image->polygon(array(array('x' => 30, 'y' => 50), array('x' => 40, 'y' => 60), array('x' => 50, 'y' => 40)), 'green', 'green'); +$image->arc(100, 100, 100, 0, 70, 'black', 'green'); +$image->brush(100, 300, 'red', 'circle'); + +$image->line(0, 200, 500, 200, 'darkblue', 2); +$image->line(200, 200, 200, 500, 'darkblue', 2); + +$image->polyline(array(array('x' => 130, 'y' => 150), array('x' => 140, 'y' => 160), array('x' => 150, 'y' => 140)), 'black', 5); + +$image->text('Hello World', 100, 100, 'arial', 'purple'); + +$image->display(); diff --git a/imp/lib/Mime/Viewer/Images.php b/imp/lib/Mime/Viewer/Images.php index 21f7cf6df..82cec5e1d 100644 --- a/imp/lib/Mime/Viewer/Images.php +++ b/imp/lib/Mime/Viewer/Images.php @@ -258,12 +258,13 @@ EOD; protected function _getHordeImageOb($load) { $img = null; - $params = array('temp' => Horde::getTempdir()); - + //@TODO: Pass in a Horde_Logger in $context if desired. + $context = array('tmpdir' => Horde::getTempDir()); if (!empty($GLOBALS['conf']['image']['convert'])) { - $img = &Horde_Image::singleton('im', $params); + $context['convert'] = $GLOBALS['conf']['image']['convert']; + $img = Horde_Image::factory('im', array('context' => $context)); } elseif (Util::extensionExists('gd')) { - $img = &Horde_Image::singleton('gd', $params); + $img = Horde_Image::factory('gd', array('context' => $context)); } if (!$img || is_a($img, 'PEAR_Error')) { diff --git a/imp/lib/Mime/Viewer/Pdf.php b/imp/lib/Mime/Viewer/Pdf.php index a2e9a7492..cfc36642e 100644 --- a/imp/lib/Mime/Viewer/Pdf.php +++ b/imp/lib/Mime/Viewer/Pdf.php @@ -114,7 +114,8 @@ class IMP_Horde_Mime_Viewer_Pdf extends Horde_Mime_Viewer_Pdf return false; } - $img = &Horde_Image::singleton('im', array('temp' => Horde::getTempdir())); + $img = Horde_Image::factory('im', array('context' => array('tmpdir' => Horde::getTempdir(), + 'convert' => $GLOBALS['conf']['image']['convert']))); if (is_a($img, 'PEAR_Error')) { return false; } -- 2.11.0