Skip to content
Advertisement

PIL Drawing a semi-transparent square overlay on image

JavaScript

This is giving me a giant black square. I want it to be a semi transparent black square with a cat. Any Ideas?

Advertisement

Answer

Sorry, the comment I made about it being a bug was incorrect, so…

You can do it by creating a temporary image and using Image.alpha_composite() as shown in the code below. Note that it supports semi-transparent squares other than black.

JavaScript

Here’s the result of applying it to your test image:

picture of a cat with blacken square rectangle superimposed on it

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement