读取和修改数字图像的元数据,包括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使用ApachePOI将excel文件导入postgreSQL表   java多线程从iText pdf提取文本   winapi Java和SetWindowDisplayAffinity   eclipse juno的java Websphere 6.1插件   java MPAndroidChart:为Y轴提供一些偏移   java中作为参数传递枚举类型的继承   java Gui jframe的工作原理与netbeans不同   使用Bouncy Castle和PDFBox在Java中验证PDF签名   优化缩小Java代码   java无法在安卓中从Firebase取回子数据   返回的java方法?我应该什么时候用?   java错误处理已完成,退出代码为1。与穿过阵列的for循环有关   多线程Java volatile是否阻止缓存或强制执行写缓存?   java Multi-collectItems如何提前终止并返回已收集的项目   java为什么不在服务(请求,响应)中直接调用processRequest(请求,响应)?   java如何从字符串生成int数组?   打印获取用户输入的值并在其他预选文本中显示。JAVA   未显示java DynamicAsper UTF8字符   java Eclipse RCP:不启动应用程序的命令行参数