38 static const char * progname;
39 static char * outfilename;
48 fprintf(stderr,
"usage: %s [switches] ", progname);
49 #ifdef TWO_FILE_COMMANDLINE 50 fprintf(stderr,
"inputfile outputfile\n");
52 fprintf(stderr,
"[inputfile]\n");
55 fprintf(stderr,
"Switches (names may be abbreviated):\n");
56 fprintf(stderr,
" -copy none Copy no extra markers from source file\n");
57 fprintf(stderr,
" -copy comments Copy only comment markers (default)\n");
58 fprintf(stderr,
" -copy all Copy all extra markers\n");
59 #ifdef ENTROPY_OPT_SUPPORTED 60 fprintf(stderr,
" -optimize Optimize Huffman table (smaller file, but slow compression)\n");
62 #ifdef C_PROGRESSIVE_SUPPORTED 63 fprintf(stderr,
" -progressive Create progressive JPEG file\n");
65 #if TRANSFORMS_SUPPORTED 66 fprintf(stderr,
"Switches for modifying the image:\n");
67 fprintf(stderr,
" -grayscale Reduce to grayscale (omit color data)\n");
68 fprintf(stderr,
" -flip [horizontal|vertical] Mirror image (left-right or top-bottom)\n");
69 fprintf(stderr,
" -rotate [90|180|270] Rotate image (degrees clockwise)\n");
70 fprintf(stderr,
" -transpose Transpose image\n");
71 fprintf(stderr,
" -transverse Transverse transpose image\n");
72 fprintf(stderr,
" -trim Drop non-transformable edge blocks\n");
74 fprintf(stderr,
"Switches for advanced users:\n");
75 fprintf(stderr,
" -restart N Set restart interval in rows, or in blocks with B\n");
76 fprintf(stderr,
" -maxmemory N Maximum memory to use (in kbytes)\n");
77 fprintf(stderr,
" -outfile name Specify name for output file\n");
78 fprintf(stderr,
" -verbose or -debug Emit debug output\n");
79 fprintf(stderr,
"Switches for wizards:\n");
80 #ifdef C_ARITH_CODING_SUPPORTED 81 fprintf(stderr,
" -arithmetic Use arithmetic coding\n");
83 #ifdef C_MULTISCAN_FILES_SUPPORTED 84 fprintf(stderr,
" -scans file Create multi-scan JPEG per script file\n");
96 #if TRANSFORMS_SUPPORTED 101 fprintf(stderr,
"%s: can only do one image transformation at a time\n",
106 fprintf(stderr,
"%s: sorry, image transformation was not compiled\n",
115 int last_file_arg_seen,
boolean for_real)
127 boolean simple_progressive;
128 char * scansarg =
NULL;
131 simple_progressive =
FALSE;
137 cinfo->err->trace_level = 0;
141 for (argn = 1; argn < argc; argn++) {
145 if (argn <= last_file_arg_seen) {
155 #ifdef C_ARITH_CODING_SUPPORTED 156 cinfo->arith_code =
TRUE;
158 fprintf(stderr,
"%s: sorry, arithmetic coding not supported\n",
167 if (
keymatch(argv[argn],
"none", 1)) {
169 }
else if (
keymatch(argv[argn],
"comments", 1)) {
171 }
else if (
keymatch(argv[argn],
"all", 1)) {
179 static boolean printed_version =
FALSE;
181 if (! printed_version) {
182 fprintf(stderr,
"Independent JPEG Group's JPEGTRAN, version %s\n%s\n",
184 printed_version =
TRUE;
186 cinfo->err->trace_level++;
192 if (
keymatch(argv[argn],
"horizontal", 1))
194 else if (
keymatch(argv[argn],
"vertical", 1))
201 #if TRANSFORMS_SUPPORTED 214 if (sscanf(argv[argn],
"%ld%c", &lval, &ch) < 1)
216 if (ch ==
'm' || ch ==
'M')
218 cinfo->mem->max_memory_to_use = lval * 1000L;
222 #ifdef ENTROPY_OPT_SUPPORTED 223 cinfo->optimize_coding =
TRUE;
225 fprintf(stderr,
"%s: sorry, entropy optimization was not compiled\n",
234 outfilename = argv[argn];
238 #ifdef C_PROGRESSIVE_SUPPORTED 239 simple_progressive =
TRUE;
242 fprintf(stderr,
"%s: sorry, progressive output was not compiled\n",
254 if (sscanf(argv[argn],
"%ld%c", &lval, &ch) < 1)
256 if (lval < 0 || lval > 65535L)
258 if (ch ==
'b' || ch ==
'B') {
259 cinfo->restart_interval = (
unsigned int) lval;
260 cinfo->restart_in_rows = 0;
262 cinfo->restart_in_rows = (
int) lval;
272 else if (
keymatch(argv[argn],
"180", 3))
274 else if (
keymatch(argv[argn],
"270", 3))
281 #ifdef C_MULTISCAN_FILES_SUPPORTED 284 scansarg = argv[argn];
287 fprintf(stderr,
"%s: sorry, multi-scan output was not compiled\n",
313 #ifdef C_PROGRESSIVE_SUPPORTED 314 if (simple_progressive)
318 #ifdef C_MULTISCAN_FILES_SUPPORTED 319 if (scansarg !=
NULL)
339 #ifdef PROGRESS_REPORT 350 argc = ccommand(&argv);
354 if (progname ==
NULL || progname[0] == 0)
355 progname =
"jpegtran";
367 #ifdef NEED_SIGNAL_CATCHER 381 srcinfo.mem->max_memory_to_use = dstinfo.mem->max_memory_to_use;
383 #ifdef TWO_FILE_COMMANDLINE 385 if (outfilename ==
NULL) {
386 if (file_index != argc-2) {
387 fprintf(stderr,
"%s: must name one input and one output file\n",
391 outfilename = argv[file_index+1];
393 if (file_index != argc-1) {
394 fprintf(stderr,
"%s: must name one input and one output file\n",
401 if (file_index < argc-1) {
402 fprintf(stderr,
"%s: only one input file\n", progname);
408 if (file_index < argc) {
410 fprintf(stderr,
"%s: can't open %s\n", progname, argv[file_index]);
419 if (outfilename !=
NULL) {
421 fprintf(stderr,
"%s: can't open %s\n", progname, outfilename);
429 #ifdef PROGRESS_REPORT 430 start_progress_monitor((
j_common_ptr) &dstinfo, &progress);
445 #if TRANSFORMS_SUPPORTED 446 jtransform_request_workspace(&srcinfo, &transformoption);
450 src_coef_arrays = jpeg_read_coefficients(&srcinfo);
458 #if TRANSFORMS_SUPPORTED 459 dst_coef_arrays = jtransform_adjust_parameters(&srcinfo, &dstinfo,
463 dst_coef_arrays = src_coef_arrays;
473 jpeg_write_coefficients(&dstinfo, dst_coef_arrays);
479 #if TRANSFORMS_SUPPORTED 480 jtransform_execute_transformation(&srcinfo, &dstinfo,
492 if (input_file != stdin)
494 if (output_file != stdout)
497 #ifdef PROGRESS_REPORT jpeg_read_header(j_decompress_ptr cinfo, boolean require_image)
jpeg_finish_compress(j_compress_ptr cinfo)
jpeg_destroy_compress(j_compress_ptr cinfo)
select_transform(JXFORM_CODE transform)
jpeg_stdio_dest(j_compress_ptr cinfo, FILE *outfile)
parse_switches(j_compress_ptr cinfo, int argc, char **argv, int last_file_arg_seen, boolean for_real)
typedef void(APIENTRY *GLDEBUGPROCARB)(GLenum source
#define jpeg_create_decompress(cinfo)
jpeg_copy_critical_parameters(j_decompress_ptr srcinfo, j_compress_ptr dstinfo)
jcopy_markers_execute(j_decompress_ptr srcinfo, j_compress_ptr dstinfo, JCOPY_OPTION option)
GLsizeiptr const GLvoid GLenum usage
keymatch(char *arg, const char *keyword, int minchars)
jpeg_stdio_src(j_decompress_ptr cinfo, FILE *infile)
jpeg_finish_decompress(j_decompress_ptr cinfo)
read_scan_script(j_compress_ptr cinfo, char *filename)
jpeg_simple_progression(j_compress_ptr cinfo)
jpeg_destroy_decompress(j_decompress_ptr cinfo)
struct jvirt_barray_control * jvirt_barray_ptr
jcopy_markers_setup(j_decompress_ptr srcinfo, JCOPY_OPTION option)
#define jpeg_create_compress(cinfo)
GLuint GLenum GLenum transform
jpeg_std_error(struct jpeg_error_mgr *err)
int main(int argc, char **argv)