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.
Replace solid color with oriented gradient
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Replace solid color with oriented gradient
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:
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 -size 140x140 gradient:rgb(0,0,64)-rgb(200,200,255) -rotate 45 +repage grad1.png
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
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Replace solid color with oriented gradient
removed -- misread the issue
Re: Replace solid color with oriented gradient
wow thank you very much!!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: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 -size 140x140 gradient:rgb(0,0,64)-rgb(200,200,255) -rotate 45 +repage grad1.png
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
this is working great and do exactly what i need!!
Re: Replace solid color with oriented gradient
Can you tell all the steps for PHP ?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: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 -size 140x140 gradient:rgb(0,0,64)-rgb(200,200,255) -rotate 45 +repage grad1.png
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
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Replace solid color with oriented gradient
Put each "convert" command in an exec().
snibgo's IM pages: im.snibgo.com