aboutsummaryrefslogtreecommitdiff
path: root/modules/images.py
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-08-21 07:50:50 +0300
committerGitHub <noreply@github.com>2023-08-21 07:50:50 +0300
commitd722d6de36fe9802360232283d14a4c62e08d4af (patch)
tree513a96d2bd0a47448c0cb54336fbe1a7eb622181 /modules/images.py
parent76ae1019b96c4673231a116f0b20bb85ebec5666 (diff)
parent8ce613bb3af2dcdbabe460a0665f80757ffd9796 (diff)
Merge pull request #12667 from AUTOMATIC1111/switch-to-PNG-when-images-too-large
switch to PNG when images too large
Diffstat (limited to 'modules/images.py')
-rw-r--r--modules/images.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/modules/images.py b/modules/images.py
index a6b4fb1e..eb644733 100644
--- a/modules/images.py
+++ b/modules/images.py
@@ -600,6 +600,11 @@ def save_image(image, path, basename, seed=None, prompt=None, extension='png', i
"""
namegen = FilenameGenerator(p, seed, prompt, image)
+ # WebP and JPG formats have maximum dimension limits of 16383 and 65535 respectively. switch to PNG which has a much higher limit
+ if (image.height > 65535 or image.width > 65535) and extension.lower() in ("jpg", "jpeg") or (image.height > 16383 or image.width > 16383) and extension.lower() == "webp":
+ print('Image dimensions too large; saving as PNG')
+ extension = ".png"
+
if save_to_dirs is None:
save_to_dirs = (grid and opts.grid_save_to_dirs) or (not grid and opts.save_to_dirs and not no_prompt)