Comfy-Org / Comfy-Org/ComfyUI

Allow ComfyUI to load a zipped workflow. That could save us up to 90% of storage on each image saved with workflow

Open
#6,808 0 comments 1 reaction 0 assignees View on GitHub
Feature
Dominant language
Python
Stars
133k
Forks
15.7k
Avg merge
1d 7h
Merged PRs (30d)
158

Description

### Feature Idea

Right now, I need to choose:
1- not to save an image with workflow, or
2- dumb down my workflows and save the image with embedded workflow

That is because the image, even when saving with a compressed WebP, would still be 1-2mb each, given that the big workflows me and a lot of people like to make can get gigantic.

I purpose to allow ComfyUI to be able to open a zipped or 7z file with a comfy json on it. With that, we could store the workflow on the image, zipped, saving up to 90% of storage.

For example, one of my workflow have 1.68MB. By zipping it with windows standard zip it becomes 180kb. By using 7zip with the "ultra" compression, it gets to 99 kbs only.

It makes totally sense to store a workflow so you can reproduce your image again. But that starts to make no sense when you are storing a 1.5MB of avoidable extra data multiplied by 1,000 images.

I'm not sure if this could open to some security issues, but I don't think so.

And according to ChatGPT it is possible (but it tends to lie):
```
Theoretical Answer: Yes, You Can Store a Zipped Workflow

You can store any binary data (including a compressed ZIP of the workflow JSON) inside PNG and WEBP metadata, just like you store the uncompressed JSON.
How Would It Work?

Compress the JSON Workflow
Convert the workflow JSON to a string.
Compress it using zlib or gzip.
Encode the compressed data in Base64 (since metadata fields expect text).

Embed the Compressed Workflow in the Image
Store the Base64-encoded compressed workflow in the EXIF metadata (WEBP) or PNG info (PNG).

Read and Decompress It Later
When loading the image, extract the Base64-encoded string from metadata.
Decode it from Base64.
Decompress it back into the original JSON.
```

### Existing Solutions

_No response_

### Other

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.