from PIL import ImageTk, Image import os import sys def resource_path(relative_path): base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__))) return os.path.join(base_path, relative_path) def get_image_and_resize(path_to_image, width, height): image = Image.open(resource_path(path_to_image)).resize((width, height)) return ImageTk.PhotoImage(image)