在不下载整个图像的情况下获取EXIF数据-Python [英] Get EXIF data without downloading whole image - Python

查看:68
本文介绍了在不下载整个图像的情况下获取EXIF数据-Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过仅下载EXIF数据来远程获取图像的EXIF信息?

Is is possible to get the EXIF information of an image remotely and with only downloading the EXIF data?

据我了解的有关图像文件中的EXIF字节,则EXIF数据位于图像的前几个字节中。

From what I can understand about EXIF bytes in image files, the EXIF data is in the first few bytes of an image.

所以问题是如何使用Python仅下载远程文件的前几个字节? (编辑:仅依靠HTTP Range Header不够好,因为并非所有远程主机都支持它,在这种情况下将进行完全下载。)

So the question is how to download only the first few bytes of a remote file, with Python? ( Relying on HTTP Range Header is not good enough, as not all remote hosts support it, in which case full download will occur.)

我可以取消下载吗?例如,在x字节的进度之后?

Can I cancel the download after x bytes of progress, for example?

推荐答案

这在很大程度上取决于图像格式。例如,如果您有TIFF文件,则不会知道EXIF数据(如果有)在文件中的先验位置。可能恰好在标头之后,第一个IFD之前,但这不太可能。可能是在图像数据之后。

This depends on the image format heavily. For example, if you have a TIFF file, there is no knowing a priori where the EXIF data, if any, is within the file. It could be right after the header and before the first IFD, but this is unlikely. It could be way after the image data. Chances are it's somewhere in the middle.

如果您需要EXIF信息,则将其提取到服务器(可能是缓存)中,然后很好地打包下来,而不是要求客户代码可以做到这一点。

If you want the EXIF information, extract that on the server (cache, maybe) and ship that down packaged up nicely instead of demanding client code do that.

这篇关于在不下载整个图像的情况下获取EXIF数据-Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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