Page 1 of 2

Cropping larger images breaks imagick.

Posted: 2014-02-20T12:09:11-07:00
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!

Re: Cropping larger images breaks imagick.

Posted: 2014-02-20T13:08:51-07:00
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.

Re: Cropping larger images breaks imagick.

Posted: 2014-02-20T13:40:13-07:00
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

Re: Cropping larger images breaks imagick.

Posted: 2014-02-20T13:41:32-07:00
by eleison
Does isp limit filesizes btw? :O

Re: Cropping larger images breaks imagick.

Posted: 2014-02-20T13:49:57-07:00
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.

Re: Cropping larger images breaks imagick.

Posted: 2014-02-20T13:54:03-07:00
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?

Re: Cropping larger images breaks imagick.

Posted: 2014-02-20T14:14:33-07:00
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!

Re: Cropping larger images breaks imagick.

Posted: 2014-02-20T14:30:22-07:00
by eleison
Thanks for taking your time try help me :) Does imagemagick got any memory or "limit" settings in itself?

Re: Cropping larger images breaks imagick.

Posted: 2014-02-20T14:39:05-07:00
by fmw42

Re: Cropping larger images breaks imagick.

Posted: 2014-02-20T14:48:29-07:00
by eleison
Enough space and open permissions is no problem.

How do i use these commands in imagick?

Re: Cropping larger images breaks imagick.

Posted: 2014-02-20T14:55:44-07:00
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?

Re: Cropping larger images breaks imagick.

Posted: 2014-02-20T15:04:48-07:00
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.. :(

Re: Cropping larger images breaks imagick.

Posted: 2014-02-20T15:13:55-07:00
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

Re: Cropping larger images breaks imagick.

Posted: 2014-02-20T15:14:13-07:00
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

Re: Cropping larger images breaks imagick.

Posted: 2014-02-20T15:16:42-07:00
by eleison
So how do I update? :/