读取和修改数字图像的元数据,包括exif、iptc、xmp。

pyexiv2的Python项目详细描述


< H1> PyxIV2

读取和修改数字图像的元数据,包括exif、iptc、xmp。

功能

用法

  • 读取元数据:

    >>>frompyexiv2importImage>>>i=Image("tests/1.jpg")>>>i.read_exif(){'Exif.Image.DateTime':'2019:06:23 19:45:17','Exif.Image.Artist':'TEST','Exif.Image.Rating':'4',...}>>>i.read_iptc(){'Iptc.Envelope.CharacterSet':'\x1b%G','Iptc.Application2.ObjectName':'TEST','Iptc.Application2.Keywords':'TEST',...}>>>i.read_xmp(){'Xmp.dc.format':'image/jpeg','Xmp.dc.rights':'lang="x-default" TEST','Xmp.dc.subject':'TEST',...}
  • 修改元数据:

    >>># prepare the XMP data you want to modify>>>_dict={"Xmp.xmp.CreateDate":"2019-06-23T19:45:17.834",# this will overwrite its original value, or add it if it doesn't exist..."Xmp.xmp.Rating":""}# set an empty str explicitly to delete the datum}>>>i.modify_xmp(_dict)>>>xmp_dict=i.read_xmp()# read it again>>>xmp_dict["Xmp.xmp.CreateDate"]'2019-06-23T19:45:17.834'# it has been set>>>xmp_dict["Xmp.xmp.Rating"]KeyError:'Xmp.xmp.Rating'# it has been deleted# use i.modify_exif() and i.modify_iptc() in the same way
  • 简而言之,请调用类pyexiv2.Image

    的公共方法
    i=Image("tests/1.jpg")i.read_exif()i.read_iptc()i.read_xmp()i.read_all()i.modify_exif({"Exif.Image.ImageDescription":"test",...})i.modify_iptc({"Iptc.Application2.ObjectName":"test",...})i.modify_xmp({"Xmp.xmp.CreateDate":"2019-06-23T19:45:17.834",...})i.modify_all({"EXIF":{...},"IPTC":{...},"XMP":{...}})i.clear_exif()i.clear_iptc()i.clear_xmp()i.clear_all()

测试

文件夹中有一些测试用例“PyExvI2/测试”。通过pytest运行它们:

pip install pytest psutil
pytest -v

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
内存Java正在运行。jar heapdump错误   java如何在安卓画布中弯曲文本区域?   java如何在Gdx 安卓游戏编程中获得矩形的真实触碰位置?   找不到java Spring MVC控制器   在Java中使用双重检查锁定单例扩展类   java在高效的时间和内存中动态执行insert(索引、数据)、delete(索引)、getAt(索引)操作。   java 安卓 Toast和视图帮助   java协议缓冲区:从文件中读取所有序列化消息   java如何在Jackson中为参数化接口类型执行通用自定义反序列化程序   与简单的空检查相比,使用(平面)映射的java优势是什么?   异步方法seam中的java Get contextparam   jar使用相同的java运行时运行另一个java程序   java访问Spring批处理中的作业参数   java给定字符串为空或null   在h2数据库1.4中找不到java类“org.h2.fulltext.FullTextLucene”。*不适用于Lucene Core 4*   java Spring Boot在使用@enableSync时不响应任何请求   java错误:在bash上找不到或加载主类pj2   “返回对象”和“返回(对象)”之间的Java差异   java Android开发:如何使用onKeyUp?