[evince] tiff: Handle incorrect 0 resolution found in TIFF files



commit 24a3d032728ab6cc530fab45d4eb5e232677c928
Author: Gabor Kelemen <kelemeng gnome hu>
Date:   Fri Oct 10 11:49:26 2014 +0200

    tiff: Handle incorrect 0 resolution found in TIFF files
    
    https://bugzilla.gnome.org/show_bug.cgi?id=646414

 backend/tiff/tiff-document.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/backend/tiff/tiff-document.c b/backend/tiff/tiff-document.c
index 80ac0f5..8f40934 100644
--- a/backend/tiff/tiff-document.c
+++ b/backend/tiff/tiff-document.c
@@ -172,9 +172,10 @@ tiff_document_get_resolution (TiffDocument *tiff_document,
                              gfloat       *x_res,
                              gfloat       *y_res)
 {
-       gfloat x = 72.0, y = 72.0;
+       gfloat x = 0.0;
+       gfloat y = 0.0;
        gushort unit;
-       
+
        if (TIFFGetField (tiff_document->tiff, TIFFTAG_XRESOLUTION, &x) &&
            TIFFGetField (tiff_document->tiff, TIFFTAG_YRESOLUTION, &y)) {
                if (TIFFGetFieldDefaulted (tiff_document->tiff, TIFFTAG_RESOLUTIONUNIT, &unit)) {
@@ -185,8 +186,9 @@ tiff_document_get_resolution (TiffDocument *tiff_document,
                }
        }
 
-       *x_res = x;
-       *y_res = y;
+       /* Handle 0 values: some software set TIFF resolution as `0 , 0` see bug #646414 */
+       *x_res = x > 0 ? x : 72.0;
+       *y_res = y > 0 ? y : 72.0;
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]