mirror of
https://github.com/vladmandic/automatic
synced 2026-09-20 01:31:13 +02:00
update
This commit is contained in:
+10
-7
@@ -607,13 +607,16 @@ def safe_decode_string(s: bytes):
|
||||
for encoding in ['utf-8', 'utf-16', 'ascii', 'latin_1', 'cp1252', 'cp437']: # try different encodings
|
||||
try:
|
||||
decoded = s.decode(encoding, errors="strict")
|
||||
if all(ord(c) < 128 for c in decoded): # only allow 7-bit ascii characters
|
||||
val = remove_prefix(decoded, 'UNICODE') # remove silly prefix added by old pnginfo/exif encoding
|
||||
val = remove_prefix(val, 'ASCII')
|
||||
val = re.sub(r'[\x00-\x09]', '', val) # remove remaining special characters
|
||||
if len(val) == 0: # remove empty strings
|
||||
val = None
|
||||
return val
|
||||
val = remove_prefix(decoded, 'UNICODE') # remove silly prefix added by old pnginfo/exif encoding
|
||||
val = remove_prefix(val, 'ASCII')
|
||||
val = re.sub(r'[\x00-\x09]', '', val).strip() # remove remaining special characters
|
||||
if len(val) > 1024: # limit string length
|
||||
val = val[:1024]
|
||||
if len(val) == 0: # remove empty strings
|
||||
val = None
|
||||
# if not all(ord(c) < 128 for c in decoded): # only allow 7-bit ascii characters
|
||||
# val = None
|
||||
return val
|
||||
except:
|
||||
pass
|
||||
return None
|
||||
|
||||
@@ -331,6 +331,7 @@ options_templates.update(options_section(('saving-images', "Saving images/grids"
|
||||
"export_for_4chan": OptionInfo(True, "If the saved image file size is above the limit, or its either width or height are above the limit, save a downscaled copy as JPG"),
|
||||
"img_downscale_threshold": OptionInfo(4.0, "File size limit for the above option, MB", gr.Number),
|
||||
"target_side_length": OptionInfo(4000, "Width/height limit for the above option, in pixels", gr.Number),
|
||||
"img_max_size_mp": OptionInfo(200, "Maximum image size, in megapixels", gr.Number),
|
||||
|
||||
"use_original_name_batch": OptionInfo(True, "Use original name for output filename during batch process in extras tab"),
|
||||
"use_upscaler_name_as_suffix": OptionInfo(False, "Use upscaler name as filename suffix in the extras tab"),
|
||||
|
||||
Reference in New Issue
Block a user