-limit not working

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
buncee
Posts: 6
Joined: 2013-11-27T13:44:24-07:00
Authentication code: 6789

-limit not working

Post by buncee »

Hi,

I've been blocked on this for a whole day. Really need some help or idea.

I run the command:

convert -limit area 128mb -limit map 256mb -limit disk 512mb -format %w,%h, <inputFile> -identify <outputFile>

It give the error: Could not read file as specified mime-type, file is invalid or corrupted: Illegal Argument Exception, bailing out: Could not read file as type 'image/gif' or 'image/jpeg', Not a JPEG file: starts with 0xff 0xd9

However, when I remove the three -limit argument and run only

convert -format %w,%h, <inputFile> -identify <outputFile>

It convert successfully.

Why is this?

I've also tried change the limit to smaller or bigger value and even tried change mb to MB or MiB(though I don't think that is the problem) but no luck.

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

Re: -limit not working

Post by fmw42 »

try

identify -ping -format "%w,%h" yourimage

or

convert yourimage -ping -format "%w,%h" info:

or

convert -limit memory 32 -limit map 32 yourimage -ping -format "%w,%h" info:

see
http://www.imagemagick.org/script/resou ... nvironment
http://www.imagemagick.org/script/comma ... .php#limit
http://www.imagemagick.org/Usage/files/#massive

if you use a disk limit, it will give an error message if you exceed the limit

try leaving off the mb
buncee
Posts: 6
Joined: 2013-11-27T13:44:24-07:00
Authentication code: 6789

Re: -limit not working

Post by buncee »

Thank you. But it doesn't solve my problem :(

If I'm not specifying a disk limit will there be any problem?

When it gives the error, is that because the disk limit (512mb) is too small? But I think it wouldn't take much space to process image, right? What is a proper value for disk size, e.g. 2 times max acceptable size? What about other limit value?

Any insight?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: -limit not working

Post by snibgo »

convert -limit area 128mb ...
"MB" is case-sensitive and should be in capitals. I suspect that "mb" is ignored, so it tries to fit the image in 128 bytes.

(This is on v6.8.7-0 on Windows 7.)
snibgo's IM pages: im.snibgo.com
buncee
Posts: 6
Joined: 2013-11-27T13:44:24-07:00
Authentication code: 6789

Re: -limit not working

Post by buncee »

I tried. But that doesn't seem make any difference...
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: -limit not working

Post by magick »

Try
  • convert -limit area 128MB -list resource
It should return an area limit of 128MB. If so, ImageMagick is behaving as expected.
buncee
Posts: 6
Joined: 2013-11-27T13:44:24-07:00
Authentication code: 6789

Re: -limit not working

Post by buncee »

It gives:
convert: invalid argument for option '128MB' : -limit
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: -limit not working

Post by snibgo »

What version are you running? On what platform?
snibgo's IM pages: im.snibgo.com
buncee
Posts: 6
Joined: 2013-11-27T13:44:24-07:00
Authentication code: 6789

Re: -limit not working

Post by buncee »

fmw42 wrote: try leaving off the mb
magick wrote:Try
  • convert -limit area 128MB -list resource
It should return an area limit of 128MB. If so, ImageMagick is behaving as expected.
These together provides some information which moves me to the next question:

when I run:
convert -limit map area 128 -limit map 256 -limit disk 512 -list resource

it gives:
File Area Memory Map Disk
-----------------------------------------------------------------------------
2.6e+02mb 1.3e+02mb 5.1e+02gb

It seems IM has default unit for different resource(Area in mb, Map in mb and Disk in gb)? Any way to make disk limit down to 512mb?
snibgo wrote:What version are you running? On what platform?
Tried on 6.5.6 and 6.8.2 on RedHat
Post Reply