azaghal / pydenticon

Pydenticon is a small utility library that can be used for deterministically generating identicons based on the hash of provided data.
BSD 3-Clause "New" or "Revised" License
66 stars 10 forks source link

Transparency not working #6

Closed ZmjbS closed 7 years ago

ZmjbS commented 8 years ago

I didn't find anything about transparent colours in the usage docs. It would be great to be able to define the colours and background as RGBA values as opposed to RGB.

azaghal commented 8 years ago

Hm... Thanks for reporting. I'll try to have a look at it and see what can be done. Definitively it is not possible to specify transparency at the moment. Might be time to do some small coding to make a new release.

azaghal commented 7 years ago

Ok, just had a very, very quick look at this, and it seems it will be a very simple fix. In fact, I think all that is needed to support transparency will be 1 character :)

So, this:

image = Image.new("RGB", (width + padding[2] + padding[3], height + padding[0] + padding[1]), background)

Would need to be changed to this:

image = Image.new("RGBA", (width + padding[2] + padding[3], height + padding[0] + padding[1]), background)

Afterwards it should be possible to specify foreground via, say, "rgba(255,255,255,0)" or "#ffffff00".

I'll look into this during weekend (want to have a look at another issue while at it for more formats).

azaghal commented 7 years ago

Fixed, including some docs + test updates. Using RGBA will slightly increase image sizes, but I don't think it's worth it to add more logic around (to pick when to choose which one). Will be part of Pydenticon 0.3 release later today.