Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Similar to the mass rescaling command this site taught me here, is there a command-line trick for mass recoloring?

To make it specific, suppose I have a bunch of images with RGB and alpha values:


and so on. I want to have a command-line command to give me the following:


where in each case, the R, G, and B values for each pixel have been multiplied by 1, 0.5, and 0, respectively, and the alpha has been left alone. Is that possible?

share|improve this question
up vote 3 down vote accepted

Thanks Ignacio for the great hint. Based on it, here are the answers:

First of all, to convert a single file. Say we want to convert test.png to orangeTest.png, multiplying R, G, and B by 1.0, 0.5, and 0.0, respectively. Here is the command:

convert test.png xc:'rgb(255,127,0)' -fx 'u*v.p{0,0}' orangeTest.png

Now, for the mass conversion:

for i in *.png; 
   do convert "$i" xc:'rgb(255,127,0)' -fx 'u*v.p{0,0}' "${i%.*}_orange.png"; 
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .