Page 1 of 1

After image resize new images are partially greyed out

Posted: 2017-06-18T19:01:07-07:00
by Joshva
Hi,

I call ImageMagick from a Java Application server. Occasionally (about 1 in 100 times) an image does not resize correctly and the bottom half of it becomes grey (although not the grey i was setting for the background)

It looks like processing didn't complete

I am using Convert with the following parameters

resize 927>
background #ffffff
gravity center
extent 927
quality 90
crop 927x0
synchronize

No error is returned. If i re run it though, it works correctly. It seems random as to which images it happens to

Any help is greatly appreciated

Re: After image resize new images are partially greyed out

Posted: 2017-06-18T19:25:19-07:00
by fmw42
Does your processing always fail on this image? If not, then this behavior can occur if you are running out of temp space. Check your /tmp directory or the directory you have set for MAGICK_TEMPORARY_PATH.

What is your IM version and platform? Perhaps you need to upgrade your version of IM. If it happens only for JPG images, then check and upgrade libjpeg.

Your command is not correct. You cannot do -crop 970x0. That produces a zero size image. Also your order may not be good, although imagemagick 6 is forgiving.

This works for me on Unix and is more correct syntax:

Code: Select all

convert example-good-image.jpg \
-resize "927>" \
-crop 927x927+0+0 +repage \
-gravity center \
-extent 927 \
-quality 90 \
-synchronize \
result.jpg
In Windows it would be

Code: Select all

convert example-good-image.jpg ^
-resize "927>" ^
-crop 927x927+0+0 +repage ^
-gravity center ^
-extent 927 ^
-quality 90 ^
-synchronize ^
result.jpg

Re: After image resize new images are partially greyed out

Posted: 2017-06-19T04:45:47-07:00
by Joshva
Hi thanks for the reply, very helpful a couple of additional notes:

1) It does not always fail, it seems random as to which image it fails in i.e. if i re run it, it normally works
2) It only happens under load i.e. when i'm running 100 at a time
3) I am using im4java to pass the commands to convert, so please excuse my crop syntax, im4java probably changes it to what you have
4) My version is: ImageMagick 7.0.5-5 Q16 x86_64 2017-05-07

The tmp directory sounds interesting, is there any size limit on it? There is a tone of storage space on the machine its running on

Re: After image resize new images are partially greyed out

Posted: 2017-06-19T05:24:03-07:00
by snibgo
I suspect the "-synchronize" setting takes effect only after it is given, so it should be the first option.

Re: After image resize new images are partially greyed out

Posted: 2017-06-19T06:18:29-07:00
by Joshva
Ah i will try that

Re: After image resize new images are partially greyed out

Posted: 2017-07-11T04:23:51-07:00
by gijs van der meijde
Dear,

Can you please show me how you called imagemagick using java?
I am having a LOT of trouble with it.