From 9ccff1b69ce3f4d978d42e83488650604d252a31 Mon Sep 17 00:00:00 2001 From: Deer-Spangle Date: Sun, 1 Sep 2024 15:40:01 +0100 Subject: [PATCH] If attempting to reverse-search using a PSD, convert to PNG first --- server/szurubooru/func/posts.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/szurubooru/func/posts.py b/server/szurubooru/func/posts.py index be2259cf..8333eea2 100644 --- a/server/szurubooru/func/posts.py +++ b/server/szurubooru/func/posts.py @@ -928,6 +928,12 @@ def search_by_image_exact(image_content: bytes) -> Optional[model.Post]: def search_by_image(image_content: bytes) -> List[Tuple[float, model.Post]]: + # Convert PSD files to PNG so pillow can open them + if image_content[0:4] == b"\x38\x42\x50\x53": + image = images.Image(image_content) + image.resize_fill(image.width, image.height) + image_content = image.content + query_signature = image_hash.generate_signature(image_content) query_words = image_hash.generate_words(query_signature)