From 04d9ce29a9ff978892bce3ec99bc76c9ee64d1fb Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Mon, 6 Nov 2017 20:11:29 +1100 Subject: [PATCH] Changed TIFF saving to use single frame save if given a single frame image and an empty generator --- PIL/TiffImagePlugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PIL/TiffImagePlugin.py b/PIL/TiffImagePlugin.py index 1b60e8016..b9dd19a61 100644 --- a/PIL/TiffImagePlugin.py +++ b/PIL/TiffImagePlugin.py @@ -1784,14 +1784,14 @@ class AppendingTiffWriter: def _save_all(im, fp, filename): encoderinfo = im.encoderinfo.copy() encoderconfig = im.encoderconfig - append_images = encoderinfo.get("append_images", []) + append_images = list(encoderinfo.get("append_images", [])) if not hasattr(im, "n_frames") and not append_images: return _save(im, fp, filename) cur_idx = im.tell() try: with AppendingTiffWriter(fp) as tf: - for ims in itertools.chain([im], append_images): + for ims in [im]+append_images: ims.encoderinfo = encoderinfo ims.encoderconfig = encoderconfig if not hasattr(ims, "n_frames"):