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)...
Its too late for the original person who asked the question but for future visitors, correct solution is
bool Imagick::cropThumbnailImage ( int $width , int $height )
Sorry for late reply but I too stuck here just 30 mins ago and first google result redirected me here. Hope same will not happen with others.
Looks like there is not support, here is how I ended up doing it: https://gist.github.com/1364489
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With