• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >python > Python读取图片EXIF信息类库介绍和使用实例

Python读取图片EXIF信息类库介绍和使用实例

作者:junjie 字体:[增加 减小] 来源:互联网

junjie 通过本文主要向大家介绍了python exif,exif,exif信息查看器,exif信息,exif是什么意思等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

首先要介绍的是 Python Imaging Library,使用方法如下:
from PIL import Image
from PIL.ExifTags import TAGS

def get_exif_data(fname):
    """Get embedded EXIF data from image file."""
    ret = {}
    try:
        img = Image.open(fname)
        if hasattr( img, '_getexif' ):
            exifinfo = img._getexif()
            if exifinfo != None:
                for tag, value in exifinfo.items():
                    decoded = TAGS.get(tag, tag)
                    ret[decoded] = value
    except IOError:
        print 'IOERROR ' + fname
    return ret

if __name__ == '__main__':
    fileName = 'C:/Users/Leyond/Desktop/IMG_20121122_153514.jpg'
    exif = get_exif_data(fileName)
    print exif
</div>


返回的清单如下:

ExifVersion
ComponentsConfiguration
ExifImageWidth
DateTimeOriginal
DateTimeDigitized
ExifInteroperabilityOffset
FlashPixVersion
MeteringMode
LightSource
Flash
FocalLength
41986
ImageDescription
Make
Model
Orientation
YCbCrPositioning
41988
XResolution
YResolution
59932
ExposureTime
ExposureProgram
ColorSpace
41990
ISOSpeedRatings
ResolutionUnit
41987
FNumber
Software
DateTime
ExifImageHeight
ExifOffset</div>

其中59932,是一大串十六进制的字符,不知为啥。除了PIL之外,还有许多类库可供使用:

Media Metadata for Python

EXIF.py

Python Exif Parser

A Blogger's Exif Parser

pyexiv2


接着看EXIF.PY,使用方法非常简单:exif.py IMG_20121122_153514.jpg
EXIF ColorSpace (Short): sRGB
EXIF ComponentsConfiguration (Undefined): YCbCr
EXIF DateTimeDigitized (ASCII): 2012:11:22 15:35:14
EXIF DateTimeOriginal (ASCII): 2012:11:22 15:35:14
EXIF DigitalZoomRatio (Ratio): 1
EXIF ExifImageLength (Long): 2560
EXIF ExifImageWidth (Long): 1920
EXIF ExifVersion (Undefined): 0220
EXIF ExposureBiasValue (Signed Ratio): 0
EXIF ExposureMode (Short): Auto Exposure
EXIF ExposureProgram (Short): Portrait Mode
EXIF ExposureTime (Ratio): 1/256
EXIF FNumber (Ratio): 14/5
EXIF Flash (Short): Flash did not fire
EXIF FlashPixVersion (Undefined): 0100
EXIF FocalLength (Ratio): 35
EXIF ISOSpeedRatings (Short): 56
EXIF InteroperabilityOffset (Long): 4810
EXIF LightSource (Short): other light source
EXIF MeteringMode (Short): CenterWeightedAverage
EXIF Padding (Undefined): []
EXIF SceneCaptureType (Short): Portrait
EXIF WhiteBalance (Short): Auto
Image DateTime (ASCII): 2012:11:24 09:44:50
Image ExifOffset (Long): 2396
Image ImageDescription (ASCII):
Image Make (ASCII):
Image Model (ASCII):
Image Orientation (Short): Horizontal (normal)
Image Padding (Undefined): []
Image ResolutionUnit (Short): Pixels/Inch
Image Software (ASCII): Microsoft Windows Photo Viewer 6.1.7600.16385
Image XResolution (Ratio): 72
Image YCbCrPositioning (Short): Co-sited
Image YResolution (Ratio): 72
Thumbnail Compression (Short): JPEG (old-style)
Thumbnail JPEGInterchangeFormat (Long): 4970
Thumbnail JPEGInterchangeFormatLength (Long): 3883
Thumbnail Orientation (Short): Horizontal (normal)
Thumbnail ResolutionUnit (Short): Pixels/Inch
Thumbnail XResolution (Ratio): 72
Thumbnail YCbCrPositioning (Short): Co-sited
Thumbnail YResolution (Ratio): 72
</div>

至于Python Exif Parser,好像没更新很久了,使用方法也很类似:

import exif
photo_path = "somePath\to\a\photo.jpg"
data = exif.parse(photo_path)
</div>

其他类库请自行研究。

</div>

您可能想查找下面的文章:

  • python用来获得图片exif信息的库实例分析
  • python通过exifread模块获得图片exif信息的方法
  • python让图片按照exif信息里的创建时间进行排序的方法
  • python用来获得图片exif信息的库实例分析
  • python通过exifread模块获得图片exif信息的方法
  • python让图片按照exif信息里的创建时间进行排序的方法
  • Python读取图片EXIF信息类库介绍和使用实例
  • Python读取图片EXIF信息类库介绍和使用实例

相关文章

  • linux 下实现python多版本安装实践
  • python测试驱动开发实例
  • 简介Django框架中可使用的各类缓存
  • python基于itchat实现微信群消息同步机器人
  • python使用mailbox打印电子邮件的方法
  • netbeans7安装python插件的方法图解
  • Python编程生成随机用户名及密码的方法示例
  • python中字典(Dictionary)用法实例详解
  • python3中int(整型)的使用教程
  • python随机生成指定长度密码的方法

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • Python实现合并字典的方法
    • python脚本爬取字体文件的实现方法
    • python递归查询菜单并转换成json实例
    • 利用python实现数据分析
    • Python程序中使用SQLAlchemy时出现乱码的解决方案
    • Python变量和数据类型详解
    • 结合Python的SimpleHTTPServer源码来解析socket通信
    • Python3实现Web网页图片下载
    • Python cx_freeze打包工具处理问题思路及解决办法
    • Python实现基本线性数据结构

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有