DrKLO/Telegram · error
%s: sorry, entropy optimization was not compiled in
Error message
%s: sorry, entropy optimization was not compiled in
What it means
cjpeg was built without entropy-optimization support (ENTROPY_OPT_SUPPORTED undefined). The -optimize/-optimise switch (which enables optimal Huffman table generation) is therefore unavailable; cjpeg prints this message and exits with EXIT_FAILURE. Most standard libjpeg/mozjpeg builds DO define ENTROPY_OPT_SUPPORTED, so hitting this means a deliberately stripped build.
Source
Thrown at TMessagesProj/jni/mozjpeg/cjpeg.c:414
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, "dc-scan-opt", 3)) {
if (++argn >= argc) { /* advance to next argument */
fprintf(stderr, "%s: missing argument for dc-scan-opt\n", progname);
usage();
}
jpeg_c_set_int_param(cinfo, JINT_DC_SCAN_OPT_MODE, atoi(argv[argn]));
} 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 in\n",
progname);
exit(EXIT_FAILURE);
#endif
} else if (keymatch(arg, "outfile", 4)) {
/* Set output file name. */
if (++argn >= argc) { /* advance to next argument */
fprintf(stderr, "%s: missing argument for outfile\n", progname);
usage();
}
outfilename = argv[argn]; /* save it away for later use */
} else if (keymatch(arg, "progressive", 1)) {
/* Select simple progressive mode. */
#ifdef C_PROGRESSIVE_SUPPORTED
simple_progressive = TRUE;
/* We must postpone execution until num_components is known. */
#elseView on GitHub (pinned to 45ab8f4308)
Solutions
- Drop -optimize (default tables will be used).
- Rebuild libjpeg/mozjpeg with ENTROPY_OPT_SUPPORTED defined if optimized coding is required.
Example fix
# before cjpeg -optimize -quality 80 in.ppm > out.jpg # after cjpeg -quality 80 in.ppm > out.jpg
Defensive patterns
Strategy: fallback
Validate before calling
# Probe entropy-optimization support before relying on -optimize. if cjpeg -h 2>&1 | grep -q optimize; then OPT=-optimize else OPT= # fall back to default tables fi cjpeg $OPT -quality 80 in.ppm > out.jpg
Prevention
- Do not assume -optimize is always compiled in.
- Rebuild with ENTROPY_OPT_SUPPORTED if optimized Huffman tables are required.
When it happens
Trigger: Invoking `cjpeg -optimize ...` against a mozjpeg/libjpeg build compiled without ENTROPY_OPT_SUPPORTED.
Common situations: A minimal/embedded libjpeg build that disabled entropy optimization to reduce code size; a stripped vendor build.
Related errors
- %s: sorry, arithmetic coding not supported
- %s: sorry, progressive output was not compiled in
- %s: sorry, in-memory destination manager was not compiled in
- %s: missing argument for dct
- %s: invalid argument for dct
AI-assisted analysis of DrKLO/Telegram@45ab8f4308 (2026-08-14).
Data as JSON: /api/errors/434ec3f61dc2899b.
Report an issue: GitHub.