invoke-ai / invoke-ai/InvokeAI

[enhancement]: add image format with better compression (webp, avif, jxl, etc)

Open
#2,704 10 comments 2 reactions 0 assignees View on GitHub
enhancement good first issue Inactive Issue
Dominant language
Python
Stars
28.2k
Forks
3k
Avg merge
6d 5h
Merged PRs (30d)
19

Description

We generate a lot of images. I would like them to be encoded more efficiently. I don't need the encoding to be lossless.

I often convert the images I've generated with InvokeAI to webp before sharing them, and it's common for them to come out at **10%** of the size of the PNG, or less. That's not 10% _smaller_, that's 10% _total,_ e.g. a 0.77 MB file to a 0.05 MB file.

Feature-wise, JPEG XL would be my first choice for an output format, as it has fewest constraints on size and plenty of options for bit depth and extra channels.

However, given that InvokeAI is a web-centric application, JPEG XL doesn't have the browser support to be viable anytime soon. [webp](https://caniuse.com/webp) or [avif](https://caniuse.com/avif) would be more practical in this regard.

## Additional Context

### Easy part: image data

Write [webp from PIL](https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html#webp) or [avif from pillow-avif-plugin](https://github.com/fdintino/pillow-avif-plugin).

### Messy part: metadata

InvokeAI currently stores image metadata inside a PNG tEXt chunk. It is not immediately obvious how to apply that to other file formats.

IMHO we should switch to using XMP instead, as XMP works more or less the same way regardless of image format.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.