diff --git a/optimize_images/img_optimize_jpg.py b/optimize_images/img_optimize_jpg.py index 81114b8..a3a139f 100644 --- a/optimize_images/img_optimize_jpg.py +++ b/optimize_images/img_optimize_jpg.py @@ -77,7 +77,11 @@ def optimize_jpg(task: Task) -> TaskResult: if task.keep_exif and had_exif: try: - piexif.transplant(os.path.expanduser(task.src_path), tmp_buffer) + tmp_buffer_exif = BytesIO() + piexif.transplant(os.path.expanduser(task.src_path), + tmp_buffer.getbuffer(), new_file=tmp_buffer_exif) + tmp_buffer.close() + tmp_buffer = tmp_buffer_exif has_exif = True except ValueError: has_exif = False