From 24a3d032728ab6cc530fab45d4eb5e232677c928 Mon Sep 17 00:00:00 2001 From: Gabor Kelemen Date: Fri, 10 Oct 2014 11:49:26 +0200 Subject: tiff: Handle incorrect 0 resolution found in TIFF files https://bugzilla.gnome.org/show_bug.cgi?id=646414 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 -- cgit v0.10.1