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 the unpackI16B_I16 unpacker to unpackers #7124

Closed
FirefoxMetzger opened this issue Apr 29, 2023 · 2 comments · Fixed by #7125
Closed

Add the unpackI16B_I16 unpacker to unpackers #7124

FirefoxMetzger opened this issue Apr 29, 2023 · 2 comments · Fixed by #7125

Comments

@FirefoxMetzger
Copy link
Contributor

I would like to propose to add a new unpacker to Unpack.c that can unpack big-endian 16-bit integer pixels (I;16B) into 16-bit integer pixels (I;16, I assume native or does it mean little-endian?).

At the moment, the following conversions are supported:

Pillow/src/libImaging/Unpack.c

Lines 1761 to 1773 in 139acc4

/* storage modes */
{"I;16", "I;16", 16, copy2},
{"I;16B", "I;16B", 16, copy2},
{"I;16L", "I;16L", 16, copy2},
{"I;16N", "I;16N", 16, copy2},
{"I;16", "I;16N", 16, unpackI16N_I16}, // LibTiff native->image endian.
{"I;16L", "I;16N", 16, unpackI16N_I16}, // LibTiff native->image endian.
{"I;16B", "I;16N", 16, unpackI16N_I16B},
{"I;16", "I;16R", 16, unpackI16R_I16},
{"I;16", "I;12", 12, unpackI12_I16}, // 12 bit Tiffs stored in 16bits.

and it would be really useful for me to also have I;16B->I;16 as well.

My use case is 16-bit PNGs, which I could then directly unpack into a 16-bit buffer. Currently, we can only unpack them into a 32-bit (I) buffer or a 16-bit big-endian buffer (I;16B), so I have to copy the data one more time from that buffer into I;16. With this small addition I could avoid/save this copy :)

@FirefoxMetzger FirefoxMetzger changed the title Add unpackI16B_I16 unpacker to unpackers Add the unpackI16B_I16 unpacker to unpackers Apr 29, 2023
@radarhere
Copy link
Member

I've created PR #7125 to resolve this.

@FirefoxMetzger
Copy link
Contributor Author

Awesome! Thanks for this @radarhere 🚀

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 a pull request may close this issue.

2 participants