timberline-secondary / hackerspace-scripts-2

Python based control panel and scripts for managing Timberline's Digital Hackerspace
GNU General Public License v3.0
3 stars 1 forks source link

fix: png transparency #148

Closed punctuations closed 1 year ago

punctuations commented 1 year ago

DESCRIPTION:

Fix png transparency, in this it will also now basically just remove alpha channel and keep whatever colour was supposed to be there (just without transparency)

TECHNICAL CHANGES:

RELATED ISSUES:

tylerecouture commented 1 year ago

How does it know what color was supposed to be there? What about fully transparent pixels?

punctuations commented 1 year ago

because the channels are broken up into rgba values like so:

rgba(255, 255, 255, 0) <-- (using CSS notation to visualize) This conversion essentially just removes alpha channel, transparent pixels will just be pixels that have an alpha value of 0, they will have a colour set by default so it will just have it has that

tylerecouture commented 1 year ago

I'm worried the backgrounds will go white (e.g. 255, 255, 255, 0), instead of black.

Can you test with some of our gifs and other transparent content? SVG, etc?

punctuations commented 1 year ago

I mean it will if the pixel states that its a transparent white pixel, do want me to just replace all fully transparent pixels with black pixels?

tylerecouture commented 1 year ago

Yes, if it's easy, that would prevent some unwanted surprises

punctuations commented 1 year ago

I made a change to go back to using the old way in that case, to just have a black background instead.

If I remember correct the actual problem wasn't removal of transparency per say but it just needed a black background so you didn't see the other images behind it?

If this was the issue this commit will fix as the only thing I changed from the original (before this issue) was checking to make sure both modes are the same (which is why the image in the issue was failing), the image in the original issue was a .png but without an alpha channel meaning it had its mode as RGB, whereas it was being pasted on an image (all back to act as a background) that has the mode of RGBA, throwing a transparency mask error. < -- This issue has been fixed in the latest commit.

tylerecouture commented 1 year ago

Excellent. Please test it with a transparent gif as well, to make sure that process wasn't broken

punctuations commented 1 year ago

I did, a fully transparent gif will just be all black