打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
python调整图片大小dpi不丢失,在Python中调整图像大小而不会丢失EXIF数据

宝源冷气工程

于 2020-12-11 03:31:04 发布
50
收藏

文章标签: python调整图片大小dpi不丢失

I need to resize jpg images with Python without losing the original image's EXIF data (metadata about date taken, camera model etc.). All google searches about python and images point to the PIL library which I'm currently using, but doesn't seem to be able to retain the metadata. The code I have so far (using PIL) is this:

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')

Any ideas? Or other libraries that I could be using?

解决方案import jpeg

jpeg.setExif(jpeg.getExif('foo.jpg'), 'foo-resized.jpg')

相关资源:python实现图片像素大小设置_python压缩图片像素,python图片大小...

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
10 分钟学会 pillow 图像处理 16 式
怎么把img格式图片转成JPG格式?这些转换方法要掌握
Python实例讲解
Python笔记——python强大的图像处理功能
Pillow入门教程
如何把img格式图片转换jpg?这几个方法很简单-今日头条
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服