mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Limit tile size to avoid extending outside image
This commit is contained in:
parent
e80ddfd2b6
commit
4d6e5a0d09
BIN
Tests/images/input_bw_one_band.fpx
Normal file
BIN
Tests/images/input_bw_one_band.fpx
Normal file
Binary file not shown.
BIN
Tests/images/input_bw_one_band.png
Normal file
BIN
Tests/images/input_bw_one_band.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 477 B |
|
@ -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"
|
||||
|
|
|
@ -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),
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue
Block a user