简体   繁体   English

python 图像拍摄日期和时间

[英]python image taken date and time

I'm trying to create an array that contains the filenames of all images in a folder in the first column and the "time taken" of the image in the second column.我正在尝试创建一个数组,其中包含第一列中文件夹中所有图像的文件名以及第二列中图像的“所用时间”。 This time should be in hh:mm:ss:msmsms (or hhmmssmsmsms), where "ms" is milliseconds.这个时间应该是 hh:mm:ss:msmsms(或 hhmmssmsmsms),其中“ms”是毫秒。

I found a piece of code that uses the Pillow library with the to pull the EXIFTAG data of the image.我找到了一段代码,它使用 Pillow 库来提取图像的 EXIFTAG 数据。 I realize that I would need the DateTimeOriginal and SubsecTimeOriginal tags to get the data I want.我意识到我需要 DateTimeOriginal 和 SubsecTimeOriginal 标签来获取我想要的数据。 Now the problem is that I just don't understand how the code bellow pulls the data from the image and how I would be able to create the desired array.现在的问题是我只是不明白下面的代码如何从图像中提取数据以及如何创建所需的数组。 If anyone knows how the.ExifTags and._getexif() modules work, some explanation would be appreciated.如果有人知道 .ExifTags 和 ._getexif() 模块如何工作,将不胜感激。

code:代码:

from PIL import Image
from PIL.ExifTags import TAGS

file_path = 'IMG_20200528_125319.jpg'

results = {}
i = Image.open(file_path)
info = i._getexif()
for tag, value in info.items():
    decoded = TAGS.get(tag, tag)
    results[decoded] = value

print results

Sadly the info I was looking for is not in the exif tags of the picture.可悲的是,我正在寻找的信息不在图片的 exif 标签中。 See Mark Setchell's comments.请参阅 Mark Setchell 的评论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM