Skip to content

Commit

Permalink
NEW: ImageMagick support
Browse files Browse the repository at this point in the history
Fixed issue causing the module to crash when using the ImagickBackend (fixes #24) (#37)
  • Loading branch information
UndefinedOffset authored and jonom committed Dec 13, 2016
1 parent cceda24 commit 9f3b2dd
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ SilverStripe 3.3+ (SS 3.1+ support available in earlier releases)

## To Do

* ImageMagick support (maybe already works - can anyone confirm?)
* Internationalisation
* Advanced cropping options and interfaces (may be an additional module)
* Auto detect focus point via Imagga API
Expand Down
3 changes: 3 additions & 0 deletions _config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ After: 'framework/*','cms/*'
Image:
extensions:
- FocusPointImage

# Injector:
# ImagickBackend:
# class: "FPImagickBackend"
# Image:
# class: FPImage
18 changes: 18 additions & 0 deletions code/FPImagickBackend.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
class FPImagickBackend extends ImagickBackend {
/**
* Crop's part of image.
* @param top y position of left upper corner of crop rectangle
* @param left x position of left upper corner of crop rectangle
* @param width rectangle width
* @param height rectangle height
* @return ImagickBackend
*/
public function crop($top, $left, $width, $height) {
$new = clone $this;
$new->cropImage($width, $height, $left, $top);

return $new;
}
}
?>
10 changes: 10 additions & 0 deletions docs/en/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,13 @@ See the [packagist listing](https://packagist.org/packages/jonom/focuspoint) and
### Manually

I promise it's worth your time to learn how to use Composer. If painless updating isn't your thing though you can download and extract this project, rename the module folder 'focuspoint', place it in your project root and run a dev/build?flush=1.


### Using Focus Point with ImageMagick

If you are using the ImageMagick you must use [injector](https://docs.silverstripe.org/en/developer_guides/extending/injector/) to replace the ImagickBackend with the wrapper FPImagickBackend for compatibility using the below:
```yml
Injector:
ImagickBackend:
class: "FPImagickBackend"
```

0 comments on commit 9f3b2dd

Please sign in to comment.