mirror of
https://github.com/Wan-Video/Wan2.1.git
synced 2025-12-15 11:43:21 +00:00
save metadata to images
This commit is contained in:
parent
0be33acb57
commit
d174f71c59
16
wgp.py
16
wgp.py
@ -4738,11 +4738,15 @@ def generate_video(
|
||||
if metadata_choice == "json":
|
||||
with open(path.replace(f'.{extension}', '.json'), 'w') as f:
|
||||
json.dump(configs, f, indent=4)
|
||||
elif metadata_choice == "metadata" and not is_image:
|
||||
from mutagen.mp4 import MP4
|
||||
file = MP4(path)
|
||||
file.tags['©cmt'] = [json.dumps(configs)]
|
||||
file.save()
|
||||
elif metadata_choice == "metadata":
|
||||
if is_image:
|
||||
with Image.open(path) as img:
|
||||
img.save(path, comment=json.dumps(configs))
|
||||
else:
|
||||
from mutagen.mp4 import MP4
|
||||
file = MP4(path)
|
||||
file.tags['©cmt'] = [json.dumps(configs)]
|
||||
file.save()
|
||||
if is_image:
|
||||
print(f"New image saved to Path: "+ path)
|
||||
else:
|
||||
@ -7621,7 +7625,7 @@ def generate_configuration_tab(state, blocks, header, model_choice, prompt_enhan
|
||||
metadata_choice = gr.Dropdown(
|
||||
choices=[
|
||||
("Export JSON files", "json"),
|
||||
("Add metadata to video", "metadata"),
|
||||
("Embed metadata (Exif tag)", "metadata"),
|
||||
("Neither", "none")
|
||||
],
|
||||
value=server_config.get("metadata_type", "metadata"),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user