DrKLO/Telegram · error
%s: unknown option '%s'
Error message
%s: unknown option '%s'
What it means
After every recognized keymatch branch fails to match the current argument, cjpeg falls into the final else and reports the unrecognized switch, then calls usage() (which exits non-zero). This catches typos, deprecated flags, and flags that belong to djpeg rather than cjpeg.
Source
Thrown at TMessagesProj/jni/mozjpeg/cjpeg.c:605
jpeg_c_set_float_param(cinfo, JFLOAT_LAMBDA_LOG_SCALE1, 12.0);
jpeg_c_set_float_param(cinfo, JFLOAT_LAMBDA_LOG_SCALE2, 13.0);
jpeg_c_set_bool_param(cinfo, JBOOLEAN_USE_LAMBDA_WEIGHT_TBL, TRUE);
jpeg_set_quality(cinfo, 75, TRUE);
} else if (keymatch(arg, "tune-hvs-psnr", 6)) {
jpeg_c_set_int_param(cinfo, JINT_BASE_QUANT_TBL_IDX, 3);
jpeg_c_set_float_param(cinfo, JFLOAT_LAMBDA_LOG_SCALE1, 14.75);
jpeg_c_set_float_param(cinfo, JFLOAT_LAMBDA_LOG_SCALE2, 16.5);
jpeg_c_set_bool_param(cinfo, JBOOLEAN_USE_LAMBDA_WEIGHT_TBL, TRUE);
jpeg_set_quality(cinfo, 75, TRUE);
} else if (keymatch(arg, "noovershoot", 11)) {
jpeg_c_set_bool_param(cinfo, JBOOLEAN_OVERSHOOT_DERINGING, FALSE);
} else if (keymatch(arg, "nojfif", 6)) {
cinfo->write_JFIF_header = 0;
} else {
fprintf(stderr, "%s: unknown option '%s'\n", progname, arg);
usage(); /* bogus switch */
}
}
/* Post-switch-scanning cleanup */
if (for_real) {
/* Set quantization tables for selected quality. */
/* Some or all may be overridden if -qtables is present. */
if (qualityarg != NULL) /* process -quality if it was present */
if (! set_quality_ratings(cinfo, qualityarg, force_baseline)) {
fprintf(stderr, "%s: can't set quality ratings\n", progname);
usage();
}
if (qtablefile != NULL) /* process -qtables if it was present */
if (! read_quant_tables(cinfo, qtablefile, force_baseline)) {View on GitHub (pinned to 45ab8f4308)
Solutions
- Run cjpeg with no args or -h to print the full usage() list of supported switches for this exact build.
- Check the spelling and minimum prefix length required by keymatch (e.g. -quality needs at least -qua).
- Confirm the flag is valid for cjpeg specifically (not a djpeg-only or jpegtran-only option).
- If you need an option that this build lacks, rebuild mozjpeg with the relevant feature macro enabled.
Example fix
# before cjpeg -grayscale input.ppm > out.jpg # -grayscale is not a cjpeg switch # after cjpeg -grayscale input.rgb > out.jpg # verify via 'cjpeg -h'; use the documented input-type or colorspace flag instead
Defensive patterns
Strategy: validation
Validate before calling
#!/bin/sh
# Reject unknown switches before calling cjpeg
SUPPORTED='quality qtables qslots sample scans outfile icc optimize progressive'
for a in "$@"; do
case "$a" in -*)
opt=${a#-}
if ! printf '%s\n' "$SUPPORTED" | grep -qw -- "$opt"; then
echo "unknown switch: $a" >&2; exit 1
fi;; esac
done
cjpeg "$@" Type guard
// n/a: validate against the tool's documented switch set at the shell layer.
Try / catch
if ! cjpeg "$@" 2>/tmp/e; then
if grep -q 'unknown option' /tmp/e; then
cjpeg 2>&1 | sed -n '/usage/,/^$/p' # show supported switches
fi
exit 1
fi Prevention
- Canonicalize command construction from a single option-registry/map in your code.
- Run cjpeg with no args in a smoke test to capture the supported switch list for the deployed version.
- Avoid passing djpeg/ffmpeg flags to cjpeg; keep encoder/decoder arg sets separate.
When it happens
Trigger: Passing any switch that is not in cjpeg's parse_switches table (e.g. -grayscale meant for djpeg, a misspelled flag like -qualty, or a mozjpeg flag removed/renamed in this version). Note keymatch matches by minimum prefix length, so a too-short ambiguous prefix can also miss.
Common situations: Mixing up cjpeg and djpeg/ffmpeg flags; using a flag from a newer/older mozjpeg version; typos in hand-typed or templated command lines; expecting an option that exists in libjpeg-turbo but not mozjpeg or vice versa.
Related errors
- %s: missing argument for trellis-dc-ver-weight
- %s: can't set quality ratings
- %s: can't set sample factors
- %s: must name one input and one output file
- %s: only one input file
AI-assisted analysis of DrKLO/Telegram@45ab8f4308 (2026-08-14).
Data as JSON: /api/errors/7b958bb4288cc718.
Report an issue: GitHub.