{"POC",REQ_ARG, NULL ,'P'},
{"ROI",REQ_ARG, NULL ,'R'},
{"jpip",NO_ARG, NULL, 'J'},
- {"mct",REQ_ARG, NULL, 'Y'}
+ {"mct",REQ_ARG, NULL, 'Y'},
+ {"version",NO_ARG, NULL, 'v'}
};
/* parse the command line */
#ifdef USE_JPWL
"W:"
#endif /* USE_JPWL */
- "h";
+ "hv";
totlen=sizeof(long_option);
img_fol->set_out_format=0;
break;
default:
fprintf(stderr,
- "!! Unrecognized format for infile : %s "
- "[accept only *.pnm, *.pgm, *.ppm, *.pgx, *png, *.bmp, *.tif, *.raw or *.tga] !!\n\n",
+ "[ERROR] Unknown input file format: %s \n"
+ " Known file formats are *.pnm, *.pgm, *.ppm, *.pgx, *png, *.bmp, *.tif, *.raw or *.tga\n",
infile);
return 1;
}
/* ----------------------------------------------------- */
+ case 'v': /* display the openjpeg library version in use */
+ fprintf(stdout,"This is the opj_compress utility from the OpenJPEG project.\n"
+ "It has been compiled against openjp2 library v%s.\n",opj_version());
+ return 1;
+
+ /* ----------------------------------------------------- */
+
case 'P': /* POC */
{
int numpocs = 0; /* number of progression order change (POC) default 0 */
default:
- fprintf(stderr, "ERROR -> Command line not valid\n");
- return 1;
+ fprintf(stderr, "[WARNING] An invalid option has been ignored\n");
+ break;
}
}while(c != -1);
if(img_fol->set_imgdir == 1){
if(!(parameters->infile[0] == 0)){
- fprintf(stderr, "Error: options -ImgDir and -i cannot be used together !!\n");
+ fprintf(stderr, "[ERROR] options -ImgDir and -i cannot be used together !!\n");
return 1;
}
if(img_fol->set_out_format == 0){
- fprintf(stderr, "Error: When -ImgDir is used, -OutFor <FORMAT> must be used !!\n");
+ fprintf(stderr, "[ERROR] When -ImgDir is used, -OutFor <FORMAT> must be used !!\n");
fprintf(stderr, "Only one format allowed! Valid formats are j2k and jp2!!\n");
return 1;
}
if(!((parameters->outfile[0] == 0))){
- fprintf(stderr, "Error: options -ImgDir and -o cannot be used together !!\n");
+ fprintf(stderr, "[ERROR] options -ImgDir and -o cannot be used together !!\n");
fprintf(stderr, "Specify OutputFormat using -OutFor<FORMAT> !!\n");
return 1;
}
}else{
if((parameters->infile[0] == 0) || (parameters->outfile[0] == 0)) {
- fprintf(stderr, "Example: %s -i image.ppm -o image.j2k\n",argv[0]);
- fprintf(stderr, " Try: %s -h\n",argv[0]);
+ fprintf(stderr, "[ERROR] Required parameters are missing\n"
+ "Example: %s -i image.j2k -o image.pgm\n",argv[0]);
+ fprintf(stderr, " Help: %s -h\n",argv[0]);
return 1;
}
}
if ( (parameters->decod_format == RAW_DFMT && raw_cp->rawWidth == 0)
|| (parameters->decod_format == RAWL_DFMT && raw_cp->rawWidth == 0)) {
- fprintf(stderr,"\nError: invalid raw image parameters\n");
+ fprintf(stderr,"[ERROR] invalid raw image parameters\n");
fprintf(stderr,"Please use the Format option -F:\n");
fprintf(stderr,"-F rawWidth,rawHeight,rawComp,rawBitDepth,s/u (Signed/Unsigned)\n");
fprintf(stderr,"Example: -i lena.raw -o lena.j2k -F 512,512,3,8,u\n");
if ((parameters->cp_disto_alloc || parameters->cp_fixed_alloc || parameters->cp_fixed_quality)
&& (!(parameters->cp_disto_alloc ^ parameters->cp_fixed_alloc ^ parameters->cp_fixed_quality))) {
- fprintf(stderr, "Error: options -r -q and -f cannot be used together !!\n");
+ fprintf(stderr, "[ERROR] options -r -q and -f cannot be used together !!\n");
return 1;
} /* mod fixed_quality */
if((parameters->cp_tx0 > parameters->image_offset_x0) || (parameters->cp_ty0 > parameters->image_offset_y0)) {
fprintf(stderr,
- "Error: Tile offset dimension is unnappropriate --> TX0(%d)<=IMG_X0(%d) TYO(%d)<=IMG_Y0(%d) \n",
+ "[ERROR] Tile offset dimension is unnappropriate --> TX0(%d)<=IMG_X0(%d) TYO(%d)<=IMG_Y0(%d) \n",
parameters->cp_tx0, parameters->image_offset_x0, parameters->cp_ty0, parameters->image_offset_y0);
return 1;
}
return 1;
}
- fprintf(stderr,"Generated outfile %s\n",parameters.outfile);
+ fprintf(stdout,"[INFO] Generated outfile %s\n",parameters.outfile);
/* close and free the byte stream */
opj_stream_destroy_v3(l_stream);
opj_option_t long_option[]={
{"ImgDir",REQ_ARG, NULL ,'y'},
{"OutFor",REQ_ARG, NULL ,'O'},
+ {"version",NO_ARG, NULL ,'v'}
};
const char optlist[] = "i:o:r:l:x:d:t:"
"W:"
#endif /* USE_JPWL */
/* <<UniPG */
- "h" ;
+ "hv" ;
totlen=sizeof(long_option);
img_fol->set_out_format = 0;
do {
return 1;
default:
fprintf(stderr,
- "!! Unrecognized format for infile: %s [accept only *.j2k, *.jp2, *.jpc or *.jpt] !!\n\n",
+ "[ERROR] Unknown input file format: %s \n"
+ " Known file formats are *.j2k, *.jp2, *.jpc or *.jpt\n",
infile);
return 1;
}
decode_help_display();
return 1;
- /* ------------------------------------------------------ */
+ /* ------------------------------------------------------ */
+
+ case 'v': /* display the openjpeg library version in use */
+ fprintf(stdout,"This is the opj_decompress utility from the OpenJPEG project.\n"
+ "It has been compiled against openjp2 library v%s.\n",opj_version());
+ return 1;
+
+ /* ----------------------------------------------------- */
case 'y': /* Image Directory path */
- {
+ {
img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);
strcpy(img_fol->imgdirpath,opj_optarg);
img_fol->set_imgdir=1;
/* ----------------------------------------------------- */
- default:
- fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, opj_optarg);
- break;
+ default:
+ fprintf(stderr, "[WARNING] An invalid option has been ignored\n");
+ break;
}
}while(c != -1);
/* check for possible errors */
if(img_fol->set_imgdir==1){
if(!(parameters->infile[0]==0)){
- fprintf(stderr, "Error: options -ImgDir and -i cannot be used together !!\n");
+ fprintf(stderr, "[ERROR] options -ImgDir and -i cannot be used together !!\n");
return 1;
}
if(img_fol->set_out_format == 0){
- fprintf(stderr, "Error: When -ImgDir is used, -OutFor <FORMAT> must be used !!\n");
+ fprintf(stderr, "[ERROR] When -ImgDir is used, -OutFor <FORMAT> must be used !!\n");
fprintf(stderr, "Only one format allowed! Valid format PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA!!\n");
return 1;
}
if(!((parameters->outfile[0] == 0))){
- fprintf(stderr, "Error: options -ImgDir and -o cannot be used together !!\n");
+ fprintf(stderr, "[ERROR] options -ImgDir and -o cannot be used together !!\n");
return 1;
}
}else{
if((parameters->infile[0] == 0) || (parameters->outfile[0] == 0)) {
- fprintf(stderr, "Example: %s -i image.j2k -o image.pgm\n",argv[0]);
- fprintf(stderr, " Try: %s -h\n",argv[0]);
+ fprintf(stderr, "[ERROR] Required parameters are missing\n"
+ "Example: %s -i image.j2k -o image.pgm\n",argv[0]);
+ fprintf(stderr, " Help: %s -h\n",argv[0]);
return 1;
}
}
switch (parameters.cod_format) {
case PXM_DFMT: /* PNM PGM PPM */
if (imagetopnm(image, parameters.outfile)) {
- fprintf(stderr,"Outfile %s not generated\n",parameters.outfile);
+ fprintf(stderr,"[ERROR] Outfile %s not generated\n",parameters.outfile);
failed = 1;
}
else {
- fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
+ fprintf(stdout,"[INFO] Generated Outfile %s\n",parameters.outfile);
}
break;
case PGX_DFMT: /* PGX */
if(imagetopgx(image, parameters.outfile)){
- fprintf(stderr,"Outfile %s not generated\n",parameters.outfile);
+ fprintf(stderr,"[ERROR] Outfile %s not generated\n",parameters.outfile);
failed = 1;
}
else {
- fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
+ fprintf(stdout,"[INFO] Generated Outfile %s\n",parameters.outfile);
}
break;
case BMP_DFMT: /* BMP */
if(imagetobmp(image, parameters.outfile)){
- fprintf(stderr,"Outfile %s not generated\n",parameters.outfile);
+ fprintf(stderr,"[ERROR] Outfile %s not generated\n",parameters.outfile);
failed = 1;
}
else {
- fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
+ fprintf(stdout,"[INFO] Generated Outfile %s\n",parameters.outfile);
}
break;
#ifdef OPJ_HAVE_LIBTIFF
case TIF_DFMT: /* TIFF */
if(imagetotif(image, parameters.outfile)){
- fprintf(stderr,"Outfile %s not generated\n",parameters.outfile);
+ fprintf(stderr,"[ERROR] Outfile %s not generated\n",parameters.outfile);
failed = 1;
}
else {
- fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
+ fprintf(stdout,"[INFO] Generated Outfile %s\n",parameters.outfile);
}
break;
#endif /* OPJ_HAVE_LIBTIFF */
case RAW_DFMT: /* RAW */
if(imagetoraw(image, parameters.outfile)){
- fprintf(stderr,"Error generating raw file. Outfile %s not generated\n",parameters.outfile);
+ fprintf(stderr,"[ERROR] Error generating raw file. Outfile %s not generated\n",parameters.outfile);
failed = 1;
}
else {
- fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
+ fprintf(stdout,"[INFO] Generated Outfile %s\n",parameters.outfile);
}
break;
case RAWL_DFMT: /* RAWL */
if(imagetorawl(image, parameters.outfile)){
- fprintf(stderr,"Error generating rawl file. Outfile %s not generated\n",parameters.outfile);
+ fprintf(stderr,"[ERROR] Error generating rawl file. Outfile %s not generated\n",parameters.outfile);
failed = 1;
}
else {
- fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
+ fprintf(stdout,"[INFO] Generated Outfile %s\n",parameters.outfile);
}
break;
case TGA_DFMT: /* TGA */
if(imagetotga(image, parameters.outfile)){
- fprintf(stderr,"Error generating tga file. Outfile %s not generated\n",parameters.outfile);
+ fprintf(stderr,"[ERROR] Error generating tga file. Outfile %s not generated\n",parameters.outfile);
failed = 1;
}
else {
- fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
+ fprintf(stdout,"[INFO] Generated Outfile %s\n",parameters.outfile);
}
break;
#ifdef OPJ_HAVE_LIBPNG
case PNG_DFMT: /* PNG */
if(imagetopng(image, parameters.outfile)){
- fprintf(stderr,"Error generating png file. Outfile %s not generated\n",parameters.outfile);
+ fprintf(stderr,"[ERROR] Error generating png file. Outfile %s not generated\n",parameters.outfile);
failed = 1;
}
else {
- fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
+ fprintf(stdout,"[INFO] Generated Outfile %s\n",parameters.outfile);
}
break;
#endif /* OPJ_HAVE_LIBPNG */
* and OPJ_HAVE_LIBTIF or OPJ_HAVE_LIBPNG is undefined
*/
default:
- fprintf(stderr,"Outfile %s not generated\n",parameters.outfile);
+ fprintf(stderr,"[ERROR] Outfile %s not generated\n",parameters.outfile);
failed = 1;
}