From f18d63f09f4784e1402b6f8af842e6568b71f896 Mon Sep 17 00:00:00 2001 From: = <=> Date: Sun, 18 Dec 2022 07:00:52 +0700 Subject: [PATCH] add support for jpeg, less ambigious extension list --- scripts/image_caption_gui.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/image_caption_gui.py b/scripts/image_caption_gui.py index f416610..dca965b 100644 --- a/scripts/image_caption_gui.py +++ b/scripts/image_caption_gui.py @@ -13,6 +13,8 @@ from tkinter import filedialog from PIL import Image, ImageTk from pathlib import Path +IMG_EXT = ["jpg", "jpeg", "png"] + class CaptionedImage(): def __init__(self, image_path): self.base_path = image_path.parent @@ -67,8 +69,9 @@ class ImageView(tk.Frame): if self.base_path is None: return self.images.clear() - for file in self.base_path.glob('*.[jp][pn][gg]'): # jpg or png - self.images.append(CaptionedImage(file)) + for ext in IMG_EXT: + for file in self.base_path.glob(f'*.{ext}'): + self.images.append(CaptionedImage(file)) self.images.sort() self.update_ui()