Page 1 of 1

Replace/change/shift colors

Posted: 2017-03-13T06:21:51-07:00
by mideal
Hi1
While changing a (Linux Mint 18.1 Cinnamon) theme a encountered a folder with 50+ png files with buttons and such things.
There are all in varaitions of mintish green of different brightness (for checked/unchecked, presses/release...), and I like to change all those with a batch command to similar variations blue.
Easy replacement isn't possible because of the different shades of the source.

I found this (to change from green to red):

Code: Select all

convert some_image.jpg \( +clone -channel G -fx R \) +swap -channel R -fx v.G swapped.jpg
here: http://www.linuxquestions.org/questions ... ost5682829, changing it to

Code: Select all

convert checkbox-checked-dark@2.png \( +clone -channel B -fx G \) +swap -channel G -fx v.B swapped.png
results in a quite violet touch.

Any suggestions?

Re: Replace/change/shift colors

Posted: 2017-03-13T07:16:19-07:00
by GeeMack
mideal wrote: 2017-03-13T06:21:51-07:00There are all in varaitions of mintish green of different brightness (for checked/unchecked, presses/release...), and I like to change all those with a batch command to similar variations blue.
It may not be exactly what you want, but you can use the "-modulate" operator to more or less roll the colors around the wheel. The operator takes up to three arguments. The one you want to adjust for color shifting is the third. A command like this should give you an idea what it can do...

Code: Select all

convert input.png -modulate 100,100,50 output.png
That third argument, where I used a value of 50, can take any number from 0 to 200. Use 100 for no change, and higher or lower values to shift around the color wheel. You can learn more about color modifications at THIS link.

Re: Replace/change/shift colors

Posted: 2017-03-13T09:53:17-07:00
by mideal
It seems that you have to try a bit with one or two examples to get the expected result color.
90,180,170 gives me the nice blue tones I wanted for all shades in the theme.

Thank you!

Re: Replace/change/shift colors

Posted: 2017-03-13T10:38:31-07:00
by snibgo
Yes, K as well as the first three channels (RGB or CMY). I work almost exclusively with RGB, so I usually forget about the K channel.

Re: Replace/change/shift colors

Posted: 2017-03-13T19:36:14-07:00
by anthony
I recommend modulating in a different cyclic hue colorspace such as LCHab as it will preserve the color intensity better, though the hue values are slightly different.

See Modulate in LCHab and other Colorspaces