Skip to content

Commit

Permalink
fixed usage of piexif with BytesIO buffers
Browse files Browse the repository at this point in the history
  • Loading branch information
YellowTech committed Apr 3, 2023
1 parent 266486f commit f2df118
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion optimize_images/img_optimize_jpg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f2df118

Please sign in to comment.