Calculating image size (bytes)

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
sacha

Calculating image size (bytes)

Post by sacha »

Using the MagickWand API I'm attempting to calculate the decompressed size of an image defined by:

height * width * bits per pixel

I can query the height and width straightforwardly, but I'm not sure about bits per pixel.

MagickGetImageDepth() looked like a reasonable candidate but reading the code it seems to visit every pixel in the image, whereas I'd have expected the number of channels & channel sizes to be defined by the format (i.e. known independently of the image data), so I'm not sure this is what I want.

Scanning down the API I can't see any other likely candidate functions.

Can anyone point me at the function I need?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Calculating image size (bytes)

Post by anthony »

Also multiply by the number of channels EG RGB and optional A (matte) channels. The depth per color value is fixed at compile time as the 'Q' level for IM.

Code: Select all

  identify -version
will let you see the compiled 'Q' level.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply