Permalink
Browse files

Add imageProcessor in options, for optional switch from GD to ImageMa…

…gick or GMagick
  • Loading branch information...
addfs committed Apr 12, 2013
1 parent e6a2c5f commit 456ac4c34e19ba4d7dac418ce9a9028c1bc43d96
Showing with 15 additions and 4 deletions.
  1. +13 −3 src/Munee/Asset/Filter/Image/Resize.php
  2. +2 −1 src/Munee/Asset/Type/Image.php
@@ -10,7 +10,6 @@
use Munee\Asset\Filter;
use Munee\ErrorException;
use Imagine\Gd\Imagine;
use Imagine\Image\ImageInterface;
use Imagine\Image\Box;
use Imagine\Image\Color;
@@ -99,8 +98,19 @@ public function doFilter($originalImage, $arguments, $imageOptions)
if (empty($arguments['height']) && empty($arguments['width'])) {
throw new ErrorException('You must set at least the height (h) or the width (w)');
}
$Imagine = new Imagine();
switch (strtolower($imageOptions['imageProcessor'])) {
case 'gd':
$Imagine = new \Imagine\Gd\Imagine();
break;
case 'imagick':
$Imagine = new \Imagine\Imagick\Imagine();
break;
case 'gmagick':
$Imagine = new \Imagine\Gmagick\Imagine();
break;
default:
throw new ErrorException('Unsupported imageProcessor config value: ' . $imageOptions['imageProcessor']);
}
$image = $Imagine->open($originalImage);
$size = $image->getSize();
@@ -32,7 +32,8 @@ class Image extends Type
// Use a placeholder for missing images?
'placeholders' => false,
'maxAllowedResizeWidth' => 1920,
'maxAllowedResizeHeight' => 1080
'maxAllowedResizeHeight' => 1080,
'imageProcessor' => "GD"
);
protected $_placeholder = false;

0 comments on commit 456ac4c

Please sign in to comment.