How to get uncompressed size or Bits-per-Pixel

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
codymanix
Posts: 19
Joined: 2008-02-20T20:49:46-07:00

How to get uncompressed size or Bits-per-Pixel

Post by codymanix »

I want to display to the user the uncompressed size of an Image. If there isn't such a method, is there any way to get the bits-per-pixel of an Image?
There is a method GetDepth() but then I do need to know how many components make up a pixel, also, the depth may not be equal in all components?

So I basically want for example that a pixelformat like "R5 G6 B5" returns me "16" and so on.
codymanix
Posts: 19
Joined: 2008-02-20T20:49:46-07:00

Re: How to get uncompressed size or Bits-per-Pixel

Post by codymanix »

Nobody knows an answer? If it is currently not possible with IM could we expect this feature in one of the future versions?
hreinn1000
Posts: 1
Joined: 2012-12-10T14:19:52-07:00
Authentication code: 6789

Re: How to get uncompressed size or Bits-per-Pixel

Post by hreinn1000 »

Did you ever get an answer to this ? Seems like this should be a core function, must be calculated each time the image info is accessed...
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to get uncompressed size or Bits-per-Pixel

Post by anthony »

uncompressed size is generally a multiply of width*height*bits_per_pixel plus the meta data.

the problem is it is format dependant. some formats include large volumes of meta data (a bit like microsoft word doc format) others like PbmPlus (NetPBM) has only a few bytes of meta-data. And then some formats have no uncompressed form as it really completely changes how the image data is stored (Jpeg for example).

basically it is format dependant, and IM does not have any way of knowing how big a specific format (compressed or uncompressed) will be. It can make some guesses as to a minimum uncomressed size (without meta-data) but that is simply a multiply, and depends again on the bits_per_pixel whcih is again format dependant.

So in summery. No, a MagickCore function can not, in general, tell you even a uncompressed image file size. If it did it is only a guess.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply