DrKLO/Telegram · info

2. Image size (e.g. '512x512')\n

Error message

2. Image size (e.g. '512x512')\n

What it means

Second descriptive line of yuvjpeg's usage block: `2. Image size (e.g. '512x512')`. Documents argument #2 (luma dimensions in WxH form). Printed only on the argc != 5 error path alongside 191/192/194.

Source

Thrown at TMessagesProj/jni/mozjpeg/yuvjpeg.c:119

  const char *yuv_path;
  const char *jpg_path;
  FILE *yuv_fd;
  size_t yuv_size;
  unsigned char *yuv_buffer;
  JSAMPLE *jpg_buffer;
  struct jpeg_compress_struct cinfo;
  struct jpeg_error_mgr jerr;
  FILE *jpg_fd;
  JSAMPROW yrow_pointer[16];
  JSAMPROW cbrow_pointer[8];
  JSAMPROW crrow_pointer[8];
  JSAMPROW *plane_pointer[3];
  int y;

  if (argc != 5) {
    fprintf(stderr, "Required arguments:\n");
    fprintf(stderr, "1. JPEG quality value, 0-100\n");
    fprintf(stderr, "2. Image size (e.g. '512x512')\n");
    fprintf(stderr, "3. Path to YUV input file\n");
    fprintf(stderr, "4. Path to JPG output file\n");
    return 1;
  }

  errno = 0;

  quality = strtol(argv[1], NULL, 10);
  if (errno != 0 || quality < 0 || quality > 100) {
    fprintf(stderr, "Invalid JPEG quality value!\n");
    return 1;
  }

  matches = sscanf(argv[2], "%dx%d", &luma_width, &luma_height);
  if (matches != 2) {
    fprintf(stderr, "Invalid image size input!\n");
    return 1;
  }

View on GitHub (pinned to 45ab8f4308)

Solutions

  1. Pass image size as a single WxH token, e.g. 512x512.
  2. Ensure width and height match the actual YUV frame dimensions.
  3. Validate the size token matches the regex ^[0-9]+x[0-9]+$ before invoking.
Defensive patterns

Strategy: validation

Validate before calling

#include <regex.h>
/* size must be WxH before invoking yuvjpeg */
regex_t re; regcomp(&re, "^[0-9]+x[0-9]+$", REG_EXTENDED);
if (regexec(&re, size_arg, 0, NULL, 0) != 0) { /* reject */ }

Prevention

When it happens

Trigger: Same trigger as 191: yuvjpeg invoked with argc != 5.

Common situations: Confusing the size format; this line specifies the expected `WxH` syntax (no 'x' variants, no spaces).

Related errors


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