Replace ANY colour Except #ffffff with #000000

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?".
Rye
Posts: 158
Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789

Re: Replace ANY colour Except #ffffff with #000000

Post by Rye »

Thats odd... when I execute that command once

Code: Select all

for %%x in (*gif) do convert %%x ( -clone 0 -fill black -colorize 100 ) +swap -alpha set ( -clone 1 ( -clone 0 +transparent #F4F4FC ) ( -clone 0 +transparent #F7F7FF ) ( -clone 0 +transparent #F9F9FF ) -delete 0 -evaluate set 0 -layers flatten -negate ) -compose Over -composite %%x
once, I get this:
Image

twice this:
Image

and three times this...
Image

and the colorize IS already on 100... either I'm missing something here... or...
Last edited by Rye on 2014-06-22T04:49:12-07:00, edited 1 time in total.
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Replace ANY colour Except #ffffff with #000000

Post by fmw42 »

Your image tags are malformed. They seem to be missing the closing [/img]


When in doubt, run the command on one single image and put -write statements throughout the code at the end of each parenthesis to check the progress of the commands and to be sure they are doing what is intended.

see
http://www.imagemagick.org/script/comma ... .php#write
http://www.imagemagick.org/Usage/files/#write (but do not add +delete as shown in these examples)
Rye
Posts: 158
Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789

Re: Replace ANY colour Except #ffffff with #000000

Post by Rye »

fixed
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Replace ANY colour Except #ffffff with #000000

Post by snibgo »

It needs a "-background White":

Code: Select all

convert ^
  s001.gif ^
  ( -clone 0 -fill Purple -colorize 100 ) ^
  +swap ^
  -alpha set ^
  ( -clone 1 ^
    ( -clone 0 +transparent #F4F4FC ) ^
    ( -clone 0 +transparent #F7F7FF ) ^
    ( -clone 0 +transparent #F9F9FF ) ^
    -delete 0 ^
    -evaluate set 0 ^
    -background White ^
    -layers flatten ^
    -negate ^
  ) ^
  -compose Over -composite ^
  s1.png
snibgo's IM pages: im.snibgo.com
Post Reply