【发布时间】:2010-09-28 21:13:47
【问题描述】:
我需要使用 Python 调整 jpg 图像的大小,而不会丢失原始图像的 EXIF 数据(有关拍摄日期、相机型号等的元数据)。所有关于 python 和图像的谷歌搜索都指向我目前正在使用的 PIL 库,但似乎无法保留元数据。我到目前为止的代码(使用 PIL)是这样的:
img = Image.open('foo.jpg')
width,height = 800,600
if img.size[0] < img.size[1]:
width,height = height,width
resized_img = img.resize((width, height), Image.ANTIALIAS) # best down-sizing filter
resized_img.save('foo-resized.jpg')
有什么想法吗?或者我可以使用的其他库?
【问题讨论】:
-
我对以下问题的回答显示了如何仅使用 PIL 保留 exif 数据:stackoverflow.com/questions/17042602/…
标签: python image-processing python-imaging-library exif