Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserving transparent pixels in image sort. #5

Open
zroper opened this issue May 26, 2020 · 2 comments
Open

Preserving transparent pixels in image sort. #5

zroper opened this issue May 26, 2020 · 2 comments

Comments

@zroper
Copy link

zroper commented May 26, 2020

Great app! I've been using it to generate some artwork using .png input images that have transparent backgrounds. Whenever I run those images through the application, the transparent pixels output black. Is there any way to preserve the transparent pixels in the original image so that they are also present in the output?

@rkargon
Copy link
Owner

rkargon commented May 26, 2020

Hmmm, I haven't looked at this codebase in a while, but based on a cursory look just now a lot of the codebase assumes the image data is in (R,G,B) tuples — specifically all the sorting functions and "key" functions.

it might be as simple as loading the image from PIL w/ a different mode in sort_image_with_cli_args (specifically the get_data() call), and passing in (R,G,B,A) tuples, and hoping most of the code doesn't explicitly require three channels per pixel. I can test this out next weekend when I'm free / feel free to try it out yourself.

@zroper
Copy link
Author

zroper commented Jun 2, 2020

Thanks for the response! After looking into this, the app is correctly detecting the image mode input (RGBA), but there was this pesky check in pixelsort.py lines 260-261:

  if img.mode != "RGB" and not gif:
        img = img.convert(mode="RGB")

After commenting this out, the alpha pixels are preserved in the output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants