ImageMagick crashes on large images
-
- Posts: 5
- Joined: 2017-02-21T07:08:11-07:00
- Authentication code: 1151
ImageMagick crashes on large images
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
$ 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
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: ImageMagick crashes on large images
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?
What does "identify -list resource" say? How much memory do you have available?
snibgo's IM pages: im.snibgo.com
-
- Posts: 5
- Joined: 2017-02-21T07:08:11-07:00
- Authentication code: 1151
Re: ImageMagick crashes on large images
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
$ 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
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: ImageMagick crashes on large images
Code: Select all
Height: 16KP
Your memory and disk limits are also very low.
snibgo's IM pages: im.snibgo.com
-
- Posts: 5
- Joined: 2017-02-21T07:08:11-07:00
- Authentication code: 1151
Re: ImageMagick crashes on large images
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?
$ 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
It looks like its failing before it gets to the policy check otherwise ImageMagick would throw:
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?
Code: Select all
-> identify -verbose image.jpg
identify: width or height exceeds limit `logo.jpg' @ error/cache.c/OpenPixelCache/3827.
Which OS are you using?
-
- Posts: 5
- Joined: 2017-02-21T07:08:11-07:00
- Authentication code: 1151
Re: ImageMagick crashes on large images
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.
I am using Debian stretrch, kernel 4.8.0-2-amd64.
-
- Posts: 5
- Joined: 2017-02-21T07:08:11-07:00
- Authentication code: 1151
Re: ImageMagick crashes on large images
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.
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.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: ImageMagick crashes on large images
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
snibgo's IM pages: im.snibgo.com
Re: ImageMagick crashes on large images
With IMv7, we get expected results:
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.
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.
-
- Posts: 1
- Joined: 2017-06-05T10:52:46-07:00
- Authentication code: 1151
Re: ImageMagick crashes on large images
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 "
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 "
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: ImageMagick crashes on large images
See the above replies, in particular about policy.xml.
snibgo's IM pages: im.snibgo.com