Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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:

apple_original.png  
pear_original.png  
banana_original.png 

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

apple_orange.png  
pear_orange.png  
banana_orange.png 

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
add comment

2 Answers

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"; 
done
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.