zixaphir / Stable-Diffusion-Webui-Civitai-Helper

Stable Diffusion Webui Extension for Civitai, to manage your model much more easily.
175 stars 24 forks source link

Save previews as jpeg instead of as png? #97

Open minogora opened 2 months ago

minogora commented 2 months ago

I feel it would make more sense for the helper to store downloaded preview images with a jpeg extension instead of with a png extension. As the README states, automatic1111 will select to display a "model.preview.png" before a "model.jpeg" if both exist.

I have set automatic1111 to always save generated images as jpeg in order to keep file sizes down. This means when I generate my own preview for a model, it becomes "model.jpeg" and is never shown. It would make more sense for user generated preview images to be preferred over default downloaded ones and storing downloaded previews with a jpeg extension would solve that.

zixaphir commented 1 month ago

model.png should also display before model.preview.png. The file extension honestly doesn't matter, and I believe that Civitai serves jpeg files automatically now. It's just a filename and honestly the only reason they're named png instead of jpeg is because it's how the extension has always named them. Most software, including webui, don't care about the file extension and instead process the image based on the file header.

I might change this behavior because it's honestly very silly to intentionally use the wrong extension, but it should have no effect on what preview loads first.

minogora commented 1 month ago

It does affect the display priority though. When automatic1111 is set to save generated images as jpeg, and I update the preview for a lora, if there is already a png preview downloaded from civitai, then the png preview will be shown.

Here is an example; I have these files for a model:

image

Porcelain_v1_R128.preview.png was downloaded by this extension, and is still displayed as the preview for the lora even after I generated an image and selected to replace the preview. This is because I have automatic1111 set to save images in jpeg format and then my replacement preview becomes Porcelain_v1_R128.jpeg. Automatic1111 does not prioritize model.jpeg over model.preview.png; it seems to pick the first match out of model.png, model.preview.png, model.jpeg, model.preview.jpeg.

This is not desired behaviour; if I select to replace the preview I obviously want to see my own generated image as the preview for the lora.

zixaphir commented 1 month ago

I double checked and you are correct. I'll see about changing the behavior on this side to deprioritize our previews, but I also consider this a bug in webui so I might try to fix it there.