Page 1 of 1

how to get depth of png files

Posted: 2013-06-30T20:28:35-07:00
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);

Re: how to get depth of png files

Posted: 2013-06-30T20:42:23-07:00
by fmw42
depth is per channel, so multiply by the number of channels

Re: how to get depth of png files

Posted: 2013-06-30T23:29:52-07:00
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.

Re: how to get depth of png files

Posted: 2013-07-01T10:07:05-07:00
by fmw42
Sorry I cannot help. I do not use any API just the command line.

Re: how to get depth of png files

Posted: 2013-07-01T19:16:55-07:00
by jasonlee
fmw42 wrote:Sorry I cannot help. I do not use any API just the command line.

Thank you all the same.