spider labrec ceil

This commit is contained in:
nulano 2019-09-27 21:58:17 +02:00
parent 26babb525a
commit 17d9938ece
2 changed files with 13 additions and 1 deletions

View File

@ -1,4 +1,5 @@
import tempfile
from io import BytesIO
from PIL import Image, ImageSequence, SpiderImagePlugin
@ -117,3 +118,14 @@ class TestImageSpider(PillowTestCase):
for i, frame in enumerate(ImageSequence.Iterator(im)):
if i > 1:
self.fail("Non-stack DOS file test failed")
# for issue #4093
def test_odd_size(self):
data = BytesIO()
width = 100
im = Image.new("F", (width, 64))
im.save(data, format="SPIDER")
data.seek(0)
im2 = Image.open(data)
self.assert_image_equal(im, im2)

View File

@ -236,7 +236,7 @@ def loadImageSeries(filelist=None):
def makeSpiderHeader(im):
nsam, nrow = im.size
lenbyt = nsam * 4 # There are labrec records in the header
labrec = 1024 / lenbyt
labrec = int(1024 / lenbyt)
if 1024 % lenbyt != 0:
labrec += 1
labbyt = labrec * lenbyt