43#define JMESSAGE(code,string) string ,
87 return jinit_read_targa(cinfo);
89 ERREXIT(cinfo, JERR_TGA_NOTCOMP);
94 ERREXIT(cinfo, JERR_INPUT_EMPTY);
96 ERREXIT(cinfo, JERR_UNGETC_FAILED);
101 return jinit_read_bmp(cinfo);
105 return jinit_read_gif(cinfo);
109 return jinit_read_ppm(cinfo);
113 return jinit_read_rle(cinfo);
115#ifdef TARGA_SUPPORTED
117 return jinit_read_targa(cinfo);
120 ERREXIT(cinfo, JERR_UNKNOWN_FORMAT);
146#ifdef TWO_FILE_COMMANDLINE
153 fprintf(
stderr,
" -quality N[,...] Compression quality (0..100; 5-95 is useful range)\n");
154 fprintf(
stderr,
" -grayscale Create monochrome JPEG file\n");
156#ifdef ENTROPY_OPT_SUPPORTED
157 fprintf(
stderr,
" -optimize Optimize Huffman table (smaller file, but slow compression)\n");
159#ifdef C_PROGRESSIVE_SUPPORTED
160 fprintf(
stderr,
" -progressive Create progressive JPEG file\n");
162#ifdef DCT_SCALING_SUPPORTED
163 fprintf(
stderr,
" -scale M/N Scale image by fraction M/N, eg, 1/2\n");
165#ifdef TARGA_SUPPORTED
166 fprintf(
stderr,
" -targa Input file is Targa format (usually not needed)\n");
169#ifdef C_ARITH_CODING_SUPPORTED
172#ifdef DCT_SCALING_SUPPORTED
173 fprintf(
stderr,
" -block N DCT block size (1..16; default is 8)\n");
175#if JPEG_LIB_VERSION_MAJOR >= 9
176 fprintf(
stderr,
" -rgb1 Create RGB JPEG file with reversible color transform\n");
179#ifdef DCT_ISLOW_SUPPORTED
183#ifdef DCT_IFAST_SUPPORTED
184 fprintf(
stderr,
" -dct fast Use fast integer DCT (less accurate)%s\n",
187#ifdef DCT_FLOAT_SUPPORTED
188 fprintf(
stderr,
" -dct float Use floating-point DCT method%s\n",
191 fprintf(
stderr,
" -nosmooth Don't use high-quality downsampling\n");
192 fprintf(
stderr,
" -restart N Set restart interval in rows, or in blocks with B\n");
193#ifdef INPUT_SMOOTHING_SUPPORTED
194 fprintf(
stderr,
" -smooth N Smooth dithered input (N=1..100 is strength)\n");
196 fprintf(
stderr,
" -maxmemory N Maximum memory to use (in kbytes)\n");
197 fprintf(
stderr,
" -outfile name Specify name for output file\n");
200 fprintf(
stderr,
" -baseline Force baseline quantization tables\n");
201 fprintf(
stderr,
" -qtables file Use quantization tables given in file\n");
202 fprintf(
stderr,
" -qslots N[,...] Set component quantization tables\n");
203 fprintf(
stderr,
" -sample HxV[,...] Set component sampling factors\n");
204#ifdef C_MULTISCAN_FILES_SUPPORTED
205 fprintf(
stderr,
" -scans file Create multi-scan JPEG per script file\n");
213 int last_file_arg_seen,
boolean for_real)
226 boolean simple_progressive;
227 char * qualityarg =
NULL;
228 char * qtablefile =
NULL;
229 char * qslotsarg =
NULL;
230 char * samplearg =
NULL;
231 char * scansarg =
NULL;
236 simple_progressive =
FALSE;
239 cinfo->err->trace_level = 0;
243 for (argn = 1; argn <
argc; argn++) {
247 if (argn <= last_file_arg_seen) {
257#ifdef C_ARITH_CODING_SUPPORTED
258 cinfo->arith_code =
TRUE;
260 fprintf(
stderr,
"%s: sorry, arithmetic coding not supported\n",
271#if defined DCT_SCALING_SUPPORTED && JPEG_LIB_VERSION_MAJOR >= 8 && \
272 (JPEG_LIB_VERSION_MAJOR > 8 || JPEG_LIB_VERSION_MINOR >= 3)
279 if (val < 1 || val > 16)
281 cinfo->block_size =
val;
283 fprintf(
stderr,
"%s: sorry, block size setting not supported\n",
304 static boolean printed_version =
FALSE;
306 if (! printed_version) {
307 fprintf(
stderr,
"Independent JPEG Group's CJPEG, version %s\n%s\n",
309 printed_version =
TRUE;
311 cinfo->err->trace_level++;
319#if JPEG_LIB_VERSION_MAJOR >= 9
329#if JPEG_LIB_VERSION_MAJOR >= 9 && \
330 (JPEG_LIB_VERSION_MAJOR > 9 || JPEG_LIB_VERSION_MINOR >= 1)
333 fprintf(
stderr,
"%s: sorry, BG_YCC colorspace not supported\n",
345 if (
sscanf(
argv[argn],
"%ld%c", &lval, &ch) < 1)
347 if (ch ==
'm' || ch ==
'M')
349 cinfo->mem->max_memory_to_use = lval * 1000L;
353 cinfo->do_fancy_downsampling =
FALSE;
357#ifdef ENTROPY_OPT_SUPPORTED
358 cinfo->optimize_coding =
TRUE;
360 fprintf(
stderr,
"%s: sorry, entropy optimization was not compiled\n",
373#ifdef C_PROGRESSIVE_SUPPORTED
374 simple_progressive =
TRUE;
377 fprintf(
stderr,
"%s: sorry, progressive output was not compiled\n",
386 qualityarg =
argv[argn];
392 qslotsarg =
argv[argn];
402 qtablefile =
argv[argn];
412 if (
sscanf(
argv[argn],
"%ld%c", &lval, &ch) < 1)
414 if (lval < 0 || lval > 65535L)
416 if (ch ==
'b' || ch ==
'B') {
417 cinfo->restart_interval = (
unsigned int) lval;
418 cinfo->restart_in_rows = 0;
420 cinfo->restart_in_rows = (
int) lval;
428 samplearg =
argv[argn];
439 &cinfo->scale_num, &cinfo->scale_denom) != 2)
444#ifdef C_MULTISCAN_FILES_SUPPORTED
447 scansarg =
argv[argn];
450 fprintf(
stderr,
"%s: sorry, multi-scan output was not compiled\n",
463 if (val < 0 || val > 100)
465 cinfo->smoothing_factor =
val;
482 if (qualityarg !=
NULL)
486 if (qtablefile !=
NULL)
490 if (qslotsarg !=
NULL)
494 if (samplearg !=
NULL)
498#ifdef C_PROGRESSIVE_SUPPORTED
499 if (simple_progressive)
500 jpeg_simple_progression(cinfo);
503#ifdef C_MULTISCAN_FILES_SUPPORTED
504 if (scansarg !=
NULL)
505 if (! read_scan_script(cinfo, scansarg))
523#ifdef PROGRESS_REPORT
550#ifdef NEED_SIGNAL_CATCHER
571#ifdef TWO_FILE_COMMANDLINE
574 if (file_index !=
argc-2) {
575 fprintf(
stderr,
"%s: must name one input and one output file\n",
581 if (file_index !=
argc-1) {
582 fprintf(
stderr,
"%s: must name one input and one output file\n",
589 if (file_index <
argc-1) {
596 if (file_index <
argc) {
617#ifdef PROGRESS_REPORT
626 (*src_mgr->start_input) (&cinfo, src_mgr);
642 num_scanlines = (*src_mgr->get_pixel_rows) (&cinfo, src_mgr);
647 (*src_mgr->finish_input) (&cinfo, src_mgr);
652 if (input_file !=
stdin)
654 if (output_file !=
stdout)
657#ifdef PROGRESS_REPORT
keymatch(char *arg, const char *keyword, int minchars)
char boolean force_baseline
parse_switches(j_compress_ptr cinfo, int argc, char **argv, int last_file_arg_seen, boolean for_real)
static const char *const cdjpeg_message_table[]
static char * outfilename
select_file_type(j_compress_ptr cinfo, FILE *infile)
static const char * progname
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
GLsizeiptr const GLvoid GLenum usage
_Check_return_ _CRTIMP int __cdecl getc(_Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP_ALT int __cdecl ungetc(_In_ int _Ch, _Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
jpeg_destroy_compress(j_compress_ptr cinfo)
jpeg_finish_compress(j_compress_ptr cinfo)
jpeg_write_scanlines(j_compress_ptr cinfo, JSAMPARRAY scanlines, JDIMENSION num_lines)
jpeg_start_compress(j_compress_ptr cinfo, boolean write_all_tables)
jpeg_set_colorspace(j_compress_ptr cinfo, J_COLOR_SPACE colorspace)
jpeg_set_defaults(j_compress_ptr cinfo)
jpeg_default_colorspace(j_compress_ptr cinfo)
jpeg_stdio_dest(j_compress_ptr cinfo, FILE *outfile)
jpeg_std_error(struct jpeg_error_mgr *err)
#define jpeg_create_compress(cinfo)
set_quality_ratings(j_compress_ptr cinfo, char *arg, boolean force_baseline)
read_quant_tables(j_compress_ptr cinfo, char *filename, boolean force_baseline)
set_sample_factors(j_compress_ptr cinfo, char *arg)
set_quant_slots(j_compress_ptr cinfo, char *arg)
J_COLOR_SPACE in_color_space
const char *const * addon_message_table