diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2022-04-15 14:43:53 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2022-04-15 14:43:53 -0700 |
commit | c3dcc4d3b29edb1a5ddafa14964488c88be02a5d (patch) | |
tree | bd4899c3837286b930aab5a66b1cae66f08c0c51 | |
parent | 81d1de74b10ca110abaafe2ccd881d9448377093 (diff) |
Cherry-pick upstream commit 4f6923f
-rw-r--r-- | debian/changelog | 7 | ||||
-rw-r--r-- | debian/patches/Fix-palette-handling-for-Pillow-9.1.0.patch | 46 | ||||
-rw-r--r-- | debian/patches/series | 1 |
3 files changed, 54 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog index 8031f76..c217935 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +pikepdf (5.1.1+dfsg-1) UNRELEASED; urgency=medium + + * New upstream release. + * Cherry-pick upstream commit 4f6923f (Closes: #1009737). + + -- Sean Whitton <spwhitton@spwhitton.name> Fri, 15 Apr 2022 14:41:24 -0700 + pikepdf (5.0.1+dfsg-1) unstable; urgency=medium * New upstream release. diff --git a/debian/patches/Fix-palette-handling-for-Pillow-9.1.0.patch b/debian/patches/Fix-palette-handling-for-Pillow-9.1.0.patch new file mode 100644 index 0000000..e74a180 --- /dev/null +++ b/debian/patches/Fix-palette-handling-for-Pillow-9.1.0.patch @@ -0,0 +1,46 @@ +From: "James R. Barlow" <james@purplerock.ca> +Date: Fri, 15 Apr 2022 00:58:07 -0700 +Subject: Fix palette handling for Pillow 9.1.0 + +(cherry picked from commit 4f6923fe33c2d7e78d1482a5eb2beb6e9155977b) +--- + src/pikepdf/models/_transcoding.py | 9 ++++----- + tests/test_image_access.py | 3 ++- + 2 files changed, 6 insertions(+), 6 deletions(-) + +diff --git a/src/pikepdf/models/_transcoding.py b/src/pikepdf/models/_transcoding.py +index 7e26381..1bfc3d1 100644 +--- a/src/pikepdf/models/_transcoding.py ++++ b/src/pikepdf/models/_transcoding.py +@@ -163,13 +163,12 @@ def fix_1bit_palette_image( + im: Image.Image, base_mode: str, palette: BytesLike + ) -> Image.Image: + """Apply palettes to 1-bit images.""" +- if base_mode == 'RGB' and palette != b'\x00\x00\x00\xff\xff\xff': ++ if base_mode == 'RGB': + im = im.convert('P') ++ if len(palette) == 6: ++ # rgbrgb -> rgb000000...rgb ++ palette = palette[0:3] + (b'\x00\x00\x00' * (256 - 2)) + palette[3:6] + im.putpalette(palette, rawmode=base_mode) +- gp = im.getpalette() +- if gp: +- gp[765:768] = gp[3:6] # work around Pillow bug +- im.putpalette(gp) + elif base_mode == 'L' and palette != b'\x00\xff': + im = im.convert('P') + try: +diff --git a/tests/test_image_access.py b/tests/test_image_access.py +index 512c2ca..11a3b97 100644 +--- a/tests/test_image_access.py ++++ b/tests/test_image_access.py +@@ -516,7 +516,8 @@ def test_image_palette(resources, filename, bpc, rgb): + outstream = BytesIO() + pim.extract_to(stream=outstream) + +- im = pim.as_pil_image().convert('RGB') ++ im_pal = pim.as_pil_image() ++ im = im_pal.convert('RGB') + assert im.getpixel((1, 1)) == rgb + + diff --git a/debian/patches/series b/debian/patches/series index 887982c..93e1509 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,3 +1,4 @@ docs-build-use-DEB_VERSION_UPSTREAM.patch drop-installation-from-docs-contents.patch drop-save-pike.patch +Fix-palette-handling-for-Pillow-9.1.0.patch |