DrKLO/Telegram · error
Can't open scan definition file %s
Error message
Can't open scan definition file %s
What it means
The set_scan_partitions function (which reads scan definition scripts for progressive JPEG encoding) attempts to fopen the file specified by the -scans argument. If fopen returns NULL, the scan definition file does not exist or is inaccessible. The function returns FALSE. Scan files define the progression order and component grouping for progressive JPEG output.
Source
Thrown at TMessagesProj/jni/mozjpeg/rdswitch.c:196
* in the current scan. The first component has index 0.
* Sequential JPEG is used if the progressive-JPEG parameters are omitted.
* The file is free format text: any whitespace may appear between numbers
* and the ':' and ';' punctuation marks. Also, other punctuation (such
* as commas or dashes) can be placed between numbers if desired.
* Comments preceded by '#' may be included in the file.
* Note: we do very little validity checking here;
* jcmaster.c will validate the script parameters.
*/
{
FILE *fp;
int scanno, ncomps, termchar;
long val;
jpeg_scan_info *scanptr;
#define MAX_SCANS 100 /* quite arbitrary limit */
jpeg_scan_info scans[MAX_SCANS];
if ((fp = fopen(filename, "r")) == NULL) {
fprintf(stderr, "Can't open scan definition file %s\n", filename);
return FALSE;
}
scanptr = scans;
scanno = 0;
while (read_scan_integer(fp, &val, &termchar)) {
if (scanno >= MAX_SCANS) {
fprintf(stderr, "Too many scans defined in file %s\n", filename);
fclose(fp);
return FALSE;
}
scanptr->component_index[0] = (int) val;
ncomps = 1;
while (termchar == ' ') {
if (ncomps >= MAX_COMPS_IN_SCAN) {
fprintf(stderr, "Too many components in one scan in file %s\n",
filename);
fclose(fp);View on GitHub (pinned to 45ab8f4308)
Solutions
- Verify the scan definition file exists and is readable: test -f <file> and test -r <file>.
- Use an absolute path for the scan file to avoid working-directory ambiguity.
- Create the scan definition file if it does not exist, following the expected format (component indices, Ss, Se, Ah, Al values separated by spaces and colons).
Example fix
# before cjpeg -scans missing.scans image.bmp > out.jpg # after cjpeg -scans /path/to/progressive.scans image.bmp > out.jpg
Defensive patterns
Strategy: validation
Validate before calling
// In C: check file accessibility before calling the scan reader
#include <unistd.h>
if (access(filename, R_OK) != 0) {
fprintf(stderr, "Scan file %s is not readable\n", filename);
return FALSE;
}
// Then call the actual scan definition reader Prevention
- Use access(filename, R_OK) to verify readability before passing scan files.
- Use absolute paths for scan definition files.
- Keep scan files in version control to prevent path or content drift.
When it happens
Trigger: Calling cjpeg with -scans <file> where <file> does not exist or is unreadable. The fopen(filename, 'r') at the entry of the scan-reading function returns NULL.
Common situations: Typo in the scan file path; file not deployed to the expected location; wrong working directory; permissions issue; the scan script was never created.
Related errors
- %s: can't open %s
- Can't open table file %s
- %s: can't open %s
- %s: can't determine size of %s
- %s: can't read ICC profile from %s
AI-assisted analysis of DrKLO/Telegram@45ab8f4308 (2026-08-14).
Data as JSON: /api/errors/11679ee3b51a0ae3.
Report an issue: GitHub.