added dimension setting for user to specify base

Modified aspect ratio resize to use user preferred dimension
Included setting next to aspect ratio inputs.
This commit is contained in:
Gerschel 2023-02-04 16:08:55 -08:00
parent e6f38a8c04
commit b68592dee9
2 changed files with 5 additions and 4 deletions

View File

@ -466,6 +466,7 @@ options_templates.update(options_section(('ui', "User interface"), {
"quicksettings": OptionInfo("sd_model_checkpoint", "Quicksettings list"),
"ui_reorder": OptionInfo(", ".join(ui_reorder_categories), "txt2img/img2img UI item order"),
"aspect_ratios": OptionInfo(", ".join(aspect_ratio_defaults), "txt2img/img2img aspect ratios"),
"aspect_ratio_base": OptionInfo("width", "aspect ratio base dimension (width or height)"),
"ui_extra_networks_tab_reorder": OptionInfo("", "Extra networks tab order"),
"localization": OptionInfo("None", "Localization (requires restart)", gr.Dropdown, lambda: {"choices": ["None"] + list(localization.localizations.keys())}, refresh=lambda: localization.list_localizations(cmd_opts.localizations_dir)),
}))

View File

@ -429,13 +429,13 @@ def aspect_ratio_list():
def aspect_ratio_resize(w, h, bttn_val):
dimension = shared.opts.aspect_ratio_base
width, height = map(int, bttn_val.split(":"))
ratio = width / height
if w / ratio > h:
return (round(h * ratio), h)
else:
if dimension == 'width':
return (w, round(w / ratio))
elif dimension == 'height':
return (round(h * ratio), h)
def get_value_for_setting(key):