Page 1 of 1

Can paletted PNG be saved without white color 'automatically' added?

Posted: 2015-07-30T12:43:10-07:00
by vadim

Code: Select all

convert rose: -colors 12 -type palette test.png
identify -verbose test.png

...
  Colors: 12
  Histogram:
       581: ( 51, 51, 45) #33332D srgb(51,51,45)
       155: ( 83, 76, 56) #534C38 srgb(83,76,56)
       296: ( 94, 93, 79) #5E5D4F srgb(94,93,79)
       217: ( 98, 57, 47) #62392F srgb(98,57,47)
       272: (110,147, 86) #6E9356 srgb(110,147,86)
       153: (140,133,146) #8C8592 srgb(140,133,146)
       273: (161, 59, 44) #A13B2C srgb(161,59,44)
       121: (166,166,186) #A6A6BA srgb(166,166,186)
       150: (187, 72, 68) #BB4844 srgb(187,72,68)
       540: (221, 54, 48) #DD3630 srgb(221,54,48)
       266: (232, 81, 89) #E85159 srgb(232,81,89)
       196: (245,243,239) #F5F3EF srgb(245,243,239)
  Colormap entries: 13
  Colormap:
         0: ( 51, 51, 45) #33332D srgb(51,51,45)
         1: ( 83, 76, 56) #534C38 srgb(83,76,56)
         2: ( 94, 93, 79) #5E5D4F srgb(94,93,79)
         3: ( 98, 57, 47) #62392F srgb(98,57,47)
         4: (187, 72, 68) #BB4844 srgb(187,72,68)
         5: (221, 54, 48) #DD3630 srgb(221,54,48)
         6: (232, 81, 89) #E85159 srgb(232,81,89)
         7: (161, 59, 44) #A13B2C srgb(161,59,44)
         8: (140,133,146) #8C8592 srgb(140,133,146)
         9: (110,147, 86) #6E9356 srgb(110,147,86)
        10: (166,166,186) #A6A6BA srgb(166,166,186)
        11: (245,243,239) #F5F3EF srgb(245,243,239)
        12: (255,255,255) #FFFFFF white
...        
Edit: I checked and it's not 'white', it is background color, can be set with command... Still, question remains.

Code: Select all

Version: ImageMagick 6.9.1-1 Q16 x86 2015-03-20 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: DPC Modules OpenMP
Delegates (built-in): bzlib cairo freetype jbig jng jp2 jpeg lcms lqr openexr pa
ngocairo png ps rsvg tiff webp xml zlib

Re: Can paletted PNG be saved without white color 'automatically' added?

Posted: 2015-07-30T13:18:29-07:00
by fmw42
I am not sure I know what you are asking? Do you want to exclude a color in the image or the background color.

If the former, then as far as I know, you cannot exclude a color in the image using -colors.

You can use -remap to recolor the image without the white value. See http://www.imagemagick.org/Usage/quantize/#remap

Re: Can paletted PNG be saved without white color 'automatically' added?

Posted: 2015-07-30T19:40:31-07:00
by glennrp
Use "-define png:exclude-chunks=bkgd" to prevent the background color from being included in the palette (assuming there is no pixel of that color in the image).

Re: Can paletted PNG be saved without white color 'automatically' added?

Posted: 2015-07-31T01:50:11-07:00
by vadim
"-define png:exclude-chunks=bkgd"
Thank you, that solved my problem.