Forum archive
Changing Bit Depth from 8 to 4 and preserve palette order.
- Ken,
I'm using the IrfanView with the PNGOUT plugin. I might be misunderstanding the menu for "Bit Depth". When I have an 8 bit image and try to change to 4 bit the program has a "PNG Save error". Also PNGOUT will not convert from 8 bit to 4 bit unless it's already 4 bit.
I have used IrfanView to decrease the color depth but it does not preserve the color palette.
I guess my problem is that I have a thousand images with only 10 colors but all of them are 8 bit when they should only be 4 bit. Is there anyway to convert these using your program and save the order of the color palette? The colors are indexed from 0 to 9.
I'm probably out of luck on this but let me know if you have any suggests. Thanks for producing PNGOUT. It has been very helpful to me.
Bill Miller - PNGOUT only allows lossless conversions. If you try to reduce colors and it doesn't fit in the selected color space, PNGOUT will exit with an error.
images with only 10 colors ... save the order of the color palette?
Try Palette, Bit Depth 4, and Preserve palette order. If that doesn't work as expected, it might help to send me a sample image. - Thanks for the help and I've decided to keep all of my images as 8 bit. It will take more memory to load but at least I don't lose the order of my color palette.
---- FYI ----
As described in the example below there seems to be no way to use "/d4 /kp" at the same time. I could not attach the image but the palette only has 10 colors for index 0 to 9. All other colors are black (0,0,0). It appears that "/kp" will not truncate to 16 colors if "/d4" is used. This is probably a logical behavior for this option.
This works but changes the position of some of my colors.
D:\>pngout parktn_test.png out.png /d4
Input: parktn_test.png coltype:3 (Pal) filter:0 (none)
Output: out.png coltype:3 (Pal) filter:0 (none)
Input size: 8259 bytes, 6 unique colors, bitdepth:4
Output size: 7381 bytes
Change: -878 bytes ( 89% of original)
This does not work
D:\>pngout parktn_test.png out.png /d4 /kp
Input: parktn_test.png coltype:3 (Pal) filter:0 (none)
Output: out.png coltype:3 (Pal) filter:0 (none)
Image doesn't fit in selected bitdepth - From what you're saying, it sounds like the image contains 256 colours, most of which are just black.
But, because they are part of the palette, PNGOUT won't truncate them off the end if you've specified /kp.
I think PNGCrush is what you need here.
If you do something like:pngcrush -plte_len 10 -bit_depth 4 -force parktn_test.png out.png
It should truncate the palette to 10 colours, and reduce the bit depth to 4.
Once you've done this, you should be able to run pngout /kp on it, to reduce the size of the image.
You might find that it if you then try PNGOUT /kp /d8 on it, it might compress better as an 8-bit image, because 8-bit palette images are often more compressible. But at least the palette will be smaller, after truncating it with PNGCrush. - Seems to be working fine now. I hope it didn't take too much of your time.
I'm converting to 4 bit because the software uses less RAM when the images are loaded.
Thanks for pointing me in the right direction.
Bill Miller