feat(parser): add support for invokeai_metadata format

pull/930/head
zanllp 2026-03-05 23:26:59 +08:00
parent 117aa7fb27
commit 74382f25eb
2 changed files with 16 additions and 8 deletions

4
.gitignore vendored
View File

@ -27,3 +27,7 @@ iib.db-wal
CLAUDE.md CLAUDE.md
.claude/* .claude/*
videos/启动&添加文件夹构建索引.mp4
videos/图像搜索和链接跳转.mp4
videos/ai智能文件整理.mp4
videos/skills安装&启动.mp4

View File

@ -12,6 +12,10 @@ class InvokeAIParser:
def parse(clz, img: Image, file_path): def parse(clz, img: Image, file_path):
if not clz.test(img, file_path): if not clz.test(img, file_path):
raise Exception("The input image does not match the current parser.") raise Exception("The input image does not match the current parser.")
if 'invokeai_metadata' in img.info:
core_metadata = json.loads(img.info['invokeai_metadata'])
core_metadata.pop("canvas_v2_metadata", None)
elif 'invokeai_graph' in img.info:
raw_infos = json.loads(img.info["invokeai_graph"]) raw_infos = json.loads(img.info["invokeai_graph"])
core_metadata = {} core_metadata = {}
for key in raw_infos['nodes']: for key in raw_infos['nodes']:
@ -60,6 +64,6 @@ class InvokeAIParser:
@classmethod @classmethod
def test(clz, img: Image, file_path: str): def test(clz, img: Image, file_path: str):
try: try:
return 'invokeai_graph' in img.info return 'invokeai_graph' in img.info or 'invokeai_metadata' in img.info
except Exception as e: except Exception as e:
return False return False