42 #define JMESSAGE(code,string) string , 85 #ifdef TARGA_SUPPORTED 88 ERREXIT(cinfo, JERR_TGA_NOTCOMP);
92 if ((c = getc(infile)) == EOF)
93 ERREXIT(cinfo, JERR_INPUT_EMPTY);
94 if (ungetc(c, infile) == EOF)
95 ERREXIT(cinfo, JERR_UNGETC_FAILED);
112 return jinit_read_rle(cinfo);
114 #ifdef TARGA_SUPPORTED 119 ERREXIT(cinfo, JERR_UNKNOWN_FORMAT);
144 fprintf(stderr,
"usage: %s [switches] ",
progname);
145 #ifdef TWO_FILE_COMMANDLINE 146 fprintf(stderr,
"inputfile outputfile\n");
148 fprintf(stderr,
"[inputfile]\n");
151 fprintf(stderr,
"Switches (names may be abbreviated):\n");
152 fprintf(stderr,
" -quality N Compression quality (0..100; 5-95 is useful range)\n");
153 fprintf(stderr,
" -grayscale Create monochrome JPEG file\n");
154 #ifdef ENTROPY_OPT_SUPPORTED 155 fprintf(stderr,
" -optimize Optimize Huffman table (smaller file, but slow compression)\n");
157 #ifdef C_PROGRESSIVE_SUPPORTED 158 fprintf(stderr,
" -progressive Create progressive JPEG file\n");
160 #ifdef TARGA_SUPPORTED 161 fprintf(stderr,
" -targa Input file is Targa format (usually not needed)\n");
163 fprintf(stderr,
"Switches for advanced users:\n");
164 #ifdef DCT_ISLOW_SUPPORTED 165 fprintf(stderr,
" -dct int Use integer DCT method%s\n",
168 #ifdef DCT_IFAST_SUPPORTED 169 fprintf(stderr,
" -dct fast Use fast integer DCT (less accurate)%s\n",
172 #ifdef DCT_FLOAT_SUPPORTED 173 fprintf(stderr,
" -dct float Use floating-point DCT method%s\n",
176 fprintf(stderr,
" -restart N Set restart interval in rows, or in blocks with B\n");
177 #ifdef INPUT_SMOOTHING_SUPPORTED 178 fprintf(stderr,
" -smooth N Smooth dithered input (N=1..100 is strength)\n");
180 fprintf(stderr,
" -maxmemory N Maximum memory to use (in kbytes)\n");
181 fprintf(stderr,
" -outfile name Specify name for output file\n");
182 fprintf(stderr,
" -verbose or -debug Emit debug output\n");
183 fprintf(stderr,
"Switches for wizards:\n");
184 #ifdef C_ARITH_CODING_SUPPORTED 185 fprintf(stderr,
" -arithmetic Use arithmetic coding\n");
187 fprintf(stderr,
" -baseline Force baseline quantization tables\n");
188 fprintf(stderr,
" -qtables file Use quantization tables given in file\n");
189 fprintf(stderr,
" -qslots N[,...] Set component quantization tables\n");
190 fprintf(stderr,
" -sample HxV[,...] Set component sampling factors\n");
191 #ifdef C_MULTISCAN_FILES_SUPPORTED 192 fprintf(stderr,
" -scans file Create multi-scan JPEG per script file\n");
200 int last_file_arg_seen,
boolean for_real)
215 boolean simple_progressive;
216 char * qtablefile = NULL;
217 char * qslotsarg = NULL;
218 char * samplearg = NULL;
219 char * scansarg = NULL;
226 q_scale_factor = 100;
228 simple_progressive =
FALSE;
231 cinfo->err->trace_level = 0;
235 for (argn = 1; argn < argc; argn++) {
239 if (argn <= last_file_arg_seen) {
249 #ifdef C_ARITH_CODING_SUPPORTED 250 cinfo->arith_code =
TRUE;
252 fprintf(stderr,
"%s: sorry, arithmetic coding not supported\n",
265 if (
keymatch(argv[argn],
"int", 1)) {
267 }
else if (
keymatch(argv[argn],
"fast", 2)) {
269 }
else if (
keymatch(argv[argn],
"float", 2)) {
277 static boolean printed_version =
FALSE;
279 if (! printed_version) {
280 fprintf(stderr,
"Independent JPEG Group's CJPEG, version %s\n%s\n",
282 printed_version =
TRUE;
284 cinfo->err->trace_level++;
297 if (sscanf(argv[argn],
"%ld%c", &lval, &ch) < 1)
299 if (ch ==
'm' || ch ==
'M')
301 cinfo->mem->max_memory_to_use = lval * 1000L;
305 #ifdef ENTROPY_OPT_SUPPORTED 306 cinfo->optimize_coding =
TRUE;
308 fprintf(stderr,
"%s: sorry, entropy optimization was not compiled\n",
321 #ifdef C_PROGRESSIVE_SUPPORTED 322 simple_progressive =
TRUE;
325 fprintf(stderr,
"%s: sorry, progressive output was not compiled\n",
334 if (sscanf(argv[argn],
"%d", &
quality) != 1)
343 qslotsarg = argv[argn];
353 qtablefile = argv[argn];
363 if (sscanf(argv[argn],
"%ld%c", &lval, &ch) < 1)
365 if (lval < 0 || lval > 65535L)
367 if (ch ==
'b' || ch ==
'B') {
368 cinfo->restart_interval = (
unsigned int) lval;
369 cinfo->restart_in_rows = 0;
371 cinfo->restart_in_rows = (
int) lval;
379 samplearg = argv[argn];
387 #ifdef C_MULTISCAN_FILES_SUPPORTED 390 scansarg = argv[argn];
393 fprintf(stderr,
"%s: sorry, multi-scan output was not compiled\n",
404 if (sscanf(argv[argn],
"%d", &val) != 1)
406 if (val < 0 || val > 100)
408 cinfo->smoothing_factor =
val;
427 if (qtablefile != NULL)
432 if (qslotsarg != NULL)
436 if (samplearg != NULL)
440 #ifdef C_PROGRESSIVE_SUPPORTED 441 if (simple_progressive)
445 #ifdef C_MULTISCAN_FILES_SUPPORTED 446 if (scansarg != NULL)
465 #ifdef PROGRESS_REPORT 476 argc = ccommand(&argv);
492 #ifdef NEED_SIGNAL_CATCHER 502 cinfo.in_color_space =
JCS_RGB;
513 #ifdef TWO_FILE_COMMANDLINE 516 if (file_index != argc-2) {
517 fprintf(stderr,
"%s: must name one input and one output file\n",
523 if (file_index != argc-1) {
524 fprintf(stderr,
"%s: must name one input and one output file\n",
531 if (file_index < argc-1) {
532 fprintf(stderr,
"%s: only one input file\n",
progname);
538 if (file_index < argc) {
539 if ((input_file = fopen(argv[file_index],
READ_BINARY)) == NULL) {
540 fprintf(stderr,
"%s: can't open %s\n",
progname, argv[file_index]);
559 #ifdef PROGRESS_REPORT 560 start_progress_monitor((
j_common_ptr) &cinfo, &progress);
568 (*src_mgr->start_input) (&cinfo, src_mgr);
583 while (cinfo.next_scanline < cinfo.image_height) {
584 num_scanlines = (*src_mgr->get_pixel_rows) (&cinfo, src_mgr);
589 (*src_mgr->finish_input) (&cinfo, src_mgr);
594 if (input_file != stdin)
596 if (output_file != stdout)
599 #ifdef PROGRESS_REPORT char int boolean force_baseline
jpeg_default_colorspace(j_compress_ptr cinfo)
jpeg_finish_compress(j_compress_ptr cinfo)
static char * outfilename
jpeg_destroy_compress(j_compress_ptr cinfo)
read_quant_tables(j_compress_ptr cinfo, char *filename, int scale_factor, boolean force_baseline)
const char *const * addon_message_table
#define ERREXIT(cinfo, code)
jpeg_stdio_dest(j_compress_ptr cinfo, FILE *outfile)
jinit_read_bmp(j_compress_ptr cinfo)
jpeg_start_compress(j_compress_ptr cinfo, boolean write_all_tables)
static const char * progname
select_file_type(j_compress_ptr cinfo, FILE *infile)
jinit_read_targa(j_compress_ptr cinfo)
parse_switches(j_compress_ptr cinfo, int argc, char **argv, int last_file_arg_seen, boolean for_real)
set_sample_factors(j_compress_ptr cinfo, char *arg)
jinit_read_gif(j_compress_ptr cinfo)
keymatch(char *arg, const char *keyword, int minchars)
typedef void(PNGAPI *png_error_ptr) PNGARG((png_structp
jpeg_write_scanlines(j_compress_ptr cinfo, JSAMPARRAY scanlines, JDIMENSION num_lines)
static const char *const cdjpeg_message_table[]
read_scan_script(j_compress_ptr cinfo, char *filename)
jpeg_simple_progression(j_compress_ptr cinfo)
int main(int argc, char **argv)
jpeg_set_colorspace(j_compress_ptr cinfo, J_COLOR_SPACE colorspace)
jinit_read_ppm(j_compress_ptr cinfo)
#define jpeg_create_compress(cinfo)
set_quant_slots(j_compress_ptr cinfo, char *arg)
jpeg_set_defaults(j_compress_ptr cinfo)
jpeg_std_error(struct jpeg_error_mgr *err)
jpeg_quality_scaling(int quality)
jpeg_set_quality(j_compress_ptr cinfo, int quality, boolean force_baseline)