When I try to resize (thumbnail) an image using PIL, the exif data is lost.
What do I have to do preserve exif data in the thumbnail image? When I searched for the same, got some links but none seem to be working.
from PIL import Image
import StringIO
file_path = '/home/me/img/a.JPG'
im = Image.open( file_path)
THUMB_SIZES = [(512, 512)]
for thumbnail_size in THUMB_SIZES:
im.thumbnail( thumbnail_size, Image.ANTIALIAS)
thumbnail_buf_string = StringIO.StringIO()
im.save('512_' + "a", "JPEG")
The orginal image has exif data, but image im(512_a.JPEG) doesn't.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…