| 28 | |
| 29 | |
| 30 | def test_img_data_to_png_data() -> None: |
| 31 | img_file = data_dir / "annotated_with_data/apc2016_obj3.jpg" |
| 32 | img_data = img_file.read_bytes() |
| 33 | png_data = image_module.img_data_to_png_data(img_data) |
| 34 | assert png_data[:8] == b"\x89PNG\r\n\x1a\n" |
| 35 | np.testing.assert_array_equal( |
| 36 | np.asarray(PIL.Image.open(io.BytesIO(png_data))), |
| 37 | np.asarray(PIL.Image.open(io.BytesIO(img_data))), |
| 38 | err_msg="pixels must survive the PNG re-encode", |
| 39 | ) |
| 40 | |
| 41 | |
| 42 | def _make_jpeg_with_red_marker(orientation: int) -> PIL.Image.Image: |