DrKLO/Telegram · error

%s: can't read ICC profile from %s\n

Error message

%s: can't read ICC profile from %s\n

What it means

MISLEADING MESSAGE: the text says 'can't read ICC profile' but the actual failing call is fwrite(icc_profile, icc_len, 1, icc_file) < 1, i.e. a WRITE failure to the ICC output file. jpeg_read_icc_profile succeeded and returned data, but writing that data to disk failed (e.g. disk full, write error). Fatal.

Source

Thrown at TMessagesProj/jni/mozjpeg/djpeg.c:786

#ifdef PROGRESS_REPORT
  /* Hack: count final pass as done in case finish_output does an extra pass.
   * The library won't have updated completed_passes.
   */
  progress.pub.completed_passes = progress.pub.total_passes;
#endif

  if (icc_filename != NULL) {
    FILE *icc_file;
    JOCTET *icc_profile;
    unsigned int icc_len;

    if ((icc_file = fopen(icc_filename, WRITE_BINARY)) == NULL) {
      fprintf(stderr, "%s: can't open %s\n", progname, icc_filename);
      exit(EXIT_FAILURE);
    }
    if (jpeg_read_icc_profile(&cinfo, &icc_profile, &icc_len)) {
      if (fwrite(icc_profile, icc_len, 1, icc_file) < 1) {
        fprintf(stderr, "%s: can't read ICC profile from %s\n", progname,
                icc_filename);
        free(icc_profile);
        fclose(icc_file);
        exit(EXIT_FAILURE);
      }
      free(icc_profile);
      fclose(icc_file);
    } else if (cinfo.err->msg_code != JWRN_BOGUS_ICC)
      fprintf(stderr, "%s: no ICC profile data in JPEG file\n", progname);
  }

  /* Finish decompression and release memory.
   * I must do it in this order because output module has allocated memory
   * of lifespan JPOOL_IMAGE; it needs to finish before releasing memory.
   */
  (*dest_mgr->finish_output) (&cinfo, dest_mgr);
  (void)jpeg_finish_decompress(&cinfo);
  jpeg_destroy_decompress(&cinfo);

View on GitHub (pinned to 45ab8f4308)

Solutions

  1. Free space on the target volume / raise quota, then retry.
  2. Point -icc at stable local storage rather than a flaky mount.
  3. Treat the message as a WRITE failure: check df and write perms on the ICC path.
  4. Verify disk health if write errors recur on known-good free space.

Example fix

// before: writes ICC to a full volume
./djpeg in.jpg -icc /full/profile.icc > out.ppm
// after: free space / use a writable volume
df -h /tmp
./djpeg in.jpg -icc /tmp/profile.icc > out.ppm
Defensive patterns

Strategy: validation

Validate before calling

#include <sys/statvfs.h>
int has_space_for(const char *dirpath, size_t need) {
  struct statvfs v;
  if (statvfs(dirpath, &v) != 0) return 0;
  return (size_t)(v.f_bavail * v.f_bsize) >= need;
}
/* call on dirname(icc_filename) before djpeg; profile is typically < 1 MB */

Prevention

When it happens

Trigger: ICC profile was successfully extracted from the JPEG, but fwrite to icc_file could not write icc_len bytes. Commonly disk full, quota exceeded, or a write I/O error on the target device. The message incorrectly blames reading.

Common situations: Full disk or quota when writing the ICC blob, target on a failing/unmounting storage medium, or a filesystem with a per-file size limit. Developers waste time looking at the input JPEG because the message says 'read'.

Related errors


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