I’m looking to center crop and image using Imagick PHP apis (not command line version of Imagick).
Essentially I want to do what is possible via command line, using API. Here is an example via command line:
http://www.imagemagick.org/Usage/crop/#crop_gravity
Here is what I’m doing (not working). It always crops the upper left corner of the source:
$this->imagickObj->setGravity(\Imagick::GRAVITY_CENTER);
$this->imagickObj->cropImage(300,250,0,0);
$this->imagickObj->setImagePage(0, 0, 0, 0);
Why is the setGravity not applying to the image before the crop? http://www.php.net/manual/en/function.imagick-setgravity.php says it should apply to the object (in this case the single image)…
Looks like there is not support, here is how I ended up doing it:
https://gist.github.com/1364489