Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Tests/test_image_resize.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@ def test_endianness(
# as separately resized channel
assert_image_equal(ch, references[channels[i]])

@pytest.mark.parametrize("mode", ("I;16", "I;16L", "I;16B", "I;16N"))
def test_i16(self, mode: str) -> None:
im = Image.new(mode, (1, 2))
im.putdata((0x0099, 0x0100))
resized = self.resize(im, (1, 1), Image.Resampling.BICUBIC)
assert resized.getpixel((0, 0)) == 0x00CD

@pytest.mark.parametrize(
"resample",
(
Expand Down
7 changes: 7 additions & 0 deletions docs/releasenotes/13.1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ TODO
Other changes
=============

Resizing I;16B and I;16N images
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

On little-endian systems, :py:meth:`~PIL.Image.Image.resize` read and wrote
I;16B and I;16N pixel values in the wrong byte order when using a resampling
filter other than ``Resampling.NEAREST``. This has been fixed.

Blurring I;16 images
^^^^^^^^^^^^^^^^^^^^

Expand Down
8 changes: 4 additions & 4 deletions src/libImaging/Resample.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,9 +551,9 @@ _ImagingResampleHorizontal_16bpc(

int bigendian = 0;
if (
imIn->mode == IMAGING_MODE_I_16N
imIn->mode == IMAGING_MODE_I_16B
#ifdef WORDS_BIGENDIAN
|| imIn->mode == IMAGING_MODE_I_16B
|| imIn->mode == IMAGING_MODE_I_16N
#endif
) {
bigendian = 1;
Expand Down Expand Up @@ -602,9 +602,9 @@ _ImagingResampleVertical_16bpc(

int bigendian = 0;
if (
imIn->mode == IMAGING_MODE_I_16N
imIn->mode == IMAGING_MODE_I_16B
#ifdef WORDS_BIGENDIAN
|| imIn->mode == IMAGING_MODE_I_16B
|| imIn->mode == IMAGING_MODE_I_16N
#endif
) {
bigendian = 1;
Expand Down
Loading