35 static const char * progname;
36 static char * outfilename;
43 fprintf(stderr,
"usage: %s [switches] ", progname);
44 #ifdef TWO_FILE_COMMANDLINE
45 fprintf(stderr,
"inputfile outputfile\n");
47 fprintf(stderr,
"[inputfile]\n");
50 fprintf(stderr,
"Switches (names may be abbreviated):\n");
51 #ifdef ENTROPY_OPT_SUPPORTED
52 fprintf(stderr,
" -optimize Optimize Huffman table (smaller file, but slow compression)\n");
54 #ifdef C_PROGRESSIVE_SUPPORTED
55 fprintf(stderr,
" -progressive Create progressive JPEG file\n");
57 fprintf(stderr,
"Switches for advanced users:\n");
58 fprintf(stderr,
" -restart N Set restart interval in rows, or in blocks with B\n");
59 fprintf(stderr,
" -maxmemory N Maximum memory to use (in kbytes)\n");
60 fprintf(stderr,
" -outfile name Specify name for output file\n");
61 fprintf(stderr,
" -verbose or -debug Emit debug output\n");
62 fprintf(stderr,
"Switches for wizards:\n");
63 #ifdef C_ARITH_CODING_SUPPORTED
64 fprintf(stderr,
" -arithmetic Use arithmetic coding\n");
66 #ifdef C_MULTISCAN_FILES_SUPPORTED
67 fprintf(stderr,
" -scans file Create multi-scan JPEG per script file\n");
75 int last_file_arg_seen,
boolean for_real)
87 boolean simple_progressive;
88 char * scansarg =
NULL;
91 simple_progressive =
FALSE;
93 cinfo->err->trace_level = 0;
97 for (argn = 1; argn < argc; argn++) {
101 if (argn <= last_file_arg_seen) {
109 if (keymatch(arg,
"arithmetic", 1)) {
111 #ifdef C_ARITH_CODING_SUPPORTED
114 fprintf(stderr,
"%s: sorry, arithmetic coding not supported\n",
119 }
else if (keymatch(arg,
"debug", 1) || keymatch(arg,
"verbose", 1)) {
122 static boolean printed_version =
FALSE;
124 if (! printed_version) {
125 fprintf(stderr,
"Independent JPEG Group's JPEGTRAN, version %s\n%s\n",
127 printed_version =
TRUE;
129 cinfo->err->trace_level++;
131 }
else if (keymatch(arg,
"maxmemory", 3)) {
138 if (sscanf(argv[argn],
"%ld%c", &lval, &ch) < 1)
140 if (ch ==
'm' || ch ==
'M')
142 cinfo->mem->max_memory_to_use = lval * 1000
L;
144 }
else if (keymatch(arg,
"optimize", 1) || keymatch(arg,
"optimise", 1)) {
146 #ifdef ENTROPY_OPT_SUPPORTED
149 fprintf(stderr,
"%s: sorry, entropy optimization was not compiled\n",
154 }
else if (keymatch(arg,
"outfile", 4)) {
158 outfilename = argv[argn];
160 }
else if (keymatch(arg,
"progressive", 1)) {
162 #ifdef C_PROGRESSIVE_SUPPORTED
163 simple_progressive =
TRUE;
166 fprintf(stderr,
"%s: sorry, progressive output was not compiled\n",
171 }
else if (keymatch(arg,
"restart", 1)) {
178 if (sscanf(argv[argn],
"%ld%c", &lval, &ch) < 1)
180 if (lval < 0 || lval > 65535
L)
182 if (ch ==
'b' || ch ==
'B') {
190 }
else if (keymatch(arg,
"scans", 2)) {
192 #ifdef C_MULTISCAN_FILES_SUPPORTED
195 scansarg = argv[argn];
198 fprintf(stderr,
"%s: sorry, multi-scan output was not compiled\n",
212 #ifdef C_PROGRESSIVE_SUPPORTED
213 if (simple_progressive)
217 #ifdef C_MULTISCAN_FILES_SUPPORTED
218 if (scansarg !=
NULL)
219 if (! read_scan_script(cinfo, scansarg))
238 #ifdef PROGRESS_REPORT
239 struct cdjpeg_progress_mgr progress;
248 argc = ccommand(&argv);
252 if (progname ==
NULL || progname[0] == 0)
253 progname =
"jpegtran";
265 #ifdef NEED_SIGNAL_CATCHER
278 #ifdef TWO_FILE_COMMANDLINE
280 if (outfilename ==
NULL) {
281 if (file_index != argc-2) {
282 fprintf(stderr,
"%s: must name one input and one output file\n",
286 outfilename = argv[file_index+1];
288 if (file_index != argc-1) {
289 fprintf(stderr,
"%s: must name one input and one output file\n",
296 if (file_index < argc-1) {
297 fprintf(stderr,
"%s: only one input file\n", progname);
303 if (file_index < argc) {
305 fprintf(stderr,
"%s: can't open %s\n", progname, argv[file_index]);
310 input_file = read_stdin();
314 if (outfilename !=
NULL) {
315 if ((output_file = fopen(outfilename, WRITE_BINARY)) ==
NULL) {
316 fprintf(stderr,
"%s: can't open %s\n", progname, outfilename);
321 output_file = write_stdout();
324 #ifdef PROGRESS_REPORT
325 start_progress_monitor((
j_common_ptr) &dstinfo, &progress);
358 if (input_file != stdin)
360 if (output_file != stdout)
363 #ifdef PROGRESS_REPORT
GLOBAL void jpeg_stdio_dest(j_compress_ptr cinfo, FILE *outfile)
GLOBAL int main(int argc, char **argv)
GLOBAL void jpeg_create_decompress(j_decompress_ptr cinfo)
GLOBAL void jpeg_finish_compress(j_compress_ptr cinfo)
unsigned int restart_interval
GLOBAL boolean jpeg_finish_decompress(j_decompress_ptr cinfo)
GLOBAL void jpeg_destroy_decompress(j_decompress_ptr cinfo)
GLOBAL void jpeg_create_compress(j_compress_ptr cinfo)
GLOBAL struct jpeg_error_mgr * jpeg_std_error(struct jpeg_error_mgr *err)
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
GLOBAL jvirt_barray_ptr * jpeg_read_coefficients(j_decompress_ptr cinfo)
GLOBAL void jpeg_destroy_compress(j_compress_ptr cinfo)
GLOBAL void jpeg_write_coefficients(j_compress_ptr cinfo, jvirt_barray_ptr *coef_arrays)
GLOBAL void jpeg_copy_critical_parameters(j_decompress_ptr srcinfo, j_compress_ptr dstinfo)
GLOBAL int jpeg_read_header(j_decompress_ptr cinfo, boolean require_image)
LOCAL int parse_switches(j_compress_ptr cinfo, int argc, char **argv, int last_file_arg_seen, boolean for_real)
GLOBAL void jpeg_stdio_src(j_decompress_ptr cinfo, unsigned char *infile)
GLOBAL void jpeg_simple_progression(j_compress_ptr cinfo)