Details
-
Suggestion
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
None
-
None
Description
Currently, QTiffHandler only supports the values COMPRESSION_NONE and COMPRESSION_LZW of TIFFTAG_COMPRESSION, which corresponds to values of 0 and 1 in QImageWriter::setCompression, respectively.
To me this looks like a rather arbitrary restriction. In my quick test the obvious extension to
enum Compression {
NoCompression = 0,
LzwCompression = 1,
HuffmanRLECompression = 2,
Group3Compression = 3,
Group4Compression = 4,
JpegCompression = 5
};
with a conversion function
int QTiffHandler::toLibTiffCompression(const int compression) const { switch(compression) { case QTiffHandler::NoCompression: return COMPRESSION_NONE; case QTiffHandler::LzwCompression: return COMPRESSION_LZW; case QTiffHandler::HuffmanRLECompression: return COMPRESSION_CCITTRLE; case QTiffHandler::Group3Compression: return COMPRESSION_CCITTFAX3; case QTiffHandler::Group4Compression: return COMPRESSION_CCITTFAX4; case QTiffHandler::JpegCompression: return COMPRESSION_JPEG; default: return COMPRESSION_NONE; } }
appeared to work just fine. This helped me reduce the resulting image size for a monochrome 1bpp image by being able to set Group4 compression.
So to me this poses the question why only two compression types are supported by the QTiffHandler and whether this was a concious decision.
If not and there are no strong arguments against adding support for more compression types, it would be great if you could do so, since I'd prefer not having to alter the code every time I update Qt.