How to draw transparency using :egd?

I cannot get drawing transparency to work. How can I make :egd to set alpha properly?

image = :egd.create(100, 100)
# Use any color with alpha = 0
:egd.filledRectangle(image, {0, 0}, {99, 99}, :egd.color({25, 123, 0, 0}))
:egd.render(image, :png)
# or :egd.render(image, :png, [render_engine: :alpha])
:edg.save(image, "image.png")

The above produces solid-color image, instead a transparent one. Am I doing something wrong?

Thanks!

Wow, the :egd documentation is not very expansive!

The only thing I can think of is to assert on the function. It’s a strange module in that it mutates too! Perhaps try this and see if you get any exceptions?

image = :egd.create(100, 100)
# Use any color with alpha = 0
:ok = :egd.filledRectangle(image, {0, 0}, {99, 99}, :egd.color({25, 123, 0, 0}))
:edg.save(image, "image.png")

Edit:

Hmmm since you get a solid color image I guess the filledRectangle/4 call is working as expected.

I get an exception, but because not calling render first makes image invalid type for save. render returns Binary::binary() which save excepts. Before call to render, image is of type Image::egd_image().