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

Add packers for RGB;15/16 and BGR;15/16 #8019

Closed
wants to merge 1 commit into from

Conversation

Yay295
Copy link
Contributor

@Yay295 Yay295 commented Apr 26, 2024

I made these to be the opposite of the unpackers for these rawmodes, but this conversion method isn't actually roundtrippable. I know of two other methods that are roundtrippable, but I would have to change the unpackers as well for that.

@radarhere
Copy link
Member

What is the motivation behind this? Are these packers something that you plan on using in your own external code that uses Pillow?

@Yay295
Copy link
Contributor Author

Yay295 commented Apr 26, 2024

It's currently possible to create or convert an image to BGR;15/16 and save it as that mode because there's a copy packer for those modes, but when those modes are removed that will no longer be possible. By adding these packers it will still be possible to save data in these formats.

I added the RGB versions because it's basically the same code with just two variables swapped.

@radarhere
Copy link
Member

radarhere commented Apr 26, 2024

So to demonstrate in code, your plan is for any user currently running

from PIL import Image
im = Image.new("RGB", (1, 1))
im.convert("BGR;15").tobytes()

to instead transition to running

from PIL import Image
im = Image.new("RGB", (1, 1))
im.tobytes("raw", "BGR;15")

Others should feel free to chime in with their thoughts, but I would think that the modes are being deprecated because they aren't used by any image format, and since we added our very rudimentary support for these modes, there's never been an issue from anyone using them. Because they're not used, we don't need to try and offer a workaround for this functionality when it is removed.

If you're aware of a portion of users that are using BGR;15 and BGR;16 in this way, feel free to say so.

@radarhere
Copy link
Member

If you've moved on and are coming up with a different plan, can this be closed?

@Yay295 Yay295 closed this Apr 28, 2024
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

Successfully merging this pull request may close these issues.

None yet

2 participants