sounds like you want to compress your images, when writing to disk.
here's it for jpeg:
std::vector<int> params;
params.push_back(CV_IMWRITE_JPEG_QUALITY);
params.push_back(100); // that's percent, so 100 == no compression, 1 == full
cv::imwrite("my.jpg",image,params);
and here for png:
std::vector<int> params;
params.push_back(CV_IMWRITE_PNG_COMPRESSION);
params.push_back(9); // that's compression level, 9 == full , 0 == none
cv::imwrite("my.png",image,params);