Page 1 of 1

Generate Gradient size based on existing image

Posted: 2014-09-22T19:14:46-07:00
by ziongates
Greetings Gurus,

I have a command line which works fine except for the hardcoded image size. It overlays a gradient onto an image.
How can the command dynamically generate the Gradient Size automatically based on the current image being processed ("%x") ?

This is the windows command line.

composite.exe -compose Dst_In "%x" ( -size 24x24 gradient:black-white -alpha Set ) png32:"%x"

Re: Generate Gradient size based on existing image

Posted: 2014-09-22T19:58:22-07:00
by fmw42
You need to use -sparse-color barycentric. See http://www.imagemagick.org/Usage/canvas ... _gradients

In unix syntax, it would be

Code: Select all

convert image \
\( -clone 0 -sparse-color Barycentric '0,0 white  0,%[fx:h-1] black' \) \
...

In windows, I believe it would be

Code: Select all

convert image ^
( -clone 0 -sparse-color Barycentric '0,0 white  0,%[fx:h-1] black' ) ^
...
The code in parenthesis will create the gradient.

The following ... means put whatever code you want. If you want to do compositing, you probably need to use the convert -compose composemethod -composite style syntax. See http://www.imagemagick.org/Usage/compose/

Re: Generate Gradient size based on existing image

Posted: 2014-09-23T11:21:06-07:00
by ziongates
Thanks Fred, that's it!