mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-25 15:15:44 -03:00
Limit Lora hash display to first 10 characters and improve WebP metadata handling
This commit is contained in:
@@ -224,7 +224,7 @@ class SaveImage:
|
|||||||
if lora_hashes:
|
if lora_hashes:
|
||||||
lora_hash_parts = []
|
lora_hash_parts = []
|
||||||
for lora_name, hash_value in lora_hashes.items():
|
for lora_name, hash_value in lora_hashes.items():
|
||||||
lora_hash_parts.append(f"{lora_name}: {hash_value}")
|
lora_hash_parts.append(f"{lora_name}: {hash_value[:10]}")
|
||||||
|
|
||||||
if lora_hash_parts:
|
if lora_hash_parts:
|
||||||
params.append(f"Lora hashes: \"{', '.join(lora_hash_parts)}\"")
|
params.append(f"Lora hashes: \"{', '.join(lora_hash_parts)}\"")
|
||||||
@@ -379,27 +379,22 @@ class SaveImage:
|
|||||||
print(f"Error adding EXIF data: {e}")
|
print(f"Error adding EXIF data: {e}")
|
||||||
img.save(file_path, format="JPEG", **save_kwargs)
|
img.save(file_path, format="JPEG", **save_kwargs)
|
||||||
elif file_format == "webp":
|
elif file_format == "webp":
|
||||||
# For WebP, use exif data in a ComfyUI-compatible format
|
|
||||||
try:
|
try:
|
||||||
# Get exif from image
|
# For WebP, use piexif for metadata
|
||||||
exif = img.getexif()
|
exif_dict = {}
|
||||||
|
|
||||||
# Add metadata if available
|
|
||||||
if metadata:
|
if metadata:
|
||||||
exif[piexif.ExifIFD.UserComment] = b'UNICODE\0' + metadata.encode('utf-16be')
|
exif_dict['Exif'] = {piexif.ExifIFD.UserComment: b'UNICODE\0' + metadata.encode('utf-16be')}
|
||||||
|
|
||||||
# Add workflow if embed_workflow is enabled
|
# Add workflow if needed
|
||||||
if embed_workflow and extra_pnginfo is not None:
|
if embed_workflow and extra_pnginfo is not None:
|
||||||
# Format the workflow with "Workflow:" prefix for ComfyUI compatibility
|
workflow_json = json.dumps(extra_pnginfo["workflow"])
|
||||||
workflow_json = json.dumps(extra_pnginfo["workflow"])
|
exif_dict['0th'] = {piexif.ImageIFD.ImageDescription: "Workflow:" + workflow_json}
|
||||||
# Store workflow in ImageDescription tag (0x010e)
|
|
||||||
exif[piexif.ImageIFD.ImageDescription] = "Workflow:" + workflow_json
|
exif_bytes = piexif.dump(exif_dict)
|
||||||
|
save_kwargs["exif"] = exif_bytes
|
||||||
# Update save_kwargs with exif data
|
|
||||||
save_kwargs["exif"] = exif.tobytes()
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error adding EXIF/workflow data to WebP: {e}")
|
print(f"Error adding EXIF data: {e}")
|
||||||
|
|
||||||
img.save(file_path, format="WEBP", **save_kwargs)
|
img.save(file_path, format="WEBP", **save_kwargs)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user