http://stackoverflow.com/questions/801054/opencv-cvsaveimage-jpeg-compression-factor
#define CV_IMWRITE_JPEG_QUALITY 1
#define CV_IMWRITE_PNG_COMPRESSION 16
#define CV_IMWRITE_PXM_BINARY 32
/* save image to file */
CVAPI(int) cvSaveImage( const char* filename, const CvArr* image, const int* params CV_DEFAULT(0) );
int p[3];
p[0] = CV_IMWRITE_JPEG_QUALITY;
p[1] = desired_quality_value;
p[2] = 0;
#include <opencv2opencv.hpp>
#include<iostream>
#include <stdio.h>
using namespace cv;
int main(int argc, char **argv) { int p[3]; IplImage *img = cvLoadImage("test.jpg"); p[0] = CV_IMWRITE_JPEG_QUALITY; p[1] = 10; p[2] = 0; cvSaveImage("out1.jpg", img, p); p[0] = CV_IMWRITE_JPEG_QUALITY; p[1] = 100; p[2] = 0; cvSaveImage("out2.jpg", img, p); exit(0); }