cocktailpeanut / breadboard

Stable Diffusion Browser for Windows, Mac, and Linux
https://breadboard.me
376 stars 37 forks source link

Feature request: support JPG and WEBP files. (Related code provided.) #11

Open r7vz9h3 opened 1 year ago

r7vz9h3 commented 1 year ago

Automatic1111's WebUI natively supports saving images with prompts in metadata as JPG and WEBP. Especially the WEBP format is great for saving a lot of space compared to PNG, with minimal quality loss. WEBP files are also much faster to read and write than PNG.

I wrote a short script for indexing and searching prompts, where I used a function copied from Auto's code (run_pnginfo) to extract prompts from PNG and JPG, but it didn't work for WEBP for me, so I wrote my own line of code to extract prompts from these. I linked to the relevant part of code:

https://gist.github.com/r7vz9h3/008e86bed8a4cbe4079e644ac71ccfc3#file-findgens-py-L72

All I needed was:

with open(webp_image_path, 'rb') as imfile:
    info = imfile.read().decode('utf-8', 'ignore').rpartition('UNICODE')[2].replace('\x00', '')

I'm sure this can be improved a lot, but it seems to work.

MrKuenning commented 1 year ago

This, please!

I couldn't figure out why only a few thousand of my tens of thousands of images showed up until I realized it was only showing me the PNG files. Please support Automatic1111 JPG files.