DrKLO/Telegram · error

%s: invalid argument for dct

Error message

%s: invalid argument for dct

What it means

-dct was given a value, but it did not match any of the accepted DCT method names (int, fast, float). cjpeg prints this message and calls usage() which exits. The DCT method enum (JDCT_ISLOW / JDCT_IFAST / JDCT_FLOAT) could not be selected.

Source

Thrown at TMessagesProj/jni/mozjpeg/cjpeg.c:336

      /* Disable multiple scans */
      simple_progressive = FALSE;
      cinfo->num_scans = 0;
      cinfo->scan_info = NULL;

    } else if (keymatch(arg, "dct", 2)) {
      /* Select DCT algorithm. */
      if (++argn >= argc) {      /* advance to next argument */
        fprintf(stderr, "%s: missing argument for dct\n", progname);
        usage();
      }
      if (keymatch(argv[argn], "int", 1)) {
        cinfo->dct_method = JDCT_ISLOW;
      } else if (keymatch(argv[argn], "fast", 2)) {
        cinfo->dct_method = JDCT_IFAST;
      } else if (keymatch(argv[argn], "float", 2)) {
        cinfo->dct_method = JDCT_FLOAT;
      } else {
        fprintf(stderr, "%s: invalid argument for dct\n", progname);
        usage();
      }

    } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) {
      /* Enable debug printouts. */
      /* On first -d, print version identification */
      static boolean printed_version = FALSE;

      if (!printed_version) {
        fprintf(stderr, "%s version %s (build %s)\n",
                PACKAGE_NAME, VERSION, BUILD);
        fprintf(stderr, "%s\n\n", JCOPYRIGHT);
        fprintf(stderr, "Emulating The Independent JPEG Group's software, version %s\n\n",
                JVERSION);
        printed_version = TRUE;
      }
      cinfo->err->trace_level++;

View on GitHub (pinned to 45ab8f4308)

Solutions

  1. Use one of the accepted values: int (accurate integer), fast (less accurate integer), or float (floating point).
  2. Run `cjpeg -h` or consult usage() output to confirm valid DCT method names for your build.

Example fix

# before
cjpeg -dct slow in.ppm > out.jpg

# after
cjpeg -dct int in.ppm > out.jpg
Defensive patterns

Strategy: validation

Validate before calling

# Reject DCT method names cjpeg does not accept.
case "$DCT" in
  int|fast|float) ;;
  *) echo "invalid DCT: $DCT (need int|fast|float)" >&2; exit 2 ;;
esac
cjpeg -dct "$DCT" in.ppm > out.jpg

Prevention

When it happens

Trigger: Running e.g. `cjpeg -dct slow ...`, `cjpeg -dct ifast ...`, or any typo that does not prefix-match int/fast/float.

Common situations: Typos; assuming a method name (like 'slow' or 'default') that cjpeg does not accept; copy-pasting flags from documentation for a different JPEG tool.

Related errors


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