Page 1 of 1

"Memory allocation failed" error running convert

Posted: 2011-08-30T14:48:45-07:00
by aksdc
$ convert MainMR171004.jpg resultImage.jpg
convert: Memory allocation failed `No such file or directory' @ string.c/AcquireStringInfo/173.


Running ImageMagick 6.5.7-8 2010-12-02 Q16 on Ubuntu 10.04.3 (Lucid)

The file is loaded from: http://www.costumes4less.com/Prodimages ... 171004.jpg

Re: "Memory allocation failed" error running convert

Posted: 2011-08-30T15:05:01-07:00
by fmw42
The file that I download from your link appears to be corrupt. Can you check that it was correctly uploaded and that you can download it and view it. Check also that you can view the original file.

Re: "Memory allocation failed" error running convert

Posted: 2011-08-30T16:16:32-07:00
by aksdc
It does seem to be corrupt, and this is the point: being able to handle corrupted images gracefully without crash.
Analogy: if one tries to process text file as jpeg, imagemagick currently detects the problem and issues error message without crashing, thus allowing the client application to recover.

Re: "Memory allocation failed" error running convert

Posted: 2011-08-30T17:29:39-07:00
by fmw42
see -quiet -regard-warnings at http://www.imagemagick.org/Usage/basics/#controls

I use that to cause an error message to be displayed when there is problem reading an image.

Something like the following:


# test input image
convert -quiet -regard-warnings "$infile" +repage "$tmpA1" ||
errMsg "--- FILE $infile DOES NOT EXIST OR IS NOT AN ORDINARY FILE, NOT READABLE OR HAS ZERO SIZE ---"

where $tmpA1 is set to a .mpc format for further use

Re: "Memory allocation failed" error running convert

Posted: 2011-08-30T19:41:20-07:00
by aksdc
Fred, Thanks for the prompt response!
I read the link and looked at your suggestion. The -quiet and -regard-warnings options seem to be opposite each other. Also, when I tweak your example to convert this corrupted image, I see both ImageMagick error and custom message from double pipe (did not know about that trick before)

Let me supply more details about my pain so you hopefully could advise further:
I have a java app using ImageMagick through JMagick interface. It converts images of various types to jpeg format. In case of corrupted image, the app is able to read ImageInfo but crashes trying to construct new image based on it. The expected behavior would be throwing some exception, like in the case of wrong format I described before. Unfortunately the application just crashes.
Appreciate any help,
Alex

Re: "Memory allocation failed" error running convert

Posted: 2011-08-30T20:45:13-07:00
by fmw42
Sorry, I know little about java or JMagick.

You have a very strange file as I get:


infile="MainMR171004.jpg"
convert -quiet -regard-warnings "$infile" "tmp1.mpc" ||
echo "--- FILE $infile DOES NOT EXIST OR IS NOT AN ORDINARY FILE, NOT READABLE OR HAS ZERO SIZE ---"


convert: Memory allocation failed `No such file or directory' @ fatal/string.c/AcquireStringInfo/175.


So IM does not even recognize this as a valid file. I have never seen this kind of test fail like this. Perhaps I have never had any really "bad" files.

It then hangs until I cmd-. (on my Mac) to abort and continue processing and then it spits out my error message.

Re: "Memory allocation failed" error running convert

Posted: 2011-08-31T20:45:35-07:00
by aksdc
Hi Fred,
Thanks for trying this pesky file on your system. Looks like it is behaving as badly on Mac. I also tested it on http://www.imagemagick.org/MagickStudio ... Studio.cgi and got Internal Server Error.
This problem can unpredictably affect any application that is using IM to process images that are not under its control, hitting especially hard the ones with 24/7 SLAs.
Who decides if / when it is going to be fixed?
Thanks,
Alex

Re: "Memory allocation failed" error running convert

Posted: 2011-08-31T21:19:45-07:00
by fmw42
Magick is the one. But I don't know if this is something that IM can deal with. But that would be his determination.

Re: "Memory allocation failed" error running convert

Posted: 2011-09-01T05:21:34-07:00
by magick
We'll get a patch in the next point release of ImageMagick, 6.7.2-2. Thanks.