Created
November 10, 2016 22:36
-
-
Save bummzack/9fbd40e887749083c07c9b8556cd23f5 to your computer and use it in GitHub Desktop.
Image magick SilverStripe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
Only: | |
classexists: 'Imagick' | |
--- | |
Image: | |
backend: 'FixedImagickBackend' | |
ImagickBackend: | |
default_quality: 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add missing "crop" method to ImagickBackend, so that it works with the focuspoint module | |
*/ | |
if(class_exists('Imagick')) { | |
class FixedImagickBackend extends ImagickBackend | |
{ | |
public function crop($top, $left, $width, $height) | |
{ | |
if (!$this->valid()) { | |
return; | |
} | |
$new = clone $this; | |
$new->setBackgroundColor(new ImagickPixel('transparent')); | |
$new->cropImage($width, $height, $left, $top); | |
return $new; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment