Buffer the exif in a bytesio to save from fp being closed.
This commit is contained in:
parent
7f2360d1c0
commit
2c8081505a
1 changed files with 6 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
|||
import copy
|
||||
import io
|
||||
import PIL.ExifTags
|
||||
import PIL.Image
|
||||
|
||||
|
@ -111,6 +112,11 @@ def rotate_by_exif(image):
|
|||
except KeyError:
|
||||
return (image, exif)
|
||||
|
||||
fp = getattr(exif, 'fp', None)
|
||||
if isinstance(fp, io.BufferedReader):
|
||||
exif.fp = io.BytesIO()
|
||||
exif.fp.write(fp.read())
|
||||
exif.fp.seek(0)
|
||||
exif = copy.deepcopy(exif)
|
||||
|
||||
if rotation == 1:
|
||||
|
|
Loading…
Reference in a new issue