mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Merge pull request #3137 from radarhere/pdf
Fixed saving a multiframe image as a single frame PDF
This commit is contained in:
commit
c222df2b56
|
@ -104,6 +104,16 @@ class TestFilePdf(PillowTestCase):
|
|||
self.assertTrue(os.path.isfile(outfile))
|
||||
self.assertGreater(os.path.getsize(outfile), 0)
|
||||
|
||||
def test_multiframe_normal_save(self):
|
||||
# Test saving a multiframe image without save_all
|
||||
im = Image.open("Tests/images/dispose_bgnd.gif")
|
||||
|
||||
outfile = self.tempfile('temp.pdf')
|
||||
im.save(outfile)
|
||||
|
||||
self.assertTrue(os.path.isfile(outfile))
|
||||
self.assertGreater(os.path.getsize(outfile), 0)
|
||||
|
||||
def test_pdf_open(self):
|
||||
# fail on a buffer full of null bytes
|
||||
self.assertRaises(PdfParser.PdfFormatError, PdfParser.PdfParser, buf=bytearray(65536))
|
||||
|
|
|
@ -113,7 +113,8 @@ def _save(im, fp, filename, save_all=False):
|
|||
|
||||
pageNumber = 0
|
||||
for imSequence in ims:
|
||||
for im in ImageSequence.Iterator(imSequence):
|
||||
im_pages = ImageSequence.Iterator(imSequence) if save_all else [imSequence]
|
||||
for im in im_pages:
|
||||
# FIXME: Should replace ASCIIHexDecode with RunLengthDecode (packbits)
|
||||
# or LZWDecode (tiff/lzw compression). Note that PDF 1.2 also supports
|
||||
# Flatedecode (zip compression).
|
||||
|
|
Loading…
Reference in New Issue
Block a user