Skip to content

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

Closed
Yay295 wants to merge 1 commit into
python-pillow:mainfrom
Yay295:pack_rgbgr_1516
Closed

Yay295 wants to merge 1 commit into
python-pillow:mainfrom
Yay295:pack_rgbgr_1516

Conversation

@Yay295

@Yay295 Yay295 commented Apr 26, 2024

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

Yay295 commented Apr 26, 2024

Copy link
Copy Markdown
Contributor Author

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

radarhere commented Apr 26, 2024 •

Copy link
Copy Markdown
Member

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
Copy Markdown
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
@Yay295
Yay295 deleted the pack_rgbgr_1516 branch May 15, 2024 16:02
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.

2 participants