diff --git a/Tests/images/input_bw_one_band.fpx b/Tests/images/input_bw_one_band.fpx new file mode 100644 index 00000000000..9bdc53763fe Binary files /dev/null and b/Tests/images/input_bw_one_band.fpx differ diff --git a/Tests/images/input_bw_one_band.png b/Tests/images/input_bw_one_band.png new file mode 100644 index 00000000000..6b4c1f37696 Binary files /dev/null and b/Tests/images/input_bw_one_band.png differ diff --git a/Tests/test_file_fpx.py b/Tests/test_file_fpx.py index 818565f88b3..fa22e90f660 100644 --- a/Tests/test_file_fpx.py +++ b/Tests/test_file_fpx.py @@ -2,11 +2,22 @@ from PIL import Image +from .helper import assert_image_equal_tofile + FpxImagePlugin = pytest.importorskip( "PIL.FpxImagePlugin", reason="olefile not installed" ) +def test_sanity(): + with Image.open("Tests/images/input_bw_one_band.fpx") as im: + assert im.mode == "L" + assert im.size == (70, 46) + assert im.format == "FPX" + + assert_image_equal_tofile(im, "Tests/images/input_bw_one_band.png") + + def test_invalid_file(): # Test an invalid OLE file invalid_file = "Tests/images/flower.jpg" diff --git a/src/PIL/FpxImagePlugin.py b/src/PIL/FpxImagePlugin.py index f955b234769..65962ac7ccc 100644 --- a/src/PIL/FpxImagePlugin.py +++ b/src/PIL/FpxImagePlugin.py @@ -160,7 +160,7 @@ def _open_subimage(self, index=1, subimage=0): self.tile.append( ( "raw", - (x, y, x + xtile, y + ytile), + (x, y, min(xsize, x + xtile), min(ysize, y + ytile)), i32(s, i) + 28, (self.rawmode,), )