Cropping larger images breaks imagick.

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Cropping larger images breaks imagick.

Post by Bonzo »

Yes I think that is the standard version for Linux.

Code: Select all

$input = $_SERVER['DOCUMENT_ROOT']."/orginal_53064950710a4.jpg";
exec("convert $input -crop 5000,3000+0+0 output.jpg");
That version should work OK for what you want to do.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Cropping larger images breaks imagick.

Post by Bonzo »

So how do I update? :/
That is one of the cockups I was talking about earlier; I managed to corrupt the Imagemagick install totally. I have done it on other servers without a problem but something just went wrong last time :?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Cropping larger images breaks imagick.

Post by fmw42 »

What version of Imagick are you using? check your phpinfo.php Perhaps you are using a too old version of Imagick also. see http://pecl.php.net/package/imagick

Is this your own personal server/computer or on a shared host? If the latter, you may have a hard time getting them to upgrade anything.
eleison
Posts: 45
Joined: 2013-12-10T15:14:46-07:00
Authentication code: 6789

Re: Cropping larger images breaks imagick.

Post by eleison »

fmw42 wrote:What version of Imagick are you using? check your phpinfo.php Perhaps you are using a too old version of Imagick also. see http://pecl.php.net/package/imagick

Is this your own personal server/computer or on a shared host? If the latter, you may have a hard time getting them to upgrade anything.
Its a VPS, my friend is owning the server, I will move to a newer and better server in the future. My imagick version is: 3.1.2. How much memory should an imagemagick crop function eat?? If I got memory issues only by testing the function my self, wouldn't there be even more problems when multiple users using the function in a live environment?

Thanks for all help!
eleison
Posts: 45
Joined: 2013-12-10T15:14:46-07:00
Authentication code: 6789

Re: Cropping larger images breaks imagick.

Post by eleison »

I finally got it to display:
Fatal error: Uncaught exception 'ImagickException' with message 'Insufficient memory (case 4) `

:O
eleison
Posts: 45
Joined: 2013-12-10T15:14:46-07:00
Authentication code: 6789

Re: Cropping larger images breaks imagick.

Post by eleison »

Ok, it's working now :)

Solution:
// pixel cache max size
IMagick::setResourceLimit(imagick::RESOURCETYPE_MEMORY, 64);
// maximum amount of memory map to allocate for the pixel cache
IMagick::setResourceLimit(imagick::RESOURCETYPE_MAP, 64);


Found answer here:
http://sourceforge.net/apps/trac/gallery/ticket/1513

And here:
http://stackoverflow.com/questions/4367 ... rge-images

Btw: How i debuged was:
1. Edit in php.ini:
log_errors = Off -> log_errors = On

2. Put this in start of your php code:
error_reporting(E_ALL);

Thanks everyone for taking your time :)
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Cropping larger images breaks imagick.

Post by Bonzo »

Thanks for the update eleison and I am glad it is now sorted.
Post Reply