DrKLO/Telegram · error

%s: missing argument for quality

Error message

%s: missing argument for quality

What it means

The -quality switch requires a following argument (a quality rating / scaling factor string). cjpeg finds no token after -quality, prints this message, and calls usage() which exits. The value is saved in qualityarg and parsed later by set_quality_ratings.

Source

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

      fprintf(stderr, "%s: sorry, progressive output was not compiled in\n",
              progname);
      exit(EXIT_FAILURE);
#endif

    } else if (keymatch(arg, "memdst", 2)) {
      /* Use in-memory destination manager */
#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
      memdst = TRUE;
#else
      fprintf(stderr, "%s: sorry, in-memory destination manager was not compiled in\n",
              progname);
      exit(EXIT_FAILURE);
#endif

    } else if (keymatch(arg, "quality", 1)) {
      /* Quality ratings (quantization table scaling factors). */
      if (++argn >= argc) {      /* advance to next argument */
        fprintf(stderr, "%s: missing argument for quality\n", progname);
        usage();
      }
      qualityarg = argv[argn];

    } else if (keymatch(arg, "qslots", 2)) {
      /* Quantization table slot numbers. */
      if (++argn >= argc)       /* advance to next argument */
        usage();
      qslotsarg = argv[argn];
      /* Must delay setting qslots until after we have processed any
       * colorspace-determining switches, since jpeg_set_colorspace sets
       * default quant table numbers.
       */

    } else if (keymatch(arg, "qtables", 2)) {
      /* Quantization tables fetched from file. */
      if (++argn >= argc)       /* advance to next argument */
        usage();

View on GitHub (pinned to 45ab8f4308)

Solutions

  1. Supply a quality value, e.g. `cjpeg -quality 80 in.ppm > out.jpg`.
  2. Ensure the variable expanding to the quality string is non-empty.

Example fix

# before
cjpeg -quality in.ppm > out.jpg

# after
cjpeg -quality 80 in.ppm > out.jpg
Defensive patterns

Strategy: validation

Validate before calling

# Ensure -quality has a non-empty numeric value.
case "$QUALITY" in ''|*[!0-9]*) QUALITY=80 ;; esac
cjpeg -quality "$QUALITY" in.ppm > out.jpg

Prevention

When it happens

Trigger: Running `cjpeg -quality` with no value following, or as the last token.

Common situations: Truncated command line; an empty shell variable for the quality value; scripts that append -quality unconditionally.

Related errors


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