Skip to content

Commit

Permalink
Disable pass-through for TIFF-JPEGs where YCbCr sub-sampling has been…
Browse files Browse the repository at this point in the history
… defined with an RGB color space - these require the full JFIF format rather than the abreviated JPEG within the TIFF
  • Loading branch information
ruven committed Jan 26, 2024
1 parent f88a826 commit 02fd88a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
26/01/2024:
- Disable pass-through for TIFF-JPEGs where YCbCr sub-sampling has been defined with an RGB color space -
these require the full JFIF format rather than the abreviated JPEG within the TIFF


25/01/2024:
- Fix to calculation of DPI in pixels/m when returned in IIP OBJ request

Expand Down
12 changes: 11 additions & 1 deletion src/TPTImage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/* IIP Server: Tiled Pyramidal TIFF handler
Copyright (C) 2000-2023 Ruven Pillay.
Copyright (C) 2000-2024 Ruven Pillay.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -521,6 +521,16 @@ RawTile TPTImage::getTile( int x, int y, unsigned int res, int layers, unsigned
requested_encoding = ImageEncoding::RAW;
}

// Also disable pass-through for TIFF-JPEGs where YCbCr sub-sampling has been defined with an RGB color space - these
// require the full JFIF format rather than the abreviated JPEG within the TIFF
if( requested_encoding == ImageEncoding::JPEG && compression == COMPRESSION_JPEG ){
uint16_t subsampling[2];
if( (TIFFGetField( tiff, TIFFTAG_YCBCRSUBSAMPLING, &subsampling[0], &subsampling[1] ) != 0) && (colour == PHOTOMETRIC_RGB) ){
if( IIPImage::logging ) logfile << "TPTImage :: Sub-sampled RGB JPEG-encoded TIFF: tile decoded to RAW" << endl;
requested_encoding = ImageEncoding::RAW;
}
}


// Get raw pre-encoded tile if our request matches the tile encoding - only currently makes sense for JPEG and WEBP
if( requested_encoding == ImageEncoding::JPEG && compression == COMPRESSION_JPEG ){
Expand Down

0 comments on commit 02fd88a

Please sign in to comment.