[gimp] plug-ins: check for invalid resolution when loading TIFF image
- From: Jacob Boerema <jboerema src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] plug-ins: check for invalid resolution when loading TIFF image
- Date: Tue, 23 Aug 2022 21:27:50 +0000 (UTC)
commit ced071a8eeb584595de9d26d3a1d8dea87e99ba8
Author: Jacob Boerema <jgboerema gmail com>
Date: Mon Aug 22 22:21:33 2022 -0400
plug-ins: check for invalid resolution when loading TIFF image
This is essentially the same check as done in gimp_image_set_resolution,
but doing it here means we can load the image instead of throwing an
error.
We still need to get replacement xres and yres values, because these are
used to compute layer_offset_x_pixel and layer_offset_y_pixel.
plug-ins/file-tiff/file-tiff-load.c | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
---
diff --git a/plug-ins/file-tiff/file-tiff-load.c b/plug-ins/file-tiff/file-tiff-load.c
index 5a1caa7ef6..db9e2dac6b 100644
--- a/plug-ins/file-tiff/file-tiff-load.c
+++ b/plug-ins/file-tiff/file-tiff-load.c
@@ -1371,11 +1371,25 @@ load_image (GFile *file,
*/
if (read_unit != RESUNIT_NONE)
{
- gimp_image_set_resolution (*image, xres, yres);
- if (unit != GIMP_UNIT_PIXEL)
- gimp_image_set_unit (*image, unit);
+ if (! isfinite (xres) ||
+ xres < GIMP_MIN_RESOLUTION || xres > GIMP_MAX_RESOLUTION ||
+ ! isfinite (yres) ||
+ yres < GIMP_MIN_RESOLUTION || yres > GIMP_MAX_RESOLUTION)
+ {
+ g_message (_("Invalid image resolution info, using default"));
+ /* We need valid xres and yres for computing
+ * layer_offset_x_pixel and layer_offset_y_pixel.
+ */
+ gimp_image_get_resolution (*image, &xres, &yres);
+ }
+ else
+ {
+ gimp_image_set_resolution (*image, xres, yres);
+ if (unit != GIMP_UNIT_PIXEL)
+ gimp_image_set_unit (*image, unit);
- *resolution_loaded = TRUE;
+ *resolution_loaded = TRUE;
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]