Question

Here's my code:

import cairo
import os
from PIL import Image

imagesize = (512,128)
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, *imagesize)

cr = cairo.Context(surface)

cr.select_font_face("Verdana", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
cr.set_font_size(24)
cr.set_source_rgb(1, 1, 1)

...

surface.write_to_png("MyImage.png")

As you can see I'm drawing some white text to this PNG, but the background defaults to an opaque black. How do I make the png transparent so that only the white text is showing?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top