Skip to content

Commit c40cd4a

Browse files
blowekampdzenanz
authored andcommitted
ENH: Enable Adobe Deflate Option for TIFF compression
Enables addressing the following warning: TIFFWriteDirectorySec: Warning, Creating TIFF with legacy Deflate codec identifier, COMPRESSION_ADOBE_DEFLATE is more widely supported.
1 parent 322c4f7 commit c40cd4a

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Modules/IO/TIFF/include/itkTIFFImageIO.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ class ITKIOTIFF_EXPORT TIFFImageIO : public ImageIOBase
117117
PackBits,
118118
JPEG,
119119
Deflate,
120+
AdobeDeflate,
120121
LZW
121122
};
122123
// ETX
@@ -150,6 +151,12 @@ class ITKIOTIFF_EXPORT TIFFImageIO : public ImageIOBase
150151
this->SetCompressor("Deflate");
151152
}
152153
void
154+
SetCompressionToAdobeDeflate()
155+
{
156+
this->UseCompressionOn();
157+
this->SetCompressor("AdobeDeflate");
158+
}
159+
void
153160
SetCompressionToLZW()
154161
{
155162
this->UseCompressionOn();

Modules/IO/TIFF/src/itkTIFFImageIO.cxx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,10 @@ TIFFImageIO::InternalSetCompressor(const std::string & _compressor)
279279
{
280280
this->SetCompression(Deflate);
281281
}
282+
else if (_compressor == "ADOBEDEFLATE")
283+
{
284+
this->SetCompression(AdobeDeflate);
285+
}
282286
else if (_compressor == "LZW")
283287
{
284288
this->SetCompression(LZW);
@@ -706,6 +710,8 @@ TIFFImageIO::InternalWrite(const void * buffer)
706710
break;
707711
case TIFFImageIO::Deflate:
708712
compression = COMPRESSION_DEFLATE;
713+
case TIFFImageIO::AdobeDeflate:
714+
compression = COMPRESSION_ADOBE_DEFLATE;
709715
break;
710716
default:
711717
compression = COMPRESSION_NONE;
@@ -746,7 +752,7 @@ TIFFImageIO::InternalWrite(const void * buffer)
746752
TIFFSetField(tif, TIFFTAG_JPEGQUALITY, this->GetJPEGQuality());
747753
TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB);
748754
}
749-
else if (compression == COMPRESSION_DEFLATE)
755+
else if (compression == COMPRESSION_DEFLATE || compression == COMPRESSION_ADOBE_DEFLATE)
750756
{
751757
predictor = PREDICTOR_NONE;
752758
TIFFSetField(tif, TIFFTAG_PREDICTOR, predictor);

0 commit comments

Comments
 (0)