Python:从图像中删除Exif信息 [英] Python: Remove Exif info from images

查看:774
本文介绍了Python:从图像中删除Exif信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了减少网站中使用的图像尺寸,我将质量降低到80-85%。这样可以在很大程度上减小图像尺寸。

In order to reduce the size of images to be used in a website, I reduced the quality to 80-85%. This decreases the image size quite a bit, up to an extent.

为了在不影响质量的情况下进一步缩小尺寸,我的朋友指出相机的原始图像有一个很多元数据称为Exif信息。由于无需为网站中的图像保留此Exif信息,我们可以将其删除。这将进一步减小3-10 kB。

To reduce the size further without compromising the quality, my friend pointed out that raw images from cameras have a lot of metadata called Exif info. Since there is no need to retain this Exif info for images in a website, we can remove it. This will further reduce the size by 3-10 kB.

但是我无法在我的Python代码中找到合适的库。我已经通过相关的问题和浏览尝试了一些方法:

But I'm not able to find an appropriate library to do this in my Python code. I have browsed through related questions and tried out some of the methods:

原始图像: http://mdb.ibcdn.com/8snmhp4sjd75vdr27gbadolc003i.jpg


  1. Mogrify

/usr/local/bin/mogrify -strip filename

结果:< A HREF = http://s23.postimg.org/aeaw5x7ez/8snmhp4sjd75vdr27gbadolc003i_mogrify.jpg 相对= nofollow noreferrer> http://s23.postimg.org/aeaw5x7ez/8snmhp4sjd75vdr27gbadolc003i_mogrify.jpg
此方法将大小从105 kB减小到99.6 kB,但也改变了颜色质量。

Result: http://s23.postimg.org/aeaw5x7ez/8snmhp4sjd75vdr27gbadolc003i_mogrify.jpg This method reduces the size from 105 kB to 99.6 kB, but also changed the color quality.

Exif-tool

exiftool -all= filename

结果: http://s22.postimg.org/aiq99o775/8snmhp4sjd75vdr27gbadolc003i_exiftool.jpg
此方法将大小从105 kB减小到72.7 KB,但也改变了颜色质量。

Result: http://s22.postimg.org/aiq99o775/8snmhp4sjd75vdr27gbadolc003i_exiftool.jpg This method reduces the size from 105 kB to 72.7 kB, but also changed the color quality.

任何人都可以帮我删除所有额外的元数据而不改变图像的颜色,尺寸和其他属性吗?

Can anyone please help me remove all the extra metadata without changing the colours, dimensions, and other properties of an image?

推荐答案

您可以尝试使用 Python Image Lirbary(PIL)加载图像,然后将其再次保存到其他文件。这应该删除元数据。

You can try loading the image with the Python Image Lirbary (PIL) and then save it again to a different file. That should remove the meta data.

这篇关于Python:从图像中删除Exif信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆