nexu-io/open-design · warning · Error

--image too large (${info.size} bytes; max ${MAX_IMAGE_BYTES

Error message

--image too large (${info.size} bytes; max ${MAX_IMAGE_BYTES}).

What it means

Thrown by resolveProjectImage when the regular file exceeds MAX_IMAGE_BYTES (16 MB). The cap exists because base64 inflation (~4/3) plus the upstream API and the daemon's own ~4 MB inbound body cap would reject larger payloads anyway; oversized images must use the dedicated upload endpoint instead of the inline --image dispatcher.

Source

Thrown at apps/daemon/src/media/index.ts:245

      `--image path "${rel}" resolves outside the project directory.`,
    );
  }
  let info;
  try {
    info = await stat(abs);
  } catch {
    throw new Error(`--image not found: ${rel}`);
  }
  if (!info.isFile()) {
    throw new Error(`--image is not a regular file: ${rel}`);
  }
  // Cap at 16 MB. Beyond this, base64 inflation alone (≈4/3) starts
  // hitting body-size limits at the upstream APIs and our own express
  // 4mb body cap on inbound requests; bigger payloads should travel
  // via the dedicated upload endpoint, not the dispatcher.
  const MAX_IMAGE_BYTES = 16 * 1024 * 1024;
  if (info.size > MAX_IMAGE_BYTES) {
    throw new Error(
      `--image too large (${info.size} bytes; max ${MAX_IMAGE_BYTES}).`,
    );
  }
  const bytes = await readFile(abs);
  const ext = path.extname(abs).toLowerCase();
  // Tight allowlist: only what i2v / image-edit endpoints actually
  // consume. Avoids smuggling arbitrary content through as data URLs.
  const mime = ({
    '.png': 'image/png',
    '.jpg': 'image/jpeg',
    '.jpeg': 'image/jpeg',
    '.webp': 'image/webp',
    '.gif': 'image/gif',
  })[ext];
  if (!mime) {
    throw new Error(
      `--image has unsupported extension "${ext}". Use png, jpg, jpeg, webp, or gif.`,
    );

View on GitHub (pinned to 5be4028344)

Solutions

  1. Resize/recompress the image to bring it under 16 MB (e.g. lower resolution, JPEG quality, or PNG optimization).
  2. Use the dedicated media upload endpoint for large assets instead of inline --image.
  3. Strip unnecessary metadata/exif that inflates size.
  4. Prefer WebP/JPEG over uncompressed formats for photographic content.

Example fix

// before: 30 MB screenshot
--image assets/full.png
// after: compress to < 16 MB
sharp('assets/full.png').resize({ width: 2000 }).jpeg({ quality: 85 }).toFile('assets/full.jpg')
--image assets/full.jpg
Defensive patterns

Strategy: validation

Validate before calling

const MAX = 16 * 1024 * 1024;
if (info.size > MAX) throw new Error(`--image too large (${info.size}); compress or use upload endpoint`);

Prevention

When it happens

Trigger: Attaching a high-resolution photo, screenshot, or rendered frame larger than 16 MB; uncompressed PNG/TIFF exports; a generated image pipeline outputting oversized frames.

Common situations: Print-resolution assets; raw camera exports; lossless screen captures; multi-frame/animated content exported as a single large file.

Related errors


AI-assisted analysis of nexu-io/open-design@5be4028344 (2026-08-12). Data as JSON: /api/errors/9e15d17d3358a78f. Report an issue: GitHub.