DrKLO/Telegram · error

%s: sorry, in-memory source manager was not compiled in

Error message

%s: sorry, in-memory source manager was not compiled in

What it means

djpeg emits this when the -memsrc switch is supplied but the build does not support an in-memory JPEG source manager: JPEG_LIB_VERSION is below 80 AND MEM_SRCDST_SUPPORTED is not defined. The switch is recognized, this message prints, and the process exits with EXIT_FAILURE. It is a build/version configuration mismatch.

Source

Thrown at TMessagesProj/jni/mozjpeg/djpeg.c:377

      /* Use fast one-pass quantization. */
      cinfo->two_pass_quantize = FALSE;

    } else if (keymatch(arg, "os2", 3)) {
      /* BMP output format (OS/2 flavor). */
      requested_fmt = FMT_OS2;

    } 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, "memsrc", 2)) {
      /* Use in-memory source manager */
#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
      memsrc = TRUE;
#else
      fprintf(stderr, "%s: sorry, in-memory source manager was not compiled in\n",
              progname);
      exit(EXIT_FAILURE);
#endif

    } else if (keymatch(arg, "pnm", 1) || keymatch(arg, "ppm", 1)) {
      /* PPM/PGM output format. */
      requested_fmt = FMT_PPM;

    } else if (keymatch(arg, "rle", 1)) {
      /* RLE output format. */
      requested_fmt = FMT_RLE;

    } else if (keymatch(arg, "scale", 2)) {
      /* Scale the output image by a fraction M/N. */
      if (++argn >= argc)       /* advance to next argument */
        usage();
      if (sscanf(argv[argn], "%u/%u",
                 &cinfo->scale_num, &cinfo->scale_denom) != 2)

View on GitHub (pinned to 45ab8f4308)

Solutions

  1. Recompile with JPEG_LIB_VERSION >= 80 or with MEM_SRCDST_SUPPORTED defined (libjpeg-turbo and mozjpeg enable this by default).
  2. If you cannot rebuild, stop using -memsrc and read the JPEG from a regular file or stdin instead.
  3. Verify the rebuilt binary supports it: djpeg -memsrc on a test input should no longer exit with this message.

Example fix

# before
djpeg -memsrc in.jpg > out.ppm
# after (rebuild with MEM_SRCDST_SUPPORTED, then)
djpeg -memsrc in.jpg > out.ppm
# or, if you cannot rebuild, use a file/stdin:
djpeg in.jpg > out.ppm
Defensive patterns

Strategy: validation

Validate before calling

#!/bin/sh
# Probe whether this djpeg build supports -memsrc
if printf '' | djpeg -memsrc 2>&1 | grep -q 'in-memory source manager was not compiled in'; then
  echo 'this djpeg lacks -memsrc support; rebuild or use file/stdin' >&2; exit 1
fi
djpeg -memsrc in.jpg > out.ppm

Type guard

// n/a: build-capability probe in the caller.

Try / catch

if ! djpeg -memsrc in.jpg > out.ppm 2>/tmp/e; then
  grep -q 'in-memory source manager was not compiled in' /tmp/e && { echo 'rebuild with MEM_SRCDST_SUPPORTED or JPEG_LIB_VERSION>=80' >&2; exit 1; }
fi

Prevention

When it happens

Trigger: Running djpeg with -memsrc on a libjpeg/mozjpeg build older than v80 that was not compiled with MEM_SRCDST_SUPPORTED.

Common situations: Using an older distro libjpeg (pre-8.0) or a minimal build that omitted the memory source/dst optional feature; expecting turbo/mozjpeg features on a vanilla libjpeg build.

Related errors


AI-assisted analysis of DrKLO/Telegram@45ab8f4308 (2026-08-14). Data as JSON: /api/errors/c9edbbc9413e1f51. Report an issue: GitHub.