From b532eeff23dbd605b8df86e23c074f1ec1ba53d1 Mon Sep 17 00:00:00 2001 From: ruven Date: Mon, 11 Sep 2023 16:00:42 +0200 Subject: [PATCH] Added extra check for untiled TIFF images --- ChangeLog | 3 +++ src/TPTImage.cc | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index c4949b6d..86ae5006 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +11/09/2023: + - Added extra check for untiled TIFF images + 07/09/2023: - Fix normalization in convolution when kernel sums to zero diff --git a/src/TPTImage.cc b/src/TPTImage.cc index 20ba7000..e9bf1bbd 100644 --- a/src/TPTImage.cc +++ b/src/TPTImage.cc @@ -103,9 +103,7 @@ void TPTImage::loadImageInfo( int seq, int ang ) currentX = seq; currentY = ang; - // Get the tile and image sizes - TIFFGetField( tiff, TIFFTAG_TILEWIDTH, &tw ); - TIFFGetField( tiff, TIFFTAG_TILELENGTH, &th ); + // Get various essential image parameters TIFFGetField( tiff, TIFFTAG_IMAGEWIDTH, &w ); TIFFGetField( tiff, TIFFTAG_IMAGELENGTH, &h ); TIFFGetField( tiff, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel ); @@ -116,6 +114,10 @@ void TPTImage::loadImageInfo( int seq, int ang ) TIFFGetField( tiff, TIFFTAG_YRESOLUTION, &dpi_y ); TIFFGetField( tiff, TIFFTAG_RESOLUTIONUNIT, &dpi_units ); + // If image is untiled, set tile sizes to zero + if( TIFFGetField( tiff, TIFFTAG_TILEWIDTH, &tw ) == 0 ) tw = 0; + if( TIFFGetField( tiff, TIFFTAG_TILEWIDTH, &th ) == 0 ) th = 0; + // Units for libtiff are 1=unknown, 2=DPI and 3=pixels/cm, whereas we want 0=unknown, 1=DPI and 2=pixels/cm dpi_units--;