mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-07 13:25:24 +03:00
crop() with multi-band format
This commit is contained in:
parent
86e7fc6b82
commit
587bb98540
|
@ -877,11 +877,18 @@ class TestFileTiff:
|
|||
def test_open_tiff_uint16_multiband(self):
|
||||
"""Test opening multiband TIFFs and reading all channels."""
|
||||
|
||||
def getpixel00(im: Image.Image):
|
||||
def check_pixel(im: Image.Image, expected_pixel, pos: tuple[int, int]):
|
||||
actual_pixel = im.getpixel((0, 0))
|
||||
if isinstance(actual_pixel, int):
|
||||
actual_pixel = (actual_pixel,)
|
||||
return actual_pixel
|
||||
assert actual_pixel == expected_pixel
|
||||
|
||||
def check_image(im: Image.Image, width: int, height: int, expected_pixel):
|
||||
assert im.width == width
|
||||
assert im.height == height
|
||||
for x in range(im.width):
|
||||
for y in range(im.height):
|
||||
check_pixel(im, expected_pixel, (x, y))
|
||||
|
||||
base_value = 4660
|
||||
for i in range(1, 6):
|
||||
|
@ -890,10 +897,13 @@ class TestFileTiff:
|
|||
im = Image.open(infile)
|
||||
|
||||
im.load()
|
||||
assert getpixel00(im) == pixel
|
||||
check_image(im, 10, 10, pixel)
|
||||
|
||||
im.copy()
|
||||
assert getpixel00(im) == pixel
|
||||
im1 = im.copy()
|
||||
check_image(im1, 10, 10, pixel)
|
||||
|
||||
im2 = im.crop((2, 2, 7, 7))
|
||||
check_image(im2, 5, 5, pixel)
|
||||
|
||||
|
||||
@pytest.mark.skipif(not is_win32(), reason="Windows only")
|
||||
|
|
|
@ -37,7 +37,8 @@ ImagingCrop(Imaging imIn, int sx0, int sy0, int sx1, int sy1) {
|
|||
ysize = 0;
|
||||
}
|
||||
|
||||
imOut = ImagingNewDirty(imIn->mode, (ImagingNewParams){xsize, ysize});
|
||||
imOut = ImagingNewDirty(
|
||||
imIn->mode, (ImagingNewParams){xsize, ysize, imIn->depth, imIn->bands});
|
||||
if (!imOut) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user