读取和写入Windows的“标签".使用Python 3 [英] Reading and writing Windows "tags" with Python 3

查看:68
本文介绍了读取和写入Windows的“标签".使用Python 3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows中,可以标记图像文件.可以通过右键单击文件,单击详细信息"选项卡,然后单击标签"属性值单元格来查看和编辑这些标签.

In Windows image files can be tagged. These tags can be viewed and edited by right clicking on a file, clicking over to the Details tab, then clicking on the Tags property value cell.

我希望能够使用Python 3读写这些标签.

I want to be able to read and write these tags using Python 3.

这不是EXIF数据,因此EXIF解决方案将不起作用.我相信它是Windows属性系统的一部分,但是在Dev Center中找不到参考.我看着win32com.propsys,那里也看不到任何东西.

This is not EXIF data so EXIF solutions won't work. I believe it's part of the Windows Property System, but I can't find a reference in Dev Center. I looked into win32com.propsys and couldn't see anything in there either.

我以前写过一个程序可以执行此操作,但是此后我丢失了它,所以我知道这是可能的.以前我是在没有pywin32的情况下做到的,但是任何解决方案都很棒.我想我用过windll,但我不记得了.

I wrote a program that does this once before, but I've since lost it, so I know it's possible. Previously I did it without pywin32, but any solution would be great. I think I used windll, but I can't remember.

推荐答案

以下是一些使用

此代码对于任何Windows属性都是非常通用的.

This code is pretty generic for any Windows property.

我正在使用 System.Keywords ,因为这就是您在属性表中看到的jpeg的"tags"属性所对应的内容.

I'm using System.Keywords because that's what corresponds to jpeg's "tags" property that you see in the property sheet.

并且该代码适用于jpeg和其他格式的 reading ( GetValue )属性,但并非所有Windows编解码器都支持 writing 属性( SetValue ),对于将扩展属性写回.png无效.

And the code works for jpeg and other formats for reading (GetValue) properties, but not all Windows codecs support property writing (SetValue), to it doesn't work for writing extended properties back to a .png for example.

这篇关于读取和写入Windows的“标签".使用Python 3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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