Image codecs
All modules / imgcodecs
imgcodecs_flags
haveImageReaderfunctionChecks if the specified image file can be decoded by OpenCV.
haveImageWriterfunctionChecks if the specified image file or specified file extension can be encoded by OpenCV.
ImageMetadataTypeclassNative enum entries for image metadata type. Pass an entry to enum-typed arguments or its .value to numeric arguments.
imcountfunctionReturns the number of images inside the given file
imdecodefunctionReads an image from a buffer in memory.
imdecodeanimationfunctionLoads frames from an animated image buffer into an Animation structure.
imdecodemultifunctionReads a multi-page image from a buffer in memory.
imdecodeWithMetadatafunctionReads an image from a memory buffer and extracts associated metadata.
imencodefunctionEncodes an image into a memory buffer.
imencodeanimationfunctionEncodes an Animation to a memory buffer.
imencodemultifunctionEncodes array of images into a memory buffer.
imencodeWithMetadatafunctionEncodes an image into a memory buffer.
imreadfunctionLoads an image from a file.
imread1functionLoads an image from a file.
imreadanimationfunctionexample: samples/cpp/tutorial_code/imgcodecs/animations.cpp
ImreadModesclassImread flags
imreadmultifunctionLoads a multi-page image from a file.
imreadmulti1functionLoads images of a multi-page image from a file.
imreadWithMetadatafunctionReads an image from a file along with associated metadata.
imwritefunctionSaves an image to a specified file.
imwriteanimationfunctionSaves an Animation to a specified file.
ImwriteBMPCompressionFlagsclassImwrite BMP specific values for IMWRITE_BMP_COMPRESSION parameter key.
ImwriteEXRCompressionFlagsclassNative enum entries for imwrite exrcompression flags. Pass an entry to enum-typed arguments or its .value to numeric arguments.
ImwriteEXRTypeFlagsclassNative enum entries for imwrite exrtype flags. Pass an entry to enum-typed arguments or its .value to numeric arguments.
ImwriteFlagsclassImwriteFlags: Imwrite flags
ImwriteGIFCompressionFlagsclassImwrite GIF specific values for IMWRITE_GIF_QUALITY parameter key, if larger than 3, then its related to the size of the color table.
ImwriteHDRCompressionFlagsclassImwrite HDR specific values for IMWRITE_HDR_COMPRESSION parameter key
ImwriteJPEGSamplingFactorParamsclassNative enum entries for imwrite jpegsampling factor params. Pass an entry to enum-typed arguments or its .value to numeric arguments.
imwritemultifunctionEncode and save multiple images to a supported multi-page format in the virtual filesystem. Return whether encoding succeeded.
ImwritePAMFlagsclassImwrite PAM specific tupletype flags used to define the 'TUPLETYPE' field of a PAM file.
ImwritePNGFilterFlagsclassImwrite PNG specific values for IMWRITE_PNG_FILTER parameter key
ImwritePNGFlagsclassImwrite PNG specific flags used to tune the compression algorithm.
ImwriteTiffCompressionFlagsclassNative enum entries for imwrite tiff compression flags. Pass an entry to enum-typed arguments or its .value to numeric arguments.
ImwriteTiffPredictorFlagsclassNative enum entries for imwrite tiff predictor flags. Pass an entry to enum-typed arguments or its .value to numeric arguments.
ImwriteTiffResolutionUnitFlagsclassNative enum entries for imwrite tiff resolution unit flags. Pass an entry to enum-typed arguments or its .value to numeric arguments.
ImwriteWEBPLosslessModeclassImwrite WEBP specific values for IMWRITE_WEBP_LOSSLESS_MODE parameter key.
imwriteWithMetadatafunctionSaves an image to a specified file with metadata
No matches. Try an algorithm name, a module, or a shorter phrase.
Constants
Use the named constant from cv. In particular, OpenCV 5 matrix type codes differ from OpenCV 4.
IMREAD_UNCHANGEDIf set, return the loaded image as is (with alpha channel, otherwise it gets cropped). Ignore EXIF orientation.
IMREAD_GRAYSCALEIf set, always convert image to the single channel grayscale image (codec internal conversion).
IMREAD_COLOR_BGRSame as IMREAD_COLOR_BGR.
IMREAD_COLORSame as IMREAD_COLOR_BGR.
IMREAD_ANYDEPTHIf set, return 16-bit/32-bit image when the input has the corresponding depth, otherwise convert it to 8-bit.
IMREAD_ANYCOLORIf set, the image is read in any possible color format.
IMREAD_LOAD_GDALIf set, use the gdal driver for loading the image.
IMREAD_REDUCED_GRAYSCALE_2If set, always convert image to the single channel grayscale image and the image size reduced 1/2.
IMREAD_REDUCED_COLOR_2If set, always convert image to the 3 channel BGR color image and the image size reduced 1/2.
IMREAD_REDUCED_GRAYSCALE_4If set, always convert image to the single channel grayscale image and the image size reduced 1/4.
IMREAD_REDUCED_COLOR_4If set, always convert image to the 3 channel BGR color image and the image size reduced 1/4.
IMREAD_REDUCED_GRAYSCALE_8If set, always convert image to the single channel grayscale image and the image size reduced 1/8.
IMREAD_REDUCED_COLOR_8If set, always convert image to the 3 channel BGR color image and the image size reduced 1/8.
IMREAD_IGNORE_ORIENTATIONIf set, do not rotate the image according to EXIF's orientation flag.
IMREAD_COLOR_RGBIf set, always convert image to the 3 channel RGB color image.
IMWRITE_JPEG_QUALITYFor JPEG, it can be a quality from 0 to 100 (the higher is the better). Default value is 95.
IMWRITE_JPEG_PROGRESSIVEEnable JPEG features, 0 or 1, default is False.
IMWRITE_JPEG_OPTIMIZEEnable JPEG features, 0 or 1, default is False.
IMWRITE_JPEG_RST_INTERVALJPEG restart interval, 0 - 65535, default is 0 - no restart.
IMWRITE_JPEG_LUMA_QUALITYSeparate luma quality level, 0 - 100, default is -1 - don't use. If JPEG_LIB_VERSION < 70, Not supported.
IMWRITE_JPEG_CHROMA_QUALITYSeparate chroma quality level, 0 - 100, default is -1 - don't use. If JPEG_LIB_VERSION < 70, Not supported.
IMWRITE_JPEG_SAMPLING_FACTORFor JPEG, set sampling factor. See cv::ImwriteJPEGSamplingFactorParams.
IMWRITE_PNG_COMPRESSIONFor PNG, it can be the compression level from 0 to 9. A higher value means a smaller size and longer compression time. If specified, strategy is changed to IMWRITE_PNG_STRATEGY_DEFAULT (Z_DEFAULT_STRATEGY). Default value is 1 (best speed setting).
IMWRITE_PNG_STRATEGYFor PNG, One of cv::ImwritePNGFlags, default is IMWRITE_PNG_STRATEGY_RLE.
IMWRITE_PNG_BILEVELFor PNG, Binary level PNG, 0 or 1, default is 0. For APNG, it is not supported.
IMWRITE_PNG_FILTERFor PNG, One of cv::ImwritePNGFilterFlags, default is IMWRITE_PNG_FILTER_SUB. For APNG, it is not supported.
IMWRITE_PNG_ZLIBBUFFER_SIZEFor PNG with libpng, sets the size of the internal zlib compression buffer in bytes, from 6 to 1048576(1024 KiB). Default is 8192(8 KiB). For normal use, 131072(128 KiB) or 262144(256 KiB) may be sufficient. If WITH_SPNG=ON, it is not supported. For APNG, it is not supported.
IMWRITE_PXM_BINARYFor PPM, PGM, or PBM, it can be a binary format flag, 0 or 1. Default value is 1.
IMWRITE_EXR_TYPE48 * /, //!< override EXR storage type (FLOAT (FP32) is default)
IMWRITE_EXR_COMPRESSION49 * /, //!< override EXR compression type (ZIP_COMPRESSION = 3 is default)
IMWRITE_EXR_DWA_COMPRESSION_LEVEL50 * /, //!< override EXR DWA compression level (45 is default)
IMWRITE_WEBP_QUALITYFor WEBP, it can be a lossy quality from 1 to 100 (the higher is the better) for IMWRITE_WEBP_LOSSLESS_OFF. By default (without this parameter) or if quality > 100, IMWRITE_WEBP_LOSSLESS_ON is used instead.
IMWRITE_WEBP_LOSSLESS_MODEFor WEBP, it can be a lossless compression strategy. See cv::ImwriteWEBPLosslessMode. Default is IMWRITE_WEBP_LOSSLESS_OFF. For Animated WEBP, it is not supported.
IMWRITE_HDR_COMPRESSION80 * /, //!< specify HDR compression
IMWRITE_PAM_TUPLETYPEFor PAM, sets the TUPLETYPE field to the corresponding string value that is defined for the format
IMWRITE_TIFF_RESUNITFor TIFF, use to specify which DPI resolution unit to set. See ImwriteTiffResolutionUnitFlags. Default is IMWRITE_TIFF_RESOLUTION_UNIT_INCH.
IMWRITE_TIFF_XDPIFor TIFF, use to specify the X direction DPI
IMWRITE_TIFF_YDPIFor TIFF, use to specify the Y direction DPI
IMWRITE_TIFF_COMPRESSIONFor TIFF, use to specify the image compression scheme. See cv::ImwriteTiffCompressionFlags. The compression scheme can be specified by this flag; the default is LZW compression, except for 32F depth where it is NONE
IMWRITE_TIFF_ROWSPERSTRIPFor TIFF, use to specify the number of rows per strip.
IMWRITE_TIFF_PREDICTORFor TIFF, use to specify predictor. See cv::ImwriteTiffPredictorFlags. Default is IMWRITE_TIFF_PREDICTOR_HORIZONTAL .
IMWRITE_JPEG2000_COMPRESSION_X1000For JPEG2000, use to specify the target compression rate (multiplied by 1000). The value can be from 0 to 1000. Default is 1000.
IMWRITE_AVIF_QUALITYFor AVIF, it can be a quality between 0 and 100 (the higher the better). Default is 95.
IMWRITE_AVIF_DEPTHFor AVIF, it can be 8, 10 or 12. If >8, it is stored/read as CV_16U. Default is 8.
IMWRITE_AVIF_SPEEDFor AVIF, it is between 0 (slowest) and 10(fastest). Default is 9.
IMWRITE_JPEGXL_QUALITYFor JPEG XL, it can be a quality from 0 to 100 (the higher is the better). Default value is 95. If set, distance parameter is re-calicurated from quality level automatically. This parameter request libjxl v0.10 or later.
IMWRITE_JPEGXL_EFFORTFor JPEG XL, encoder effort/speed level without affecting decoding speed; it is between 1 (fastest) and 10 (slowest). Default is 7.
IMWRITE_JPEGXL_DISTANCEFor JPEG XL, distance level for lossy compression: target max butteraugli distance, lower = higher quality, 0 = lossless; range: 0 .. 25. Default is 1.
IMWRITE_JPEGXL_DECODING_SPEEDFor JPEG XL, decoding speed tier for the provided options; minimum is 0 (slowest to decode, best quality/density), and maximum is 4 (fastest to decode, at the cost of some quality/density). Default is 0.
IMWRITE_BMP_COMPRESSIONFor BMP, use to specify compress parameter for 32bpp image. Default is IMWRITE_BMP_COMPRESSION_BITFIELDS. See cv::ImwriteBMPCompressionFlags.
IMWRITE_GIF_LOOPNot functional since 4.12.0. Replaced by cv::Animation::loop_count.
IMWRITE_GIF_SPEEDNot functional since 4.12.0. Replaced by cv::Animation::durations.
IMWRITE_GIF_QUALITYFor GIF, it can be a quality from 1 to 8. Default is 2. See cv::ImwriteGifCompressionFlags.
IMWRITE_GIF_DITHERFor GIF, it can be a quality from -1(most dither) to 3(no dither). Default is 0.
IMWRITE_GIF_TRANSPARENCYFor GIF, the alpha channel lower than this will be set to transparent. Default is 1.
IMWRITE_GIF_COLORTABLEFor GIF, 0 means global color table is used, 1 means local color table is used. Default is 0.
IMWRITE_JPEG_SAMPLING_FACTOR_411IMWRITE_JPEG_SAMPLING_FACTOR_411: 4x1,1x1,1x1
IMWRITE_JPEG_SAMPLING_FACTOR_4202x2,1x1,1x1(Default)
IMWRITE_JPEG_SAMPLING_FACTOR_422IMWRITE_JPEG_SAMPLING_FACTOR_422: 2x1,1x1,1x1
IMWRITE_JPEG_SAMPLING_FACTOR_440IMWRITE_JPEG_SAMPLING_FACTOR_440: 1x2,1x1,1x1
IMWRITE_JPEG_SAMPLING_FACTOR_4441x1,1x1,1x1(No subsampling)
IMWRITE_TIFF_COMPRESSION_NONEIMWRITE_TIFF_COMPRESSION_NONE: dump mode
IMWRITE_TIFF_COMPRESSION_CCITTRLECCITT modified Huffman RLE
IMWRITE_TIFF_COMPRESSION_CCITTFAX3CCITT Group 3 fax encoding
IMWRITE_TIFF_COMPRESSION_CCITT_T4CCITT T.4 (TIFF 6 name)
IMWRITE_TIFF_COMPRESSION_CCITTFAX4CCITT Group 4 fax encoding
IMWRITE_TIFF_COMPRESSION_CCITT_T6CCITT T.6 (TIFF 6 name)
IMWRITE_TIFF_COMPRESSION_LZWLempel-Ziv & Welch
IMWRITE_TIFF_COMPRESSION_OJPEGIMWRITE_TIFF_COMPRESSION_OJPEG: !6.0 JPEG
IMWRITE_TIFF_COMPRESSION_JPEG%JPEG DCT compression
IMWRITE_TIFF_COMPRESSION_T85!TIFF/FX T.85 JBIG compression
IMWRITE_TIFF_COMPRESSION_T43!TIFF/FX T.43 colour by layered JBIG compression
IMWRITE_TIFF_COMPRESSION_NEXTIMWRITE_TIFF_COMPRESSION_NEXT: NeXT 2-bit RLE
IMWRITE_TIFF_COMPRESSION_CCITTRLEW#1 w/ word alignment
IMWRITE_TIFF_COMPRESSION_PACKBITSIMWRITE_TIFF_COMPRESSION_PACKBITS: Macintosh RLE
IMWRITE_TIFF_COMPRESSION_THUNDERSCANThunderScan RLE
IMWRITE_TIFF_COMPRESSION_IT8CTPADIT8 CT w/padding
IMWRITE_TIFF_COMPRESSION_IT8LWIT8 Linework RLE
IMWRITE_TIFF_COMPRESSION_IT8MPIT8 Monochrome picture
IMWRITE_TIFF_COMPRESSION_IT8BLIT8 Binary line art
IMWRITE_TIFF_COMPRESSION_PIXARFILMPixar companded 10bit LZW
IMWRITE_TIFF_COMPRESSION_PIXARLOGPixar companded 11bit ZIP
IMWRITE_TIFF_COMPRESSION_DEFLATEDeflate compression, legacy tag
IMWRITE_TIFF_COMPRESSION_ADOBE_DEFLATEDeflate compression, as recognized by Adobe
IMWRITE_TIFF_COMPRESSION_DCSKodak DCS encoding
IMWRITE_TIFF_COMPRESSION_JBIGIMWRITE_TIFF_COMPRESSION_JBIG: ISO JBIG
IMWRITE_TIFF_COMPRESSION_SGILOGSGI Log Luminance RLE
IMWRITE_TIFF_COMPRESSION_SGILOG24SGI Log 24-bit packed
IMWRITE_TIFF_COMPRESSION_JP2000Leadtools JPEG2000
IMWRITE_TIFF_COMPRESSION_LERCESRI Lerc codec: https://github.com/Esri/lerc
IMWRITE_TIFF_COMPRESSION_LZMAIMWRITE_TIFF_COMPRESSION_LZMA: LZMA2
IMWRITE_TIFF_COMPRESSION_ZSTDZSTD: WARNING not registered in Adobe-maintained registry
IMWRITE_TIFF_COMPRESSION_WEBPWEBP: WARNING not registered in Adobe-maintained registry
IMWRITE_TIFF_COMPRESSION_JXLJPEGXL: WARNING not registered in Adobe-maintained registry
IMWRITE_TIFF_PREDICTOR_NONEno prediction scheme used
IMWRITE_TIFF_PREDICTOR_HORIZONTALhorizontal differencing
IMWRITE_TIFF_PREDICTOR_FLOATINGPOINTfloating point predictor
IMWRITE_TIFF_RESOLUTION_UNIT_NONEno absolute unit of measurement.
IMWRITE_TIFF_RESOLUTION_UNIT_INCHIMWRITE_TIFF_RESOLUTION_UNIT_INCH: inch
IMWRITE_TIFF_RESOLUTION_UNIT_CENTIMETERIMWRITE_TIFF_RESOLUTION_UNIT_CENTIMETER: centimeter
IMWRITE_EXR_TYPE_HALFstore as HALF (FP16)
IMWRITE_EXR_TYPE_FLOATstore as FP32 (default)
IMWRITE_EXR_COMPRESSION_NOIMWRITE_EXR_COMPRESSION_NO: no compression
IMWRITE_EXR_COMPRESSION_RLErun length encoding
IMWRITE_EXR_COMPRESSION_ZIPSzlib compression, one scan line at a time
IMWRITE_EXR_COMPRESSION_ZIPzlib compression, in blocks of 16 scan lines
IMWRITE_EXR_COMPRESSION_PIZpiz-based wavelet compression
IMWRITE_EXR_COMPRESSION_PXR24lossy 24-bit float compression
IMWRITE_EXR_COMPRESSION_B44lossy 4-by-4 pixel block compression, fixed compression rate
IMWRITE_EXR_COMPRESSION_B44Alossy 4-by-4 pixel block compression, flat fields are compressed more
IMWRITE_EXR_COMPRESSION_DWAAlossy DCT based compression, in blocks of 32 scanlines. More efficient for partial buffer access. Supported since OpenEXR 2.2.0.
IMWRITE_EXR_COMPRESSION_DWABlossy DCT based compression, in blocks of 256 scanlines. More efficient space wise and faster to decode full frames than DWAA_COMPRESSION. Supported since OpenEXR 2.2.0.
IMWRITE_PNG_STRATEGY_DEFAULTUse this value for normal data.
IMWRITE_PNG_STRATEGY_FILTEREDUse this value for data produced by a filter (or predictor).Filtered data consists mostly of small values with a somewhat random distribution. In this case, the compression algorithm is tuned to compress them better.
IMWRITE_PNG_STRATEGY_HUFFMAN_ONLYUse this value to force Huffman encoding only (no string match).
IMWRITE_PNG_STRATEGY_RLEUse this value to limit match distances to one (run-length encoding).
IMWRITE_PNG_STRATEGY_FIXEDUsing this value prevents the use of dynamic Huffman codes, allowing for a simpler decoder for special applications.
IMWRITE_PNG_FILTER_NONEThis is a combination of IMWRITE_PNG_FILTER_NONE, IMWRITE_PNG_FILTER_SUB, and IMWRITE_PNG_FILTER_UP, typically used for faster compression.
IMWRITE_PNG_FILTER_SUBThis is a combination of IMWRITE_PNG_FILTER_NONE, IMWRITE_PNG_FILTER_SUB, and IMWRITE_PNG_FILTER_UP, typically used for faster compression.
IMWRITE_PNG_FILTER_UPThis is a combination of IMWRITE_PNG_FILTER_NONE, IMWRITE_PNG_FILTER_SUB, and IMWRITE_PNG_FILTER_UP, typically used for faster compression.
IMWRITE_PNG_FILTER_AVGThis combines all available filters (NONE, SUB, UP, AVG, and PAETH), which will attempt to apply all of them for the best possible compression.
IMWRITE_PNG_FILTER_PAETHThis combines all available filters (NONE, SUB, UP, AVG, and PAETH), which will attempt to apply all of them for the best possible compression.
IMWRITE_PNG_FAST_FILTERSThis combines all available filters (NONE, SUB, UP, AVG, and PAETH), which will attempt to apply all of them for the best possible compression.
IMWRITE_PNG_ALL_FILTERSThis combines all available filters (NONE, SUB, UP, AVG, and PAETH), which will attempt to apply all of them for the best possible compression.
IMWRITE_PAM_FORMAT_NULLimwrite pam format null constant (0), defined by OpenCV for cv.
IMWRITE_PAM_FORMAT_BLACKANDWHITEimwrite pam format blackandwhite constant (1), defined by OpenCV for cv.
IMWRITE_PAM_FORMAT_GRAYSCALEimwrite pam format grayscale constant (2), defined by OpenCV for cv.
IMWRITE_PAM_FORMAT_GRAYSCALE_ALPHAimwrite pam format grayscale alpha constant (3), defined by OpenCV for cv.
IMWRITE_PAM_FORMAT_RGBimwrite pam format rgb constant (4), defined by OpenCV for cv.
IMWRITE_PAM_FORMAT_RGB_ALPHAimwrite pam format rgb alpha constant (5), defined by OpenCV for cv.
IMWRITE_WEBP_LOSSLESS_OFFLossy compression mode. Uses IMWRITE_WEBP_QUALITY to control compression. (Default)
IMWRITE_WEBP_LOSSLESS_ONStandard lossless compression. May modify or discard RGB values of fully transparent pixels to improve compression ratio.
IMWRITE_WEBP_LOSSLESS_PRESERVE_COLORExact lossless compression. Preserves all RGB data even for pixels with 0 alpha (equivalent to WebP's exact flag).
IMWRITE_HDR_COMPRESSION_NONEimwrite hdr compression none constant (0), defined by OpenCV for cv.
IMWRITE_HDR_COMPRESSION_RLEimwrite hdr compression rle constant (1), defined by OpenCV for cv.
IMWRITE_BMP_COMPRESSION_RGBUse BI_RGB. OpenCV v4.12.0 or before supports to encode with this compression only.
IMWRITE_BMP_COMPRESSION_BITFIELDSUse BI_BITFIELDS. OpenCV v4.13.0 or later can support to encode with this compression. (only for 32 BPP images)
IMWRITE_GIF_FAST_NO_DITHERimwrite gif fast no dither constant (1), defined by OpenCV for cv.
IMWRITE_GIF_FAST_FLOYD_DITHERimwrite gif fast floyd dither constant (2), defined by OpenCV for cv.
IMWRITE_GIF_COLORTABLE_SIZE_8imwrite gif colortable size 8 constant (3), defined by OpenCV for cv.
IMWRITE_GIF_COLORTABLE_SIZE_16imwrite gif colortable size 16 constant (4), defined by OpenCV for cv.
IMWRITE_GIF_COLORTABLE_SIZE_32imwrite gif colortable size 32 constant (5), defined by OpenCV for cv.
IMWRITE_GIF_COLORTABLE_SIZE_64imwrite gif colortable size 64 constant (6), defined by OpenCV for cv.
IMWRITE_GIF_COLORTABLE_SIZE_128imwrite gif colortable size 128 constant (7), defined by OpenCV for cv.
IMWRITE_GIF_COLORTABLE_SIZE_256imwrite gif colortable size 256 constant (8), defined by OpenCV for cv.
IMAGE_METADATA_UNKNOWNUsed when metadata type is unrecognized or not set
IMAGE_METADATA_EXIFEXIF metadata (e.g., camera info, GPS, orientation)
IMAGE_METADATA_XMPXMP metadata (eXtensible Metadata Platform - Adobe format)
IMAGE_METADATA_ICCPICC Profile (color profile for color management)
IMAGE_METADATA_CICPcICP Profile (video signal type)
IMAGE_METADATA_MAXHighest valid index (usually used for bounds checking)