how to get depth of png files

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
jasonlee
Posts: 8
Joined: 2012-11-29T00:36:25-07:00
Authentication code: 6789

how to get depth of png files

Post by jasonlee »

I'm using MagickCore to get depth of png files, (Version ImageMagick-6.7.8) but it doesnot work correctly, I have 32-bit and a 8-bit png pictures, but im tells them depth are same as 8-bit, it's so strange.

Code: Select all

        Image *images = NULL, *thumbnails = NULL;
        ngx_buf_t* buf = NULL;
        size_t len;
        u_char *inputblob = NULL, *outputblob = NULL;
        ImageInfo *image_info = NULL;
        ExceptionInfo *exception = NULL;

        exception = AcquireExceptionInfo();
        buf = &(image_bean->src_image);
        inputblob = buf->pos;
        len = buf->last - buf->pos;
        image_info = CloneImageInfo((ImageInfo *) NULL);
        images = BlobToImage(image_info, inputblob, len, exception);
        if (exception->severity != UndefinedException || images == (Image *) NULL)
        {
                if(images != (Image *) NULL)
                {
                        images = DestroyImageList(images);
                }
                image_info = DestroyImageInfo(image_info);
                exception = DestroyExceptionInfo(exception);
                return;
        }


      thumbnails = SampleImage(images, width, height, exception);

      printf("thumbnails->depth=%d ", (int)thumbnails->depth);
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how to get depth of png files

Post by fmw42 »

depth is per channel, so multiply by the number of channels
jasonlee
Posts: 8
Joined: 2012-11-29T00:36:25-07:00
Authentication code: 6789

Re: how to get depth of png files

Post by jasonlee »

fmw42 wrote:depth is per channel, so multiply by the number of channels

Thanks. But I get zero as number of channels. As i got code:

Code: Select all

printf("thumbnails->channels=%d\n", (int)thumbnails->channels);
Thanks for your clearation.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how to get depth of png files

Post by fmw42 »

Sorry I cannot help. I do not use any API just the command line.
jasonlee
Posts: 8
Joined: 2012-11-29T00:36:25-07:00
Authentication code: 6789

Re: how to get depth of png files

Post by jasonlee »

fmw42 wrote:Sorry I cannot help. I do not use any API just the command line.

Thank you all the same.
Post Reply