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

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
vadim
Posts: 7
Joined: 2015-07-02T10:05:21-07:00
Authentication code: 1151

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

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

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

Post 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).
vadim
Posts: 7
Joined: 2015-07-02T10:05:21-07:00
Authentication code: 1151

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

Post by vadim »

"-define png:exclude-chunks=bkgd"
Thank you, that solved my problem.
Post Reply