DrKLO/Telegram · error
%s: sorry, arithmetic coding not supported
Error message
%s: sorry, arithmetic coding not supported
What it means
The -arithmetic flag was given to jpegtran but the encoder was built without C_ARITH_CODING_SUPPORTED. Arithmetic coding is a compile-time option in libjpeg/mozjpeg; when absent, the flag is rejected at parse time with exit(EXIT_FAILURE).
Source
Thrown at TMessagesProj/jni/mozjpeg/jpegtran.c:188
/* Not a switch, must be a file name argument */
if (argn <= last_file_arg_seen) {
outfilename = NULL; /* -outfile applies to just one input file */
continue; /* ignore this name if previously processed */
}
break; /* else done parsing switches */
}
arg++; /* advance past switch marker character */
if (keymatch(arg, "arithmetic", 1)) {
/* Use arithmetic coding. */
#ifdef C_ARITH_CODING_SUPPORTED
cinfo->arith_code = TRUE;
/* No table optimization required for AC */
cinfo->optimize_coding = FALSE;
prefer_smallest = FALSE;
#else
fprintf(stderr, "%s: sorry, arithmetic coding not supported\n",
progname);
exit(EXIT_FAILURE);
#endif
} else if (keymatch(arg, "copy", 2)) {
/* Select which extra markers to copy. */
if (++argn >= argc) /* advance to next argument */
usage();
if (keymatch(argv[argn], "none", 1)) {
copyoption = JCOPYOPT_NONE;
} else if (keymatch(argv[argn], "comments", 1)) {
copyoption = JCOPYOPT_COMMENTS;
} else if (keymatch(argv[argn], "all", 1)) {
copyoption = JCOPYOPT_ALL;
} else
usage();
} else if (keymatch(arg, "crop", 2)) {View on GitHub (pinned to 45ab8f4308)
Solutions
- Drop the -arithmetic flag and use the default Huffman coding.
- Rebuild libjpeg-turbo/mozjpeg with -DC_ARITH_CODING_SUPPORTED=1 (enable in CMake/Make config).
- Verify the feature at build time: #ifdef C_ARITH_CODING_SUPPORTED in a probe before relying on it.
- Document the build variant so callers know whether arithmetic coding is available.
Example fix
# before ./jpegtran -arithmetic in.jpg > out.jpg # after: either drop the flag ./jpegtran in.jpg > out.jpg # or rebuild: cmake -DCMAKE_C_FLAGS=-DC_ARITH_CODING_SUPPORTED=1 ...
Defensive patterns
Strategy: type-guard
Type guard
#ifndef C_ARITH_CODING_SUPPORTED #error "arithmetic coding unavailable; do not pass -arithmetic" #endif
Prevention
- Guard -arithmetic usage behind a build-time feature probe.
- Default to Huffman coding for portability across builds.
- Rebuild with C_ARITH_CODING_SUPPORTED if arithmetic is required.
When it happens
Trigger: Passing -arithmetic (or -a) to a jpegtran that was compiled with arithmetic coding disabled. Common in distributions that ship only Huffman coding for licensing or size reasons.
Common situations: Default upstream libjpeg-turbo builds historically leave arithmetic coding enabled, but custom/minified builds or older libjpeg releases omit it; copying a command from a tutorial onto such a build fails immediately.
Related errors
- %s: sorry, image transformation was not compiled
- %s: sorry, entropy optimization was not compiled
- %s: sorry, progressive output was not compiled
- %s: sorry, multi-scan output was not compiled
- %s: sorry, multi-scan output was not compiled in
AI-assisted analysis of DrKLO/Telegram@45ab8f4308 (2026-08-14).
Data as JSON: /api/errors/af3aded6b23351c2.
Report an issue: GitHub.