(tmp_path: Path, mode: str)
| 30 | |
| 31 | @pytest.mark.parametrize("mode", ("L", "I;16", "I;16B", "I;16L", "I")) |
| 32 | def test_basic(tmp_path: Path, mode: str) -> None: |
| 33 | # PIL 1.1 has limited support for 16-bit image data. Check that |
| 34 | # create/copy/transform and save works as expected. |
| 35 | |
| 36 | im_in = original.convert(mode) |
| 37 | verify(im_in) |
| 38 | |
| 39 | w, h = im_in.size |
| 40 | |
| 41 | im_out = im_in.copy() |
| 42 | verify(im_out) # copy |
| 43 | |
| 44 | im_out = im_in.transform((w, h), Image.Transform.EXTENT, (0, 0, w, h)) |
| 45 | verify(im_out) # transform |
| 46 | |
| 47 | filename = tmp_path / "temp.im" |
| 48 | im_in.save(filename) |
| 49 | |
| 50 | with Image.open(filename) as im_out: |
| 51 | verify(im_in) |
| 52 | verify(im_out) |
| 53 | |
| 54 | im_out = im_in.crop((0, 0, w, h)) |
| 55 | verify(im_out) |
| 56 | |
| 57 | im_out = Image.new(mode, (w, h), None) |
| 58 | im_out.paste(im_in.crop((0, 0, w // 2, h)), (0, 0)) |
| 59 | im_out.paste(im_in.crop((w // 2, 0, w, h)), (w // 2, 0)) |
| 60 | |
| 61 | verify(im_in) |
| 62 | verify(im_out) |
| 63 | |
| 64 | im_in = Image.new(mode, (1, 1), 1) |
| 65 | assert im_in.getpixel((0, 0)) == 1 |
| 66 | |
| 67 | im_in.putpixel((0, 0), 2) |
| 68 | assert im_in.getpixel((0, 0)) == 2 |
| 69 | |
| 70 | if mode == "L": |
| 71 | maximum = 255 |
| 72 | else: |
| 73 | maximum = 32767 |
| 74 | |
| 75 | im_in = Image.new(mode, (1, 1), 256) |
| 76 | assert im_in.getpixel((0, 0)) == min(256, maximum) |
| 77 | |
| 78 | im_in.putpixel((0, 0), 512) |
| 79 | assert im_in.getpixel((0, 0)) == min(512, maximum) |
| 80 | |
| 81 | |
| 82 | def test_tobytes() -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…