DrKLO/Telegram · error
%s: %d is invalid argument for quant-table
Error message
%s: %d is invalid argument for quant-table
What it means
The -quant-table switch selects a base quantization table index via jpeg_c_set_int_param(JINT_BASE_QUANT_TBL_IDX, val). cjpeg then reads it back with jpeg_c_get_int_param; if the value round-trips to something different, the index was out of range / rejected, so cjpeg prints this (with the offending integer) and calls usage() which exits.
Source
Thrown at TMessagesProj/jni/mozjpeg/cjpeg.c:480
* colorspace-determining switches, since jpeg_set_colorspace sets
* default quant table numbers.
*/
} else if (keymatch(arg, "qtables", 2)) {
/* Quantization tables fetched from file. */
if (++argn >= argc) /* advance to next argument */
usage();
qtablefile = argv[argn];
/* We postpone actually reading the file in case -quality comes later. */
} else if (keymatch(arg, "quant-table", 7)) {
int val;
if (++argn >= argc) /* advance to next argument */
usage();
val = atoi(argv[argn]);
jpeg_c_set_int_param(cinfo, JINT_BASE_QUANT_TBL_IDX, val);
if (jpeg_c_get_int_param(cinfo, JINT_BASE_QUANT_TBL_IDX) != val) {
fprintf(stderr, "%s: %d is invalid argument for quant-table\n", progname, val);
usage();
}
jpeg_set_quality(cinfo, 75, TRUE);
} else if (keymatch(arg, "quant-baseline", 7)) {
/* Force quantization table to meet baseline requirements */
force_baseline = TRUE;
} else if (keymatch(arg, "restart", 1)) {
/* Restart interval in MCU rows (or in MCUs with 'b'). */
long lval;
char ch = 'x';
if (++argn >= argc) /* advance to next argument */
usage();
if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1)
usage();
if (lval < 0 || lval > 65535L)View on GitHub (pinned to 45ab8f4308)
Solutions
- Use a valid base quantization table index (check the mozjpeg tune presets: 0, 1, 3 are referenced by -tune-psnr/-tune-ssim/-tune-ms-ssim/-tune-hvs-psnr).
- Run `cjpeg -h` or consult the mozjpeg docs to list the valid indices for your build.
Example fix
# before cjpeg -quant-table 9 in.ppm > out.jpg # after cjpeg -quant-table 1 in.ppm > out.jpg
Defensive patterns
Strategy: validation
Validate before calling
# Restrict -quant-table to indices known to this mozjpeg build. case "$QTBL" in 0|1|3) ;; *) echo "invalid quant-table: $QTBL (valid: 0,1,3)" >&2; exit 2 ;; esac cjpeg -quant-table "$QTBL" in.ppm > out.jpg
Prevention
- Use only the base quantization-table indices your mozjpeg build provides (see tune presets: 0, 1, 3).
- Verify the value round-trips via jpeg_c_get_int_param before relying on it.
When it happens
Trigger: Running e.g. `cjpeg -quant-table 9 ...` where only a small set of indices (the built-in quantization tables, typically 0..3 in mozjpeg's tune presets) are valid.
Common situations: Passing an index larger than the available base quant tables; assuming 1-based vs 0-based numbering; copy-pasting an index from a different mozjpeg version.
Related errors
- %s: missing argument for dct
- %s: invalid argument for dct
- %s: missing argument for dc-scan-opt
- %s: missing argument for outfile
- %s: missing argument for quality
AI-assisted analysis of DrKLO/Telegram@45ab8f4308 (2026-08-14).
Data as JSON: /api/errors/ec029b1631fd6c8f.
Report an issue: GitHub.