Decoding XMP data read using python from .lrcat

huangapple go评论60阅读模式
英文:

Decoding XMP data read using python from .lrcat

问题

我正在使用Python脚本和sqlite3读取.lrcat数据。在Adobe_AdditionalMetadata表中,我有一个名为xmp的列,其编码方式似乎很奇怪,可能是Adobe Lightroom的编码方式。以下是我的代码片段:

from libxmp import XMPFiles

cursor = conn.execute('SELECT xmp FROM Adobe_AdditionalMetadata')
row = cursor.fetchone()
xmp_data = row[0]

xmp_data.decode('utf-8')

我尝试过一些.decode('utf-8')或尝试将字节转换为字符串,但都没有成功。我知道有exiftool,但我没有看到任何解码xmp_data的方法。显然,它有助于读取xmp文件,但不适用于目录中的数据...有什么建议吗?也许可以尝试使用LR API吗?

英文:

I'm reading .lrcat data using a python script and sqlite3.
I have a column in the Adobe_AdditionalMetadata table called xmp with an odd encoding, probably an Adobe Lightroom encoding.
Here's my chunk of code:

from libxmp import XMPFiles

cursor = conn.execute('SELECT xmp FROM Adobe_AdditionalMetadata')
row = cursor.fetchone()
xmp_data = row[0]

xmp_data.decode('utf-8')

I tried some .decode('utf-8') or trying to convert the byte to string but didn't work.
I know there's the exiftool but I dont see any ways to decode the xmp_data. Apparently, it helps reading xmp files but not the data in the catalog...
Any ideas of what i could try? Something with LR API's maybe?

答案1

得分: 0

这个xmp字段以压缩形式存储,并以32位数字为前缀,指示未压缩数据的长度。

您可以使用以下方式解码它:

zlib.decompress(xmp_data[4:])

在目录数据库的一些其他地方也使用了相同的压缩技巧。

英文:

This xmp field is stored as deflated, and stored prefixed by 32-bit number indicating the length of uncompressed data.

You can decode it with:

zlib.decompress(xmp_data[4:]))

Same deflate trick is used in some other places in the catalog database.

答案2

得分: 0

I found a workaround for this actually without python code.
My initial goal here was to be able to make the bridge between the name of my DNG file and its file metadata such as the tint, exposure, etc.
I finally found I could do this using a SQL query on the .lrcat that looks like this:

SELECT AgLibraryFile.id_global as dngID, Adobe_imageDevelopSettings.text as metadata
FROM AgLibraryFile
JOIN Adobe_images ON AgLibraryFile.id_local = Adobe_images.rootFile
JOIN Adobe_imageDevelopSettings ON Adobe_images.developSettingsIDCache = Adobe_imageDevelopSettings.id_local;

英文:

I found a workaround for this actually without python code.
My initial goal here was to be able to make the bridge between the name of my DNG file and its file metadata such as the tint, exposure, etc.
I finally found I could do this using a SQL query on the .lrcat that looks like this :

SELECT AgLibraryFile.id_global as dngID, Adobe_imageDevelopSettings.text as metadata
FROM AgLibraryFile
JOIN Adobe_images ON AgLibraryFile.id_local = Adobe_images.rootFile
JOIN Adobe_imageDevelopSettings ON Adobe_images.developSettingsIDCache = Adobe_imageDevelopSettings.id_local;

huangapple
  • 本文由 发表于 2023年3月4日 04:15:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/75631514.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定