读取大疆照片中XMP元数据的RtkFlag信息


import os
from PIL import Image
from xml.dom.minidom import parseString

def readXMPRtkFlag(filename):
    with Image.open(filename) as im:
        for segment, content in im.applist:
            if segment != 'APP1':
                continue
            marker, body = content.rsplit(b'\x00', 1)
            if marker != b'http://ns.adobe.com/xap/1.0/':
                continue
            strBody = str(body, encoding='utf-8')
            doc = parseString(strBody)
            docRoot = doc.documentElement
            ele = docRoot.getElementsByTagName("rdf:Description")[0]
            return ele.getAttribute('drone-dji:RtkFlag')
    return ''

def main():
    root = './'
    subs = os.listdir(root)
    with open('result.txt', 'w') as f:
        for sub in subs:
            path = os.path.join(root, sub)
            if not os.path.isfile(path):
                continue
            if not path.upper().endswith('JPG'):
                continue
            flag = readXMPRtkFlag(path)
            f.write(path + '\t' + flag + '\n')

main()

版权声明:
除非注明,本博文章均为原创,转载请以链接形式标明本文地址。



   转载规则


《读取大疆照片中XMP元数据的RtkFlag信息》 Jackie Tang(唐浩桀) 采用 知识共享署名 4.0 国际许可协议 进行许可。
 上一篇
nginx反向代理nextcloud开启ssl nginx反向代理nextcloud开启ssl
docker nginx 安装 docker pull nginxdocker volume create nginx_configdocker run --name nginx-for-nextcloud --restart=always
2021-12-14 Jackie Tang(唐浩桀)
下一篇 
windows docker 安装部署 nextcloud windows docker 安装部署 nextcloud
拉取镜像 docker pull nextcloud 创建容器 docker run -d -p 9000:80 --restart always -v /mnt/d/docker/win-mount/nextcloud-data:/va
2021-10-15 Jackie Tang(唐浩桀)