DrKLO/Telegram · error
%s: sorry, entropy optimization was not compiled
Error message
%s: sorry, entropy optimization was not compiled
What it means
The -optimize (or -optimise) flag was passed but the build lacks ENTROPY_OPT_SUPPORTED, the compile-time feature enabling Huffman table optimization. jpegtran exits with failure at parse time; no processing occurs.
Source
Thrown at TMessagesProj/jni/mozjpeg/jpegtran.c:290
} else if (keymatch(arg, "maxmemory", 3)) {
/* Maximum memory in Kb (or Mb with 'm'). */
long lval;
char ch = 'x';
if (++argn >= argc) /* advance to next argument */
usage();
if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1)
usage();
if (ch == 'm' || ch == 'M')
lval *= 1000L;
cinfo->mem->max_memory_to_use = lval * 1000L;
} else if (keymatch(arg, "optimize", 1) || keymatch(arg, "optimise", 1)) {
/* Enable entropy parm optimization. */
#ifdef ENTROPY_OPT_SUPPORTED
cinfo->optimize_coding = TRUE;
#else
fprintf(stderr, "%s: sorry, entropy optimization was not compiled\n",
progname);
exit(EXIT_FAILURE);
#endif
} else if (keymatch(arg, "outfile", 4)) {
/* Set output file name. */
if (++argn >= argc) /* advance to next argument */
usage();
outfilename = argv[argn]; /* save it away for later use */
} else if (keymatch(arg, "perfect", 2)) {
/* Fail if there is any partial edge MCUs that the transform can't
* handle. */
transformoption.perfect = TRUE;
} else if (keymatch(arg, "progressive", 2)) {
/* Select simple progressive mode. */
#ifdef C_PROGRESSIVE_SUPPORTEDView on GitHub (pinned to 45ab8f4308)
Solutions
- Drop the -optimize flag and rely on default coding.
- Rebuild with ENTROPY_OPT_SUPPORTED defined (standard in libjpeg-turbo/mozjpeg; verify the CMake option).
- Probe for the feature at build time and disable the flag conditionally.
- Use mozjpeg, which enables optimization by default, instead of stripped libjpeg.
Example fix
# before ./jpegtran -optimize in.jpg > out.jpg # after: drop the flag or rebuild ./jpegtran in.jpg > out.jpg # or rebuild mozjpeg with ENTROPY_OPT_SUPPORTED
Defensive patterns
Strategy: type-guard
Type guard
#ifndef ENTROPY_OPT_SUPPORTED #error "entropy optimization unavailable; do not pass -optimize" #endif
Prevention
- Guard -optimize behind a feature probe.
- Prefer mozjpeg, which optimizes by default.
- Drop the flag on stripped builds.
When it happens
Trigger: Invoking jpegtran -optimize on a libjpeg/mozjpeg build compiled without entropy optimization support. The flag is recognized but its handler is in the #else branch.
Common situations: Ultra-minimal decode-oriented builds, older embedded libjpeg variants, or a misconfigured CMake build that set -DWITH_ENTROPY_OPT=0 (if exposed). Command copied from documentation that assumes the feature is present.
Related errors
- %s: sorry, image transformation was not compiled
- %s: sorry, arithmetic coding not supported
- %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/7d1a21c09f983d3c.
Report an issue: GitHub.