Page 1 of 1

change colors in indexed png (all files in folder)

Posted: 2012-09-12T05:00:43-07:00
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.

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

Posted: 2012-09-12T06:20:07-07:00
by glennrp
Try

Code: Select all

  mogrify -fill "#e6d6b7" -opaque "#ffffff *.png 

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

Posted: 2012-09-12T07:31:32-07:00
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?

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

Posted: 2012-09-12T08:42:25-07:00
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

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

Posted: 2012-09-12T19:43:19-07:00
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/

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

Posted: 2012-09-29T01:54:12-07:00
by ohnonot
thank you both for the explanation!