Load an arbitrary format from disk and use libJpeg to convert it to JPEG-image with given (dflt 60) quality
- Author
- Arne Petersen
#include <Base/Image/ImageBase.hh>
#include <Base/Image/ImageIO.hh>
#include <Base/Image/CompressJpeg.hh>
using namespace BIAS;
using namespace std;
int main(int argc, char *argv[])
{
if ((argc<3)||(argc>4)) {
cout <<"usage: "<<argv[0]<<" <in-image-file> <out-image-file>"
" [<jpeg-quality: 0..100>]"<<endl;
return -1;
}
if (result!=0){
BIASERR("Error while loading '"<<argv[1]<<"' with result="<<result);
return result;
}
int quality = 60;
if (argc > 3) quality = atoi(argv[3]);
if ((quality < 0)||(quality > 100)) {
BIASERR("Given quality (" << quality << ") not valid!");
return -1;
}
int res = jHandler.
Compress(srcImg, quality);
if (res < 0) {
BIASERR("Compression failed (returned "<< res <<")!!!");
return -1;
}
string filename(argv[2]);
BIASERR("Error writing jpeg-image to " << argv[2] << "!!!");
return -1;
}
return 0;
}