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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions Tests/test_image_getextrema.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import pytest
from PIL import Image

from .helper import hopper, is_big_endian, on_ci
from .helper import hopper


@pytest.mark.xfail(is_big_endian() and on_ci(), reason="Fails on big-endian")
def test_extrema():
def extrema(mode):
return hopper(mode).getextrema()
Expand All @@ -20,7 +18,6 @@ def extrema(mode):
assert extrema("I;16") == (1, 255)


@pytest.mark.xfail(is_big_endian() and on_ci(), reason="Fails on big-endian")
def test_true_16():
with Image.open("Tests/images/16_bit_noise.tif") as im:
assert im.mode == "I;16"
Expand Down
14 changes: 12 additions & 2 deletions src/libImaging/GetBBox.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,21 @@ ImagingGetExtrema(Imaging im, void *extrema)
case IMAGING_TYPE_SPECIAL:
if (strcmp(im->mode, "I;16") == 0) {
UINT16 v;
memcpy(&v, *im->image8, sizeof(v));
UINT8* pixel = *im->image8;
#ifdef WORDS_BIGENDIAN
v = pixel[0] + (pixel[1] << 8);
#else
memcpy(&v, pixel, sizeof(v));
#endif
imin = imax = v;
for (y = 0; y < im->ysize; y++) {
for (x = 0; x < im->xsize; x++) {
memcpy(&v, im->image[y] + x * sizeof(v), sizeof(v));
pixel = im->image[y] + x * sizeof(v);
#ifdef WORDS_BIGENDIAN
v = pixel[0] + (pixel[1] << 8);
#else
memcpy(&v, pixel, sizeof(v));
#endif
if (imin > v)
imin = v;
else if (imax < v)
Expand Down