copy png to png expands palette
Moderators: XnTriq, helmut, xnview
copy png to png expands palette
If you copy an 8bit png which uses only a few colors, say 10 and copy using "ncvonert -o new.png old.png", your new image has a palette of 256 colors expanding the size of the image (bytes on disk, not image dimension). The size of the image is critical since I am placing them in an Android apk package and want the smallest possible png.
Re: copy png to png expands palette
Please try adding the following code from the NConvert Help file:dlang wrote:If you copy an 8bit png which uses only a few colors, say 10 and copy using "ncvonert -o new.png old.png", your new image has a palette of 256 colors ...
-colors num : Convert in Indexed Colors (256, 216, 128, 64, 32, 16 or 8 )
So
Code: Select all
nconvert -colors 16 -o new.png old.png
Re: copy png to png expands palette
Using -colors <numColors> is not practical when I am converting a bunch of images using a DOS "for" loop command.
for %f in (*.png) do nconvert -o out\%f %f
I also do not know the number of color used in each image.
I only determined that nconvert was expanding the palette because some of my images got larger (size on disk).
I used tweakPng to display the file details and noticed the palette size increased.
I am using nconvert to strip off some of the meta chunk sections (text, iText, and zText).
for %f in (*.png) do nconvert -o out\%f %f
I also do not know the number of color used in each image.
I only determined that nconvert was expanding the palette because some of my images got larger (size on disk).
I used tweakPng to display the file details and noticed the palette size increased.
I am using nconvert to strip off some of the meta chunk sections (text, iText, and zText).
Re: copy png to png expands palette
Is not practical because... ? It doesn't run, or some other reason?dlang wrote:Using -colors <numColors> is not practical when I am converting a bunch of images using a DOS "for" loop command.
Code: Select all
for %f in (*.png) do nconvert -o out\%f %f
If you open an image in a GUI image editor such as XnView you should be able to see the image properties including the number of colours, or you could upload an example image.[/quote]I also do not know the number of color used in each image.
But that shows the number of colours??I used tweakPng to display the file details and noticed the palette size increased.
When a png file is opened NConvert may convert it to a 24-bit image while preserving the actual colours used; when you use the -colours option you would need to set a value equal to greater than the number of colours in the original image.
You should be able to do that using the following flag:I am using nconvert to strip off some of the meta chunk sections (text, iText, and zText).
-rmeta : Remove Metadata (EXIF/IPTC/...)
Have you created a list of the available NConvert commands using -help ?
Re: copy png to png expands palette
Bug confirmed for 8- as well as 4-bit PNGs
Re: copy png to png expands palette
I would NOT consider this as a BUG ... NC is neither a hard-core PNG optimizer nor a generic file copy tool, so to me it seems to work well, despite somewhat unfortunate result is this special case. Try OPTIPNG or PNGOUT or TRUEPNG or similar. http://newsgroup.xnview.com/viewtopic.php?t=23326XnTriq wrote:Bug confirmed for 8- as well as 4-bit PNGs
> and want the smallest possible png
PS: some other PNG creation tools save pictures always as 32-bpp RGBA, even if there are just 5 colours in ... so NC is NOT that bad :-\
There is indeed no WinZIP under my rock.
Re: copy png to png expands palette
A ´bug´becomes a ´limitation´when it is documented as such...DOS386 wrote:[I would NOT consider this as a BUG ... NC is neither a hard-core PNG optimizer nor a generic file copy tool, so to me it seems to work well, despite somewhat unfortunate result is this special case.