Skip to content

How can I achieve a gradient font effect? #659

Answered by emcconville
Josh596 asked this question in Q&A
Discussion options

You must be logged in to vote

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 

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Josh596
Comment options

Answer selected by Josh596
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants