issue-13921: Support setting compression setting for writing tiff images
authorRajkiran Natarajan <saskatchewancatch@gmail.com>
Sat, 9 Mar 2019 20:48:21 +0000 (15:48 -0500)
committerRajkiran Natarajan <saskatchewancatch@gmail.com>
Sat, 9 Mar 2019 20:48:21 +0000 (15:48 -0500)
modules/imgcodecs/include/opencv2/imgcodecs.hpp
modules/imgcodecs/src/grfmt_tiff.cpp

index 4e79518..ab75990 100644 (file)
@@ -92,9 +92,10 @@ enum ImwriteFlags {
        IMWRITE_EXR_TYPE            = (3 << 4) + 0, /* 48 */ //!< override EXR storage type (FLOAT (FP32) is default)
        IMWRITE_WEBP_QUALITY        = 64, //!< For WEBP, it can be a quality from 1 to 100 (the higher is the better). By default (without any parameter) and for quality above 100 the lossless compression is used.
        IMWRITE_PAM_TUPLETYPE       = 128,//!< For PAM, sets the TUPLETYPE field to the corresponding string value that is defined for the format
-       IMWRITE_TIFF_RESUNIT = 256,//!< For TIFF, use to specify which DPI resolution unit to set; see libtiff documentation for valid values
-       IMWRITE_TIFF_XDPI = 257,//!< For TIFF, use to specify the X direction DPI
-       IMWRITE_TIFF_YDPI = 258 //!< For TIFF, use to specify the Y direction DPI
+       IMWRITE_TIFF_RESUNIT = 256,//!< For TIFF, use to specify which DPI resolution unit to set; see libtiff documentation for valid values.
+       IMWRITE_TIFF_XDPI = 257,//!< For TIFF, use to specify the X direction DPI.
+       IMWRITE_TIFF_YDPI = 258, //!< For TIFF, use to specify the Y direction DPI.
+       IMWRITE_TIFF_COMPRESSION = 259 //!< For TIFF, use to specify the image compression scheme. See libtiff for integer constants corresponding to compression formats. Note, for images whose depth is CV_32F, only libtiff's SGILOG compression scheme is used. For other supported depths, the compression scheme can be specified by this flag; LZW compression is the default.
      };
 
 enum ImwriteEXRTypeFlags {
index b83ab10..40295df 100644 (file)
@@ -750,12 +750,11 @@ bool TiffEncoder::writeLibTiff( const std::vector<Mat>& img_vec, const std::vect
     }
 
     //Settings that matter to all images
-    // defaults for now, maybe base them on params in the future
     int compression = COMPRESSION_LZW;
     int predictor = PREDICTOR_HORIZONTAL;
     int resUnit = -1, dpiX = -1, dpiY = -1;
 
-    readParam(params, TIFFTAG_COMPRESSION, compression);
+    readParam(params, IMWRITE_TIFF_COMPRESSION, compression);
     readParam(params, TIFFTAG_PREDICTOR, predictor);
     readParam(params, IMWRITE_TIFF_RESUNIT, resUnit);
     readParam(params, IMWRITE_TIFF_XDPI, dpiX);