Page 1 of 1

Image conversion incomplete, grey results

Posted: 2013-01-10T08:46:00-07:00
by wwftdg
Converting some images via a cron task on our servers, but some of the images do not finish, end up with grey backgrounds. Usually, 2/10 images will not convert correctly. Any ideas whats the problem?

Image

code sample:

Code: Select all

convert $source -limit memory 1 -limit map 1 -thumbnail x800\> -bordercolor white -border 0 -gravity center -crop x800+0+0 +repage -strip -quality 90 -profile $rgbProfile $thumb

IM Version: ImageMagick 6.8.1-2 2012-12-24 Q16

Re: Image conversion incomplete, grey results

Posted: 2013-01-10T09:38:37-07:00
by magick
Check your temporary disk space, are you running out of free space? You can change the temporary disk space path with MAGICK_TMPDIR environment variable or the -define registry:temporary-path=/data/tmp command line.

Re: Image conversion incomplete, grey results

Posted: 2013-01-10T18:48:58-07:00
by wwftdg
Will try, how do I set my own custom /tmp directory preference for ImageMagick?

Re: Image conversion incomplete, grey results

Posted: 2013-01-16T23:28:44-07:00
by wwftdg
Ok I updated the configure.xml file with the following items:

<configure name="MAGICK_TEMPORARY_PATH" value="/tmp"/>
<configure name="MAGICK_THREAD_LIMIT" value="1"/>
<configure name="MAGICK_MEMORY_LIMIT" value="1gb"/>
<configure name="MAGICK_DISK_LIMIT" value="10gb"/>

I restarted the apache server as well...is there anything else I need to do for these settings to take effect?

Re: Image conversion incomplete, grey results

Posted: 2013-01-17T04:25:32-07:00
by magick
Do you have policy.xml? Resource limits should be made in policy.xml. They have no effect in configure.xml. You can also set environment variables (e.g. MAGICK_TMPDIR=/data/tmp) or the command line (e.g. -limit memory 2MiB).

Re: Image conversion incomplete, grey results

Posted: 2013-01-18T07:27:55-07:00
by wwftdg
Right now there is only the configure file in that /usr/local/lib/ area

Do I just create one manually and IM will automatically read it?

Re: Image conversion incomplete, grey results

Posted: 2013-01-18T07:40:51-07:00
by wwftdg
Ok found the file in: /usr/local/etc/ImageMagick/policy.xml

I added these items to the document:

Code: Select all

<policy domain="resource" name="memory" value="3GB"/>
	<policy domain="resource" name="temporary-path" value="/tmp"/>
	<policy domain="resource" name="disk" value="5GB"/>
	<policy domain="resource" name="thread" value="1"/>
So I am going to restart the web server, on reboot will these settings go into effect? Also, is there any other options I should look at in order to fix this bug I am getting.

Re: Image conversion incomplete, grey results

Posted: 2013-01-21T19:30:58-07:00
by wwftdg
I have adjusted these values, even limiting the thread t 1 file, but still getting images ending in grey outputs...any ideas how to resolve?

Re: Image conversion incomplete, grey results

Posted: 2013-01-23T19:10:46-07:00
by wwftdg
So I was reading the imagemagick article about how to speed things up, as my error logs are showing IM has not finishing the completion of the images. It seems because we are sending so many to process sometimes, IM/Server gets overloaded. In the IM article it says to try using not so many system calls at once, so I am curious if anyone knows how to make our code more simple, minimize the system calls:

Code: Select all

$pWidth='';
$pHeight='';
system(binary_system_path()."convert $source -thumbnail X800\> -bordercolor '#ffffff' -border 0 -gravity center -crop X8000+0+0 +repage -strip -quality 100 -profile $rgbProfile $preview");

#check for MAX width
list($pWidth, $pHeight) = getimagesize($preview);
if ($pWidth > 500) {
	system(binary_system_path()."convert $preview -thumbnail '500X' -quality 100 $preview");
}
		
#check for MIN height
list($pWidth, $pHeight) = getimagesize($preview);
if ($pHeight < 300) {
	system(binary_system_path()."convert $preview -gravity center -background '#ffffff' -extent ".$pWidth."X300 -quality 100 $preview");
}
		
#Watermark
system(binary_system_path()."composite -quality 90 -gravity center $watermark $preview $preview");

Re: Image conversion incomplete, grey results

Posted: 2013-01-23T19:11:21-07:00
by wwftdg
And the main error in our logs for IM that causes the incomplete images starts with this:

convert: Premature end of JPEG file