How can I achieve a gradient font effect? #659
-
Hey everyone, I've been looking through the ImageMagick usage examples (https://imagemagick.org/Usage/fonts/) and came across the gradient font effect. However, I can't find an API or method in Wand to directly set the Is there a way to achieve this effect using Wand? Any help or guidance would be greatly appreciated! Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Try the following... from wand.drawing import Drawing
from wand.image import Image
WIDTH=320
HEIGHT=100
with Image(width=WIDTH, height=HEIGHT, pseudo='xc:lightblue') as background:
with Image(width=WIDTH, height=HEIGHT, pseudo='gradient:') as gradient:
with Image(width=WIDTH, height=HEIGHT, pseudo='xc:transparent') as text:
with Drawing() as ctx:
ctx.font = 'support/Candice.ttf'
ctx.font_size = 72
text.annotate('Anthony', ctx, 28, 68, 0)
gradient.composite(text, operator='copy_alpha')
background.composite(gradient, operator='over')
background.save(filename='output.png') ... or perhaps ... from wand.font import Font
from wand.image import Image
WIDTH=320
HEIGHT=100
with Image(width=WIDTH, height=HEIGHT, pseudo='xc:lightblue') as background:
with Image(width=WIDTH, height=HEIGHT, pseudo='gradient:') as gradient:
with Image() as text:
text.font = Font('support/Candice.ttf', 72)
text.gravity = 'center'
text.pseudo(width=WIDTH, height=HEIGHT, pseudo='caption:Anthony')
text.negate()
text.alpha_channel = 'copy'
gradient.composite(text, operator='copy_alpha')
background.composite(gradient, operator='over')
background.save(filename='output.png')
Sadly, some of those docs are out of date, and reference MVG operations that have been deprecated. Honestly, for the better as leveraging alpha channels, and composite methods are way faster then rendering complex effects. Best of luck! |
Beta Was this translation helpful? Give feedback.
Try the following...
... or perhaps ...
from