Mogrify on corrupt images crashing server (doesnt timeout)

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
mikemeadeuk
Posts: 7
Joined: 2011-06-22T15:59:43-07:00
Authentication code: 8675308

Mogrify on corrupt images crashing server (doesnt timeout)

Post by mikemeadeuk »

Hi Guys,

I have a little problem. I am using mogrify to trim whitespace from images within a directory in a recursive manner using the unix find command.

However, i have a few corrupt images and mogrify plods along nicely until it hits one of these corrupt images. Then it just hangs and eventually my server loads hits about 80 and dies.

I have tried setting the timeout in both policy.xml and via the command line but it doesnt seem to work.

Is there anyway I can

a: avoid corrupt images
b: avoid images below 10x10 pixels (the corrupt images seem to be 0x0 pixels)
c: make the timeout work so that it skips it if it doesnt complete the task

Hopefully someone can point me in the rigth direction because im stuck for ideas!

thanks in advance guys!

Mike

oh, and the command I am using is:

Code: Select all

find /directory/ -name "*.jpg" -exec mogrify -trim -fuzz 1% {} \;
and also tried:

Code: Select all

find /directory/ -name "*.jpg" -exec mogrify -limit time 20 -trim -fuzz 1% {} \;
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Mogrify on corrupt images crashing server (doesnt timeou

Post by fmw42 »

can't you just use ls -al to filter out any file that has zero filesize for the images that are 0x0 in dimensions?
mikemeadeuk
Posts: 7
Joined: 2011-06-22T15:59:43-07:00
Authentication code: 8675308

Re: Mogrify on corrupt images crashing server (doesnt timeou

Post by mikemeadeuk »

Hi fmw42,

Yeah I thought about that, but it turns out that although the dimensions are 0x0, the file size is still > 100k. I think the only reason the dimensions are 0x0 is because the operating system cant actually read/view it?

Any other ideas?

Cheers

Mike
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Mogrify on corrupt images crashing server (doesnt timeou

Post by fmw42 »

what happens when you do

convert corruptimage.jpg image.jpg

does it crash, abort, hang?
mikemeadeuk
Posts: 7
Joined: 2011-06-22T15:59:43-07:00
Authentication code: 8675308

Re: Mogrify on corrupt images crashing server (doesnt timeou

Post by mikemeadeuk »

Hi,

it completely crashed my system and I have to reboot via KVM.

If I add a "-limit thread 1" to the command i can see it takes up 100% of one of my cpus and stays there forever.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Mogrify on corrupt images crashing server (doesnt timeou

Post by fmw42 »

what happens if you do

convert image -regard-warnings newimage || echo "bad image"
mikemeadeuk
Posts: 7
Joined: 2011-06-22T15:59:43-07:00
Authentication code: 8675308

Re: Mogrify on corrupt images crashing server (doesnt timeou

Post by mikemeadeuk »

hi,

its just doing the same thing, sitting at 100% cpu and not doing anything. ?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Mogrify on corrupt images crashing server (doesnt timeou

Post by fmw42 »

What do you get from:

convert image -ping -format "%wx%h" info:

if 0x0, then you you can trap on that.
mikemeadeuk
Posts: 7
Joined: 2011-06-22T15:59:43-07:00
Authentication code: 8675308

Re: Mogrify on corrupt images crashing server (doesnt timeou

Post by mikemeadeuk »

hi, the same thing again. 100% cpu and no result.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Mogrify on corrupt images crashing server (doesnt timeou

Post by fmw42 »

sorry then, I am out of ideas. hopefully one of the IM developers may have more insight.
mikemeadeuk
Posts: 7
Joined: 2011-06-22T15:59:43-07:00
Authentication code: 8675308

Re: Mogrify on corrupt images crashing server (doesnt timeou

Post by mikemeadeuk »

ok well thanks for your help anyway. :)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Mogrify on corrupt images crashing server (doesnt timeou

Post by fmw42 »

you probably will need to post a link to one of your bad images, so that the IM developers have some way to duplicate your issue. you should also identify what version of IM you are using and on which platform.
Post Reply