Round Spider record count (#4094)

Round Spider record count
This commit is contained in:
Hugo van Kemenade 2019-09-28 10:41:51 +03:00 committed by GitHub
commit 575a616bb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -1,4 +1,5 @@
import tempfile import tempfile
from io import BytesIO
from PIL import Image, ImageSequence, SpiderImagePlugin from PIL import Image, ImageSequence, SpiderImagePlugin
@ -117,3 +118,14 @@ class TestImageSpider(PillowTestCase):
for i, frame in enumerate(ImageSequence.Iterator(im)): for i, frame in enumerate(ImageSequence.Iterator(im)):
if i > 1: if i > 1:
self.fail("Non-stack DOS file test failed") 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): def makeSpiderHeader(im):
nsam, nrow = im.size nsam, nrow = im.size
lenbyt = nsam * 4 # There are labrec records in the header lenbyt = nsam * 4 # There are labrec records in the header
labrec = 1024 / lenbyt labrec = int(1024 / lenbyt)
if 1024 % lenbyt != 0: if 1024 % lenbyt != 0:
labrec += 1 labrec += 1
labbyt = labrec * lenbyt labbyt = labrec * lenbyt