Page 1 of 1

Calculating image size (bytes)

Posted: 2007-06-14T09:15:10-07:00
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?

Re: Calculating image size (bytes)

Posted: 2007-06-14T16:12:12-07:00
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.