0

Looking at creating gradients with imagemagick (or here using sparse-color) I can only see how to make a linear gradient between points. But how could I make a non-linear gradient? Like, how to I assign more weight to one of the points in the gradient? For example I'm using this line to assign some diagonal transparency to an image:

convert in.png -alpha set -background none -channel A \
-sparse-color barycentric "0,%[h] none -%w,0 none %w,0 white" +channel out.png

But I'd like more transparency. I'd like the gradient to be more weighted towards the transparent points. Quadratic gradient? Maybe something like this shepard's power method, but if I could assign different powers to each point? Can this be done?

1 Answer 1

1

I think the best way to work with this is to compose the transparency gradient as a greyscale and the use copy-opacity to shunt that into the alpha channel. In your example, the image itself would be all white with a gradient alpha.

You can do functions and math with imagemagick, so something like gradient: -function Polynomial -4,4,0 -evaluate Pow 0.9 would be be black-white-black. The 4-point gradient examples in your cite also would work if conceived as a greyscale and set for the alpha.

Helpful resource (far too in depth to properly quote): http://im.snibgo.com/gradients.htm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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