Page 1 of 1
Replace solid color with oriented gradient
Posted: 2013-06-03T07:40:08-07:00
by Tyvain
Hello all,
I am trying to make a script to replace a color from an image with a gradient oriented one. The goal is make an animated image with the gradient color turning.
I try diffrent commands but was unable to do it. My main problem is that this command "convert source.jpg -size 1000x496 gradient:yellow-green -opaque "#0973A5" res2.jpg" create a square gradient, and not a gradient replacing the given color.
here is my source image:
here is what i would like to have in result (the angle of the gradient can change):
i someone can help please.
Sorry if my english is not very good.
Thank you.
Re: Replace solid color with oriented gradient
Posted: 2013-06-03T09:10:42-07:00
by snibgo
I would break the problem down into stages. One stage is to replace the solid blue with a gradient blue. You can create the gradient blue (Windows script), at any angle you want:
Code: Select all
convert -size 140x140 gradient:rgb(0,0,64)-rgb(200,200,255) -rotate 45 +repage grad1.png
I will make the solid blue transparent, and overlay the result over the gradient. But the background is already transparent, so I will first make that red.
Code: Select all
convert ring.png ( +clone -fill Red -colorize 100 ) +swap -composite rNT.png
set COL1=rgb(0,147,238)
convert rNT.png -transparent %COL1% r2.png
convert grad1.png r2.png -gravity center -composite -crop 96x96+0+0 +repage r.png
Re: Replace solid color with oriented gradient
Posted: 2013-06-03T09:51:07-07:00
by fmw42
removed -- misread the issue
Re: Replace solid color with oriented gradient
Posted: 2013-06-05T07:19:55-07:00
by Tyvain
snibgo wrote:I would break the problem down into stages. One stage is to replace the solid blue with a gradient blue. You can create the gradient blue (Windows script), at any angle you want:
Code: Select all
convert -size 140x140 gradient:rgb(0,0,64)-rgb(200,200,255) -rotate 45 +repage grad1.png
I will make the solid blue transparent, and overlay the result over the gradient. But the background is already transparent, so I will first make that red.
Code: Select all
convert ring.png ( +clone -fill Red -colorize 100 ) +swap -composite rNT.png
set COL1=rgb(0,147,238)
convert rNT.png -transparent %COL1% r2.png
convert grad1.png r2.png -gravity center -composite -crop 96x96+0+0 +repage r.png
wow thank you very much!!
this is working great and do exactly what i need!!
Re: Replace solid color with oriented gradient
Posted: 2016-02-22T05:01:07-07:00
by king111
snibgo wrote:I would break the problem down into stages. One stage is to replace the solid blue with a gradient blue. You can create the gradient blue (Windows script), at any angle you want:
Code: Select all
convert -size 140x140 gradient:rgb(0,0,64)-rgb(200,200,255) -rotate 45 +repage grad1.png
I will make the solid blue transparent, and overlay the result over the gradient. But the background is already transparent, so I will first make that red.
Code: Select all
convert ring.png ( +clone -fill Red -colorize 100 ) +swap -composite rNT.png
set COL1=rgb(0,147,238)
convert rNT.png -transparent %COL1% r2.png
convert grad1.png r2.png -gravity center -composite -crop 96x96+0+0 +repage r.png
Can you tell all the steps for PHP ?
Re: Replace solid color with oriented gradient
Posted: 2016-02-22T05:18:23-07:00
by snibgo
Put each "convert" command in an exec().