Changed TIFF saving to use single frame save if given a single frame image and an empty generator

This commit is contained in:
Andrew Murray 2017-11-06 20:11:29 +11:00
parent bfaa0a1f07
commit 04d9ce29a9

View File

@ -1784,14 +1784,14 @@ class AppendingTiffWriter:
def _save_all(im, fp, filename): def _save_all(im, fp, filename):
encoderinfo = im.encoderinfo.copy() encoderinfo = im.encoderinfo.copy()
encoderconfig = im.encoderconfig 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: if not hasattr(im, "n_frames") and not append_images:
return _save(im, fp, filename) return _save(im, fp, filename)
cur_idx = im.tell() cur_idx = im.tell()
try: try:
with AppendingTiffWriter(fp) as tf: with AppendingTiffWriter(fp) as tf:
for ims in itertools.chain([im], append_images): for ims in [im]+append_images:
ims.encoderinfo = encoderinfo ims.encoderinfo = encoderinfo
ims.encoderconfig = encoderconfig ims.encoderconfig = encoderconfig
if not hasattr(ims, "n_frames"): if not hasattr(ims, "n_frames"):