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.
eleison
Posts: 45
Joined: 2013-12-10T15:14:46-07:00
Authentication code: 6789

Cropping larger images breaks imagick.

Post by eleison »

I been trying to solve a bug / problem for several hours now. And i can't figure out whats wrong.
I'm using an ajax call to send dynamic crop values (width, height, x, y) to a php script. When user submits a small cropping area everything works fine, imagick returns the correct image.
But the larger the cropping area is the greater the chance that php script stops at "$picture->writeImage($outFile);" in my tmp folder where the croped image is saved there spawns an image file with no information in it.

To make it simple i replaced the dynamic cropping values with just static values, to see that nothing else is interfering...
I don't know how to debug whats going wrong, and why larger areas of cropping makes it crash.

The images users inputs could be large image files, my test image is 12,3 MB and 5616 x 3338.
Im running CentOs, before I developed the function on my local computer with Windows 7 and Wamp-server. Before i moved over from local server everything worked.

Code: Select all

$picture = new Imagick($_SERVER['DOCUMENT_ROOT']."/orginal_53064950710a4.jpg");
$picture->cropImage( 5000,  3000,  0,  0);
$picture->writeImage($outFile);
$picture->clear();
$picture->destroy();
How do i find the problem? Can't find any imagick log files etc.
Any help is appreciated!!

Really been trying to find an solution for this :( Thanks for taking your time helping me!
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 »

Your ISP may be limiting the file sizes that can be used in Imagick. Also check your permissions on the directories where your input and output images reside.
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:Your ISP may be limiting the file sizes that can be used in Imagick. Also check your permissions on the directories where your input and output images reside.
Hum, I don't think that's the problem. Because sometimes it works and sometimes not. It's just the larger image crop the greater chance it won't work. Sometimes full size crop works, but not very often. :S
eleison
Posts: 45
Joined: 2013-12-10T15:14:46-07:00
Authentication code: 6789

Re: Cropping larger images breaks imagick.

Post by eleison »

Does isp limit filesizes btw? :O
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Cropping larger images breaks imagick.

Post by Bonzo »

Does isp limit filesizes btw? :O
If not file size it could be the file is using to much memory etc. I would talk to your hosts and see what they say.
eleison
Posts: 45
Joined: 2013-12-10T15:14:46-07:00
Authentication code: 6789

Re: Cropping larger images breaks imagick.

Post by eleison »

Bonzo wrote:
Does isp limit filesizes btw? :O
If not file size it could be the file is using to much memory etc. I would talk to your hosts and see what they say.
I got root on server... So what memory limit should i change?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Cropping larger images breaks imagick.

Post by Bonzo »

I got root on server... So what memory limit should i change?
I have no idea; if I get problems like this I ask the hosts and they usually change what needs changing.
I do not know how a server works I just use it; they are the professionals and its their job. I could easily cock something up; which I have done in the past!
eleison
Posts: 45
Joined: 2013-12-10T15:14:46-07:00
Authentication code: 6789

Re: Cropping larger images breaks imagick.

Post by eleison »

Thanks for taking your time try help me :) Does imagemagick got any memory or "limit" settings in itself?
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 »

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

Re: Cropping larger images breaks imagick.

Post by eleison »

Enough space and open permissions is no problem.

How do i use these commands in imagick?
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 »

How do i use these commands in imagick?
I don't think you can or they don't have equivalents. You export them to your PATH or put the export command in your .profile file for Imagemagick to use when called by Imagick

Have you tried your crop command using just PHP exec()? Do they work there?

Are you using the latest Imagick and Imagemagick?

Could it be just corrupt input files?
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:
How do i use these commands in imagick?
I don't think you can or they don't have equivalents. You export them to your PATH or put the export command in your .profile file for Imagemagick to use when called by Imagick

Have you tried your crop command using just PHP exec()? Do they work there?

Are you using the latest Imagick and Imagemagick?

Could it be just corrupt input files?
I recently installed imagemagick with yum command. Should be recent version, but how do i check?
I have tried it, but then I also get random results. I could try a little bit more though... The thing is that everything works great with smaller sized images :C, and all other commands working, its just cropImage n writeImage that hangs it.. :(
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Cropping larger images breaks imagick.

Post by Bonzo »

Should be recent version
Probably not!

Try this:

Code: Select all

<?php
echo "<pre>";
system("convert -version");  
echo "</pre>";
?> 
The latest version as of today is: 6.8.8-7
Last edited by Bonzo on 2014-02-20T15:14:57-07:00, edited 1 time in total.
eleison
Posts: 45
Joined: 2013-12-10T15:14:46-07:00
Authentication code: 6789

Re: Cropping larger images breaks imagick.

Post by eleison »

Version: ImageMagick 6.5.4-7 2012-05-07 Q16 OpenMP http://www.imagemagick.org
Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC
eleison
Posts: 45
Joined: 2013-12-10T15:14:46-07:00
Authentication code: 6789

Re: Cropping larger images breaks imagick.

Post by eleison »

So how do I update? :/
Post Reply