Page 1 of 1
ImageMagick crashes on large images
Posted: 2017-02-21T07:54:38-07:00
by roundsturdy
ImageMagick is not able to handle larges images. As you can see in the following code, I am running identify on a JPG of size 624x28281. I've tried to use the -limit parameter to to lift any memory-related restrictions, but there was no change. This seems to be a regression; this was definitely working with 6.8. I'm currently using version 6.9.7-4. Any help would be appreciated. Thanks.
$ identify pic.jpg
identify-im6.q16: memory allocation failed `pic.jpg' @ error/jpeg.c/ReadJPEGImage/1239.
$ file pic.jpg
pic.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 624x28281, frames 1
$ identify -limit map 128MB -limit memory 128MB -limit area 128MP pic.jpg
identify-im6.q16: memory allocation failed `pic.jpg' @ error/jpeg.c/ReadJPEGImage/1239.
$ identify --version
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114
http://www.imagemagick.org
Copyright: © 1999-2017 ImageMagick Studio LLC
License:
http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib djvu fftw fontconfig freetype jbig jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png tiff wmf x xml zlib
Re: ImageMagick crashes on large images
Posted: 2017-02-21T08:08:26-07:00
by snibgo
Please don't multi-post. The bugs forum is the correct place to report suspected bugs. I've removed your other post.
What does "identify -list resource" say? How much memory do you have available?
Re: ImageMagick crashes on large images
Posted: 2017-02-21T08:11:04-07:00
by roundsturdy
Sorry, I wasn't sure where to post. To answer your questions:
$ identify -list resource
Resource limits:
Width: 16KP
Height: 16KP
Area: 128MP
Memory: 256MiB
Map: 512MiB
Disk: 1GiB
File: 768
Thread: 4
Throttle: 0
Time: unlimited
$ free -h
total used free shared buff/cache available
Mem: 23G 4.3G 1.3G 1.3G 17G 17G
Re: ImageMagick crashes on large images
Posted: 2017-02-21T08:29:05-07:00
by snibgo
You only have permission for images up to that height, but yours is 28281. I suggest you adjust your policy.xml.
Your memory and disk limits are also very low.
Re: ImageMagick crashes on large images
Posted: 2017-02-21T08:36:52-07:00
by roundsturdy
Thanks for your response. Are these values that I should be able to adjust on the command line? If so, there doesn't seem to be any effect:
$ identify -limit memory 4GB -limit map 4GB -limit disk 20GB -limit area 500MP -limit height 50KP -limit width 50KP pic.jpg
identify-im6.q16: memory allocation failed `pic.jpg' @ error/jpeg.c/ReadJPEGImage/1239.
Can you suggest an alternative set of values?
Re: ImageMagick crashes on large images
Posted: 2017-02-21T08:39:42-07:00
by magick
It looks like its failing before it gets to the policy check otherwise ImageMagick would throw:
Code: Select all
-> identify -verbose image.jpg
identify: width or height exceeds limit `logo.jpg' @ error/cache.c/OpenPixelCache/3827.
We can convert a large JPEG image with the latest ImageMagick releases, 7.0.5-0 and 6.9.7-9. Perhaps the problem is image specific. Can you post a URL to your JPEG image so we can download it and attempt to reproduce the problem?
Which OS are you using?
Re: ImageMagick crashes on large images
Posted: 2017-02-21T08:48:37-07:00
by roundsturdy
Sure, here is the image in question:
http://6jpuwudl6o60u5j2nvzjnd1aq9q.s3-w ... om/pic.jpg
I am using Debian stretrch, kernel 4.8.0-2-amd64.
Re: ImageMagick crashes on large images
Posted: 2017-02-21T09:16:38-07:00
by roundsturdy
Thanks to snibgo's comment, I was able to solve the problem. The solution is indeed to adjust the height and width limits in policy.xml. I think there are actually two underlying problems here:
1. The "-limit width" and "-limit height" command line arguments are ignored. Apparently, these limits can be set only in policy.xml. This might be intentional for security reasons, but is confusing nonetheless. If it is fact an intentional design decision to ignore the flags, I think IM should at least emit a warning that it's ignoring them when they are provided. For example, in the following, notice that the limit width flag is ignored:
$ identify -limit width 100KP -list resource
Resource limits:
Width: 16KP
....
2. As pointed out by magick, when encountering an image that exceeds the width and height limits, it crashes with a memory error rather than emit a helpful message. This is definitely a bug.
Thank you both for your help. Let me know if I can do anything else for you.
Re: ImageMagick crashes on large images
Posted: 2017-02-21T09:28:13-07:00
by snibgo
resource.xml is a security feature. The command-line "-limit" cannot relax the limits. It can only make them tighter, for example:
Code: Select all
f:\web\im>%IM%identify -limit width 100 -list resource
Resource limits:
Width: 100P
Re: ImageMagick crashes on large images
Posted: 2017-02-21T09:50:19-07:00
by magick
With IMv7, we get expected results:
Code: Select all
-> identify pic.jpg
identify: width or height exceeds limit `pic.jpg' @ error/cache.c/OpenPixelCache/3465.
identify: memory allocation failed `pic.jpg' @ error/jpeg.c/ReadJPEGImage/1270.
However, with IMv6, we just get the second message which is misleading. We will add a patch to fix this problem within the next few days.
Re: ImageMagick crashes on large images
Posted: 2017-06-05T10:57:10-07:00
by oliverknill
I have the same problem after updating to Ubuntu 17,04
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114
Convert refuses to resize larger panoramas which were no problem before.
" width or height exceeds limit "
Re: ImageMagick crashes on large images
Posted: 2017-06-05T11:04:31-07:00
by snibgo
See the above replies, in particular about policy.xml.