Dropping colors

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
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

Well -scale 100% is a no-op. that is it doesn nothing!

As for your problem. I currently know of no way to remove the colors specified by an image from another image. It is not a common thing to do.

You can however re-map specific colors Eg:

Code: Select all

   convert input.png  -transparency green  output.png
will remove all perfect green colors from the image.
For imperfect or 'near' matchs you can add a 'fuzz factor'. See IM examples...
http://www.cit.gu.edu.au/~anthony/graph ... olor/#fuzz

However you can generate a command to do this type of thing! the 'txt:' image format will list the colors in the map into a format that IM can handle.

Code: Select all

  convert colormap.png -unique-colors txt:-
From this you can pull out a column or IM parsable colors, append a "-transparent" to the front of each color and add the result to a command line to convert those colors to transparency.

Code: Select all

convert colormap.png -unique-colors txt:- | \
   sed '1d; s/.*#/#/; s/ .*//; s/^/-transparent /' > remove_colors_args
   convert input.png  `cat remove_colors_args`  output.png
It is scripty, requiring multiple commands and output re-processing, but it should work for a small number of unique colors.

If anyone has a better idea, or a way to replace one colormap for another, PLEASE let us know.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

If you find a better way, or even a colormap to colormap transformation, PLEASE let us know. Or you could try to add a function to do it. It is an area of IM that is lacking.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

The first section of txt: output is always the same. the RGB and posibly A numbers at the depth setting in force when written. Anything else should however be one or two colors of colors in a format that IM can undersand AS IS.

As such if you see 'grey8' then you can use grey8 as the color argument to IM.

See IM Examples. 'Text Image Format'
http://www.cit.gu.edu.au/~anthony/graph ... files/#txt
for more details.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply