Skip to content

Instantly share code, notes, and snippets.

@bummzack
Created November 10, 2016 22:36
Show Gist options
  • Save bummzack/9fbd40e887749083c07c9b8556cd23f5 to your computer and use it in GitHub Desktop.
Save bummzack/9fbd40e887749083c07c9b8556cd23f5 to your computer and use it in GitHub Desktop.
Image magick SilverStripe
---
Only:
classexists: 'Imagick'
---
Image:
backend: 'FixedImagickBackend'
ImagickBackend:
default_quality: 80
<?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