aboutsummaryrefslogtreecommitdiff
path: root/modules/images.py
diff options
context:
space:
mode:
authorAUTOMATIC <16777216c@gmail.com>2022-09-10 08:45:16 +0300
committerAUTOMATIC <16777216c@gmail.com>2022-09-10 08:45:16 +0300
commit6f678ec79ce6319607a79ac2b75bbe987611603e (patch)
treec7176165434159e554b41f526e13b996eeb43f71 /modules/images.py
parentee8a6fa89fed10dc672678fe84430309480f1f89 (diff)
Emoji are not being sorted correctly #192
Diffstat (limited to 'modules/images.py')
-rw-r--r--modules/images.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/modules/images.py b/modules/images.py
index 932fd216..f2de9d86 100644
--- a/modules/images.py
+++ b/modules/images.py
@@ -6,6 +6,7 @@ import re
import numpy as np
from PIL import Image, ImageFont, ImageDraw, PngImagePlugin
from fonts.ttf import Roboto
+import string
import modules.shared
from modules.shared import opts
@@ -235,6 +236,7 @@ def resize_image(resize_mode, im, width, height):
invalid_filename_chars = '<>:"/\\|?*\n'
+re_nonletters = re.compile(r'[\s'+string.punctuation+']+')
def sanitize_filename_part(text):
@@ -256,11 +258,11 @@ def save_image(image, path, basename, seed=None, prompt=None, extension='png', i
pnginfo = None
if opts.save_to_dirs and not no_prompt:
- words = re.findall(r'\w+', prompt or "")
+ words = re_nonletters.split(prompt or "")
if len(words) == 0:
words = ["empty"]
- dirname = " ".join(words[0:opts.save_to_dirs_prompt_len])
+ dirname = " ".join(words[0:opts.save_to_dirs_prompt_len]).strip()
path = os.path.join(path, dirname)
os.makedirs(path, exist_ok=True)