7

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?

3

"Mathematical Linear Histogram Adjustments"

3

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

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

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