Skip to content

Commit

Permalink
Added extra check for untiled TIFF images
Browse files Browse the repository at this point in the history
  • Loading branch information
ruven committed Sep 11, 2023
1 parent b9caf9c commit b532eef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 5 additions & 3 deletions src/TPTImage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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--;

Expand Down

0 comments on commit b532eef

Please sign in to comment.