change colors in indexed png (all files in folder)

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
ohnonot
Posts: 13
Joined: 2012-09-12T03:41:25-07:00
Authentication code: 67789

change colors in indexed png (all files in folder)

Post by ohnonot »

hello everybody,

i have a large amount of small png's in a folder. i want to replace white with another color in all of them with this:

Code: Select all

mogrify *.png -opaque "#ffffff" -fill "#e6d6b7"
but nothing happens.

the png's are indexed and i thought it's because of that, so i tried to first change that to normal rgb (?) with different variations of

Code: Select all

mogrify [-format...|-define...|-type...] *.png
- and then try the first command again - but nothing changes.

please help, i've been trying and searching for hours!

ps: i copied all pics to a new folder and try to work agressively, directly overwriting the original.
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: change colors in indexed png (all files in folder)

Post by glennrp »

Try

Code: Select all

  mogrify -fill "#e6d6b7" -opaque "#ffffff *.png 
ohnonot
Posts: 13
Joined: 2012-09-12T03:41:25-07:00
Authentication code: 67789

Re: change colors in indexed png (all files in folder)

Post by ohnonot »

glennrp wrote:Try

Code: Select all

  mogrify -fill "#e6d6b7" -opaque "#ffffff *.png 
now it works!
i had tried it also with *.png in the end.
but -fill has to come before -opaque, is that it?
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: change colors in indexed png (all files in folder)

Post by glennrp »

ohnonot wrote:but -fill has to come before -opaque, is that it?
Yes. "-fill" is an "image setting" and "-opaque" is an "image operator".
Settings take effect immediately where they appear on the commandline
and they persist. Operators take effect immediately using whatever settings
have appeared previously on the commandline. See
http://www.imagemagick.org/script/comma ... essing.php
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: change colors in indexed png (all files in folder)

Post by anthony »

It is done that way as it is the only way to ensure the setting you apply actually should be applied to the specific operator. If you don't have it this way you get problems when dealing with multiple operators.

The order of settings before each operator does not matter, as long as the operators are after the approparite settings, and the order of the operators is the order you want. But remember settings remain set for ALL later operators unless reset using the '+' form of the setting (no argument).

See IM Examples, Basics...
http://www.imagemagick.org/Usage/basics/
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
ohnonot
Posts: 13
Joined: 2012-09-12T03:41:25-07:00
Authentication code: 67789

Re: change colors in indexed png (all files in folder)

Post by ohnonot »

thank you both for the explanation!
Post Reply