What's the canonical way to get the RAM size of a PNG

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
jack-mann
Posts: 16
Joined: 2014-03-15T00:49:44-07:00
Authentication code: 6789

What's the canonical way to get the RAM size of a PNG

Post by jack-mann »

If I do a

Code: Select all

convert img.png    out.bmp
I get for a 20500x8000 img.png a 500M out.bmp

So can I conclude that when imagmagick reads the img.png in it uses about 500M RAM?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: What's the canonical way to get the RAM size of a PNG

Post by magick »

Resource requirements for a typical image is 4 x width x height. The resource can be memory or disk depending on your resource limits. Add -limit memory 2MB, for example, to limit the amount of allowed memory to 2MB. If this limit is exceeded, pixels are pushed to disk. The tradeoff is that disk access is 1000x slower than memory access. See http://www.imagemagick.org/script/archi ... .php#cache for details.
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: What's the canonical way to get the RAM size of a PNG

Post by glennrp »

magick wrote:Resource requirements for a typical image is 4 x width x height.
It's 4 times width times height times bytes_per_sample. bytes_per_sample depends on how you built ImageMagick. It's 1 in a Q8 build, 2 in a Q16, 4, in a Q32, etc.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: What's the canonical way to get the RAM size of a PNG

Post by snibgo »

So, in the OP's example of 20500x8000 pixels, assuming Q16, we need 8 bytes/pixels, so 1.3GB of memory.
snibgo's IM pages: im.snibgo.com
Post Reply