DrKLO/Telegram · error
Invalid image size input!\n
Error message
Invalid image size input!\n
What it means
yuvjpeg parses argv[2] as image size using sscanf(argv[2], "%dx%d", &luma_width, &luma_height). If sscanf does not return 2 (the token does not contain an `x`-separated pair of integers), it prints `Invalid image size input!` and returns 1. This catches syntactically malformed size tokens before any dimension logic.
Source
Thrown at TMessagesProj/jni/mozjpeg/yuvjpeg.c:135
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;
}
if (luma_width <= 0 || luma_height <= 0) {
fprintf(stderr, "Invalid image size input!\n");
return 1;
}
chroma_width = (luma_width + 1) >> 1;
chroma_height = (luma_height + 1) >> 1;
/* Will check these for validity when opening via 'fopen'. */
yuv_path = argv[3];
jpg_path = argv[4];
yuv_fd = fopen(yuv_path, "r");
if (!yuv_fd) {
fprintf(stderr, "Invalid path to YUV file!\n");
return 1;View on GitHub (pinned to 45ab8f4308)
Solutions
- Format the size as lowercase `WxH` with no spaces, e.g. 512x512.
- Validate argv[2] against ^[0-9]+x[0-9]+$ before invoking.
- Normalize the separator to lowercase 'x' in the calling code.
Example fix
// before yuvjpeg 90 512X512 in.yuv out.jpg // after yuvjpeg 90 512x512 in.yuv out.jpg
Defensive patterns
Strategy: validation
Validate before calling
int w, h;
/* sscanf must yield exactly 2 ints separated by lowercase x */
if (sscanf(size_arg, "%dx%d", &w, &h) != 2) { /* reject malformed size */ } Prevention
- Use lowercase 'x' with no surrounding spaces.
- Reject uppercase X, '*', or ' x ' separators upstream.
- Validate with ^[0-9]+x[0-9]+$ before invoking.
When it happens
Trigger: Passing a size token that is not exactly `<int>x<int>`, e.g. `512`, `512X512`, `512 x 512`, `512*512`, or an empty string.
Common situations: Using uppercase X, adding spaces around the separator, using a different delimiter, or a UI that formats dimensions with a multiplication sign.
Related errors
- Unexpected input format!\n
- Required arguments:\n
- Invalid JPEG quality value!\n
- Invalid path to YUV file!\n
- %s: can't open %s
AI-assisted analysis of DrKLO/Telegram@45ab8f4308 (2026-08-14).
Data as JSON: /api/errors/2290ce6164184296.
Report an issue: GitHub.