Skip to content

Commit

Permalink
Add imageProcessor in options, for optional switch from GD to ImageMa…
Browse files Browse the repository at this point in the history
…gick or GMagick
  • Loading branch information
addfs committed Apr 12, 2013
1 parent e6a2c5f commit 456ac4c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
16 changes: 13 additions & 3 deletions src/Munee/Asset/Filter/Image/Resize.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion src/Munee/Asset/Type/Image.php
Expand Up @@ -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;
Expand Down

0 comments on commit 456ac4c

Please sign in to comment.