Merge pull request #22790 from reunanen:add-capability-to-set-DWA-compression-level-in-OpenEXR-encoding

OpenEXR encoder: add capability to set the DWA compression level

* OpenEXR encoder: add capability to set the DWA compression level from outside

* Do not try to call `header.dwaCompressionLevel()` if OpenEXR is not version 3 or later

* Minor cleanup
pull/24800/head
Juha Reunanen 2 years ago committed by GitHub
parent 2aad039b4f
commit 1ba0984203
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      modules/imgcodecs/include/opencv2/imgcodecs.hpp
  2. 8
      modules/imgcodecs/src/grfmt_exr.cpp

@ -97,6 +97,7 @@ enum ImwriteFlags {
IMWRITE_PXM_BINARY = 32, //!< For PPM, PGM, or PBM, it can be a binary format flag, 0 or 1. Default value is 1.
IMWRITE_EXR_TYPE = (3 << 4) + 0, /* 48 */ //!< override EXR storage type (FLOAT (FP32) is default)
IMWRITE_EXR_COMPRESSION = (3 << 4) + 1, /* 49 */ //!< override EXR compression type (ZIP_COMPRESSION = 3 is default)
IMWRITE_EXR_DWA_COMPRESSION_LEVEL = (3 << 4) + 2, /* 50 */ //!< override EXR DWA compression level (45 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

@ -691,6 +691,14 @@ bool ExrEncoder::write( const Mat& img, const std::vector<int>& params )
CV_Error(Error::StsBadArg, "IMWRITE_EXR_COMPRESSION is invalid or not supported");
}
}
if (params[i] == IMWRITE_EXR_DWA_COMPRESSION_LEVEL)
{
#if OPENEXR_VERSION_MAJOR >= 3
header.dwaCompressionLevel() = params[i + 1];
#else
CV_LOG_ONCE_WARNING(NULL, "Setting `IMWRITE_EXR_DWA_COMPRESSION_LEVEL` not supported in OpenEXR version " + std::to_string(OPENEXR_VERSION_MAJOR) + " (version 3 is required)");
#endif
}
}
if( channels == 3 || channels == 4 )

Loading…
Cancel
Save