Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use gr.Dropdown for Image Formats #16687

Merged
merged 3 commits into from
Nov 28, 2024
Merged

Conversation

Haoming02
Copy link
Contributor

Description

  • Simple Description: Currently, the setting for the image formats is a Textbox, without any validation for it afaik during my brief tracing. So if the user made a typo or entered an unsupported format, it would simply raise errors when saving images.

    • (I just checked, apparently entering .png will still save without errors, with the filename simply being <filename>..png; But surely this would cause problems somewhere else?)
  • Summary of Changes: Added gr.Dropdown to the options, with a list of supported formats as the choices

Checklist

@Haoming02
Copy link
Contributor Author

Questions

  1. Should we use gr.Dropdown or gr.Radio component (live_previews_image_format is using Radio)?
  2. If using gr.Dropdown, should we also enable allow_custom_value?
  3. Should we have a central list of all supported formats in somewhere like images.py
    • And have I missed any formats?

use DropdownEditable so user can input other formats if they require it
make the default png the first on the list
@w-e-w
Copy link
Collaborator

w-e-w commented Nov 28, 2024

I change it to use DropdownEditable
even though it's not recommended it is technically possible someone may want to use other formats
for example gif bmp

if they require other formats I think it's better for them to convert the file to the format afterwards
but since it was possible for them to set it to format to any supported format, it should still be possible after this usability change


I'm not too happy with my wording about manual input of other formats
any suggestions?

@Haoming02
Copy link
Contributor Author

How about:

.link("PIL docs", "https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html")
.info("manual input of other formats is possible, but compatibility is not guaranteed")

@w-e-w
Copy link
Collaborator

w-e-w commented Nov 28, 2024

which do you think it's better
A
image
B
image

my opinion (read after you decide)

I think B is be better because unlike other things like Images filename pattern which links to a important Wiki
other file format this is a advance functionality that most people don't really need to know

@Haoming02
Copy link
Contributor Author

Oh right, I forgot custom .html() is a thing

Definitely B. imho

@w-e-w
Copy link
Collaborator

w-e-w commented Nov 28, 2024

LGTM
you any last minute changes?

@Haoming02
Copy link
Contributor Author

LGTM too 👍

@w-e-w w-e-w merged commit 0120768 into AUTOMATIC1111:dev Nov 28, 2024
3 checks passed
@Haoming02 Haoming02 deleted the dropdown4format branch November 28, 2024 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants