Merge pull request #6368 from radarhere/fpx

This commit is contained in:
Hugo van Kemenade 2022-06-16 12:03:54 +03:00 committed by GitHub
commit b3bc4a7bb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 3 deletions

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 B

View File

@ -2,11 +2,22 @@ import pytest
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"

View File

@ -154,13 +154,16 @@ class FpxImageFile(ImageFile.ImageFile):
for i in range(0, len(s), length):
x1 = min(xsize, x + xtile)
y1 = min(ysize, y + ytile)
compression = i32(s, i + 8)
if compression == 0:
self.tile.append(
(
"raw",
(x, y, x + xtile, y + ytile),
(x, y, x1, y1),
i32(s, i) + 28,
(self.rawmode,),
)
@ -172,7 +175,7 @@ class FpxImageFile(ImageFile.ImageFile):
self.tile.append(
(
"fill",
(x, y, x + xtile, y + ytile),
(x, y, x1, y1),
i32(s, i) + 28,
(self.rawmode, s[12:16]),
)
@ -201,7 +204,7 @@ class FpxImageFile(ImageFile.ImageFile):
self.tile.append(
(
"jpeg",
(x, y, x + xtile, y + ytile),
(x, y, x1, y1),
i32(s, i) + 28,
(rawmode, jpegmode),
)