Monochrome Memory Reduction?

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
anotherprogrammer123
Posts: 36
Joined: 2010-02-21T18:02:40-07:00
Authentication code: 8675308

Monochrome Memory Reduction?

Post by anotherprogrammer123 »

Hello,

I was wondering if ImageMagick uses more memory than needed for pixels.

If I load an image that has 256^2 colors, ImageMagick will use 2 bytes per pixel, right?
But, if I load an image that only has 2 colors, will ImageMagick use 1 bit per pixel for memory or 1 byte per pixel?

I am concerned about efficiency.

Thanks in advance!
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Monochrome Memory Reduction?

Post by magick »

anotherprogrammer123
Posts: 36
Joined: 2010-02-21T18:02:40-07:00
Authentication code: 8675308

Re: Monochrome Memory Reduction?

Post by anotherprogrammer123 »

Thanks, I read through that page and what I picked up is that Imagemagick does not use less memory for monochrome images. It must hold a minimum of 4 unsigned bytes per pixel.

Is this true?

Thanks,
Sorry for the late response.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Monochrome Memory Reduction?

Post by snibgo »

Yes.
snibgo's IM pages: im.snibgo.com
anotherprogrammer123
Posts: 36
Joined: 2010-02-21T18:02:40-07:00
Authentication code: 8675308

Re: Monochrome Memory Reduction?

Post by anotherprogrammer123 »

:( that's too bad...
anotherprogrammer123
Posts: 36
Joined: 2010-02-21T18:02:40-07:00
Authentication code: 8675308

Re: Monochrome Memory Reduction?

Post by anotherprogrammer123 »

Are you sure? I can't believe that ImageMagick would have such a design.

What if I am working with .gif images of 9 million pixels with only 2^8 = 256 colors? Normally I would only need 1 byte per pixel in this case, but ImageMagick requires 4 bytes (= 4 times as much memory)?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Monochrome Memory Reduction?

Post by magick »

Read http://www.imagemagick.org/script/archi ... p#overview. It explains why we took the design approach we did with the pixel cache. If memory is an issue, use -limit area 0 to force the pixels to disk. If that solution is not acceptable there are plenty of alternative image processing utilities that have a smaller memory footprint than ImageMagick.
anotherprogrammer123
Posts: 36
Joined: 2010-02-21T18:02:40-07:00
Authentication code: 8675308

Re: Monochrome Memory Reduction?

Post by anotherprogrammer123 »

Okay. It was done for efficiency and generability.
Thanks for clarifying this.
Post Reply