[gs-commits] mupdf 1.16.1.epub-prerelease-23 Improve clamping of impro

[email protected] (Sebastian Rasmussen) Mon, 4 Nov 2019 12:01:40 +0000 (UTC)
Newsgroups gmane.comp.printing.ghostscript.cvs
Message-ID <[email protected]>
commit 2985ec5c0445f1f298b38aee069b581d1f868c41
Author: Sebastian Rasmussen <[email protected]>
Date:   Fri Nov 1 05:21:56 2019 +0100

    Improve clamping of improbable image resolutions.
    
    Previously if image resolutions were improbably large or small
    in either dimension, MuPDF would scale the resolution to sane
    values. If the two resolutions differed by a large amount that
    difference would remain after rescaling. Now, if a resolution
    in either dimension remains improbably large or small after
    rescaling, simply assume 72 DPI.

diff --git a/source/fitz/image.c b/source/fitz/image.c
index 074cdfc..9d142c5 100644
--- a/source/fitz/image.c
+++ b/source/fitz/image.c
@@ -1289,12 +1289,7 @@ fz_image_resolution(fz_image *image, int *xres, int *yres)
 	/* Scale xres and yres up until we get believable values */
 	if (*xres < SANE_DPI || *yres < SANE_DPI || *xres > INSANE_DPI || *yres > INSANE_DPI)
 	{
-		if (*xres == *yres)
-		{
-			*xres = SANE_DPI;
-			*yres = SANE_DPI;
-		}
-		else if (*xres < *yres)
+		if (*xres < *yres)
 		{
 			*yres = *yres * SANE_DPI / *xres;
 			*xres = SANE_DPI;
@@ -1304,6 +1299,12 @@ fz_image_resolution(fz_image *image, int *xres, int *yres)
 			*xres = *xres * SANE_DPI / *yres;
 			*yres = SANE_DPI;
 		}
+
+		if (*xres == *yres || *xres < SANE_DPI || *yres < SANE_DPI || *xres > INSANE_DPI || *yres > INSANE_DPI)
+		{
+			*xres = SANE_DPI;
+			*yres = SANE_DPI;
+		}
 	}
 }
 

http://git.ghostscript.com/?p=mupdf.git;a=commit;h=2985ec5c0445f1f298b38aee069b581d1f868c41

--
MuPDF library
Artifex Software, Inc.