Skip to content

Conversation

@radarhere
Copy link
Member

When decoding JPEG2000 images in C, we allow for 3 codecs.

Pillow/src/decode.c

Lines 871 to 876 in 7dbcb32

if (strcmp(format, "j2k") == 0) {
codec_format = OPJ_CODEC_J2K;
} else if (strcmp(format, "jpt") == 0) {
codec_format = OPJ_CODEC_JPT;
} else if (strcmp(format, "jp2") == 0) {
codec_format = OPJ_CODEC_JP2;

But only 2 are ever set in Python.

self.codec = "j2k"
self._size, self._mode = _parse_codestream(self.fp)
self._parse_comment()
else:
sig = sig + self.fp.read(8)
if sig == b"\x00\x00\x00\x0cjP \x0d\x0a\x87\x0a":
self.codec = "jp2"

@hugovk hugovk changed the title Removed unused code Remove unused code Sep 4, 2025
@hugovk hugovk merged commit 29309e4 into python-pillow:main Sep 4, 2025
57 checks passed
@radarhere radarhere deleted the unused_code branch September 4, 2025 10:48
@hugovk hugovk added the changelog: skip Exclude PR from release draft label Oct 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: skip Exclude PR from release draft Cleanup

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants