Page 1 of 1
Converting a 24 bit png to 4 bit png not successfull
Posted: 2013-12-03T06:37:22-07:00
by prasadmenon
Hi All,
I am new to imagemagik. I have a query while using it. The scenario is as follows.
I have a 24 bit png.
http://wikisend.com/download/816040/image_5778.png
I want to convert it to 4 bit png. I tried the following command
convert image_5778.png PNG8:correctimage.png This is
successfully converting 24 bit to 8 bit png, but when I tried
convert image_5778.png -depth 4 correctimage.png It is not getting converted to 4 bit png.
Please let me know how I can save it correctly to 4 bit for my use and what is wrong in the command I used.
Note: I am using
ImageMagick-6.8.7-Q16 in Windows machine.
Re: Converting a 24 bit png to 4 bit png not successfull
Posted: 2013-12-03T06:58:50-07:00
by snibgo
I think you are confusing 24 bits per pixel and 8 bits per channel per pixel.
Your input image has pixeldepth 24 (bits per pixel). But there are only 2 colours: black and white.
After this command ...
... the result has 2 palette entries, with pixeldepth of 1.
IM generally tries to make the file as small as possible. You can force it to be 24-bits (per pixel) with PNG24:out.png but I don't think you can force 4-bits/channel/pixel.
Re: Converting a 24 bit png to 4 bit png not successfull
Posted: 2013-12-03T09:42:20-07:00
by glennrp
Yes, the converted image has a palette with two entries, black and white. This should be representable without loss
as a 4-bit image. I don't know why convert is rejecting the attempt to write the 1-bit image in a 4-bit format. I'll
take a look at that.
Re: Converting a 24 bit png to 4 bit png not successfull
Posted: 2013-12-03T12:25:32-07:00
by glennrp
It turns out to be a side effect of the recent split of linear and sRGB colorspaces. A fix is in the SVN repository, r=13919 and will appear in IM-6.8.7-9 in a few days.
Re: Converting a 24 bit png to 4 bit png not successfull
Posted: 2013-12-04T01:16:28-07:00
by prasadmenon
Thanks for the inputs. So if I understand correctly, I will be able to test this only when IM-6.8.7-9 gets released. Please let me know once it gets released.
I am waiting for it.
Re: Converting a 24 bit png to 4 bit png not successfull
Posted: 2013-12-05T06:57:59-07:00
by prasadmenon
Glen,
Can you please try converting the attached image to 4 bit using the development version of Imagemagick and share it here. It is for a urgent project requirement. Any help will be appreciated.
Re: Converting a 24 bit png to 4 bit png not successfull
Posted: 2013-12-05T08:05:37-07:00
by glennrp
prasadmenon wrote:Glen,
Can you please try converting the attached image to 4 bit using the development version of Imagemagick and share it here. It is for a urgent project requirement. Any help will be appreciated.
Using this command:
Code: Select all
convert image_5778.png -define png:color-type=0 -define png:bit-depth=4 -define png:exclude-chunks=all image_depth4.png
The last -define isn't necessary but it doesn't make a lot of sense to include gAMA and cHRM chunks in a black-and-white image so I used that option to exclude them.
Re: Converting a 24 bit png to 4 bit png not successfull
Posted: 2015-06-06T09:48:50-07:00
by glennrp
This bug was fixed in IM-6.8.7-9 but has reappeared in IM-6.9.1-3.