[Bf-blender-cvs] [87582d95dfd] blender-v3.4-release: Fix T101245: Allow Thumbnails of > 256:1 Images

Harley Acheson noreply at git.blender.org
Tue Dec 6 17:15:21 CET 2022


Commit: 87582d95dfdbc6df4baff881e0bbe62a1fb45c37
Author: Harley Acheson
Date:   Tue Dec 6 08:14:02 2022 -0800
Branches: blender-v3.4-release
https://developer.blender.org/rB87582d95dfdbc6df4baff881e0bbe62a1fb45c37

Fix T101245: Allow Thumbnails of > 256:1 Images

Ensure that thumbnails of images with aspect greater than 256:1 have
dimensions of at least one pixel.

See D16707 for more details

Differential Revision: https://developer.blender.org/D16707

Reviewed by Brecht Van Lommel

===================================================================

M	source/blender/imbuf/intern/openexr/openexr_api.cpp
M	source/blender/imbuf/intern/webp.c

===================================================================

diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp
index d2bdb5041c5..c17931827f7 100644
--- a/source/blender/imbuf/intern/openexr/openexr_api.cpp
+++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp
@@ -2215,8 +2215,8 @@ struct ImBuf *imb_load_filepath_thumbnail_openexr(const char *filepath,
 
     float scale_factor = MIN2(float(max_thumb_size) / float(source_w),
                               float(max_thumb_size) / float(source_h));
-    int dest_w = int(source_w * scale_factor);
-    int dest_h = int(source_h * scale_factor);
+    int dest_w = MAX2(int(source_w * scale_factor), 1);
+    int dest_h = MAX2(int(source_h * scale_factor), 1);
 
     struct ImBuf *ibuf = IMB_allocImBuf(dest_w, dest_h, 32, IB_rectfloat);
 
diff --git a/source/blender/imbuf/intern/webp.c b/source/blender/imbuf/intern/webp.c
index 3031b8c3e33..abf915b1b8e 100644
--- a/source/blender/imbuf/intern/webp.c
+++ b/source/blender/imbuf/intern/webp.c
@@ -112,8 +112,8 @@ struct ImBuf *imb_load_filepath_thumbnail_webp(const char *filepath,
   *r_height = (size_t)config.input.height;
 
   const float scale = (float)max_thumb_size / MAX2(config.input.width, config.input.height);
-  const int dest_w = (int)(config.input.width * scale);
-  const int dest_h = (int)(config.input.height * scale);
+  const int dest_w = MAX2((int)(config.input.width * scale), 1);
+  const int dest_h = MAX2((int)(config.input.height * scale), 1);
 
   colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE);
   struct ImBuf *ibuf = IMB_allocImBuf(dest_w, dest_h, 32, IB_rect);



More information about the Bf-blender-cvs mailing list