Page 1 of 1
imagemagick7, MagickCore: GetPixelChannels(image) not valid after PingImage()?
Posted: 2016-07-08T07:55:34-07:00
by jcupitt
Hi all,
I'm rewriting an import class for imagemagick7, lots of nice improvements, thank you.
I'd like to be able to call PingImage() and then get the number of channels with GetPixelChannels(image), but this seems to return 0, at least for JPEG images. It seems I can only use GetPixelChannels() after ReadImage().
Is this correct? Is there any way to get the number of channels without decoding the whole image?
Re: imagemagick7, MagickCore: GetPixelChannels(image) not valid after PingImage()?
Posted: 2016-07-08T15:15:52-07:00
by magick
You could try calling InitializePixelChannelMap(image), before you call GetPixelChannels(). The channel map is initialized when the pixel cache is initialized. The pixel cache is generally not initialized when you are "pinging" an image. Let us know if that works. If so, we will consider adding a patch to initialize the pixel channel map automatically when pinging an image.
Re: imagemagick7, MagickCore: GetPixelChannels(image) not valid after PingImage()?
Posted: 2016-07-09T04:57:30-07:00
by jcupitt
It works! And it makes PingBlob() work too.
Thank you very much. I have another question, I'll start a fresh topic.
Re: imagemagick7, MagickCore: GetPixelChannels(image) not valid after PingImage()?
Posted: 2016-07-09T05:18:59-07:00
by dlemstra
We added a patch so you won't need to do it yourself in the next version:
http://git.imagemagick.org/repos/ImageM ... 85e97aa69d
Re: imagemagick7, MagickCore: GetPixelChannels(image) not valid after PingImage()?
Posted: 2016-07-09T07:50:27-07:00
by jcupitt
I've found a case when this fails. If I PingImage()/InitializePixelChannelMap(image) on a PDF I see:
image->depth = 16
GetImageType() = 6
GetPixelChannels() = 3
But if I ReadImage() the same file I see:
image->depth = 16
GetImageType() = 7
GetPixelChannels() = 4
I'd obviously like Ping and Read to return the same header so I can allocate memory correctly. Is there some way around this?
Re: imagemagick7, MagickCore: GetPixelChannels(image) not valid after PingImage()?
Posted: 2016-07-09T13:50:07-07:00
by magick
Thanks for the problem report. We can reproduce it and will have a patch to fix it in GIT master branch @
https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @
http://www.imagemagick.org/download/beta/ by sometime tomorrow.
Re: imagemagick7, MagickCore: GetPixelChannels(image) not valid after PingImage()?
Posted: 2016-07-28T07:19:43-07:00
by jcupitt
Works well here. Thank you very much!