{"record":{"id":"09d48195f60a5179","repo":"jackwener/OpenCLI","slug":"label-exceeds-midjourney-s-10mb-upload-limit","errorCode":null,"errorMessage":"${label} exceeds Midjourney's 10MB upload limit: ${ref.value}","messagePattern":"(.+?) exceeds Midjourney's 10MB upload limit: (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/midjourney/utils.js","lineNumber":913,"sourceCode":"        if (error instanceof ArgumentError) throw error;\n      }\n      return { kind: 'url', value: item };\n    }\n    const expanded = item === '~' ? os.homedir() : item.startsWith('~/') ? path.join(os.homedir(), item.slice(2)) : item;\n    return { kind: 'local', value: path.resolve(expanded) };\n  });\n}\n\nexport async function validateLocalReferences(refs, label) {\n  for (const ref of refs.filter((item) => item.kind === 'local')) {\n    let stat;\n    try {\n      stat = await fs.stat(ref.value);\n    } catch {\n      throw new ArgumentError(`${label} file does not exist: ${ref.value}`);\n    }\n    if (!stat.isFile() || stat.size <= 0) throw new ArgumentError(`${label} must reference a non-empty file: ${ref.value}`);\n    if (stat.size > MAX_REFERENCE_BYTES) throw new ArgumentError(`${label} exceeds Midjourney's 10MB upload limit: ${ref.value}`);\n    const ext = path.extname(ref.value).toLowerCase();\n    if (!IMAGE_EXTENSIONS.has(ext)) throw new ArgumentError(`${label} must be PNG, JPEG, WEBP, or GIF: ${ref.value}`);\n  }\n  return refs;\n}\n\nasync function visibleImageSources(page) {\n  const payload = unwrapEvaluateResult(await page.evaluate(() => [...document.querySelectorAll('img[src]')]\n    .filter((img) => {\n      const rect = img.getBoundingClientRect();\n      let card = img.parentElement;\n      while (card && !String(card.className).includes('group/img')) card = card.parentElement;\n      return Boolean(card) && rect.width > 24 && rect.height > 24 && /cdn\\.midjourney\\.com\\/u\\//.test(img.src);\n    })\n    .map((img) => img.src)));\n  return Array.isArray(payload) ? payload.map(String) : [];\n}\n","sourceCodeStart":895,"sourceCodeEnd":931,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/midjourney/utils.js#L895-L931","documentation":"Midjourney's upload endpoint accepts images up to 10MB (MAX_REFERENCE_BYTES). When a local reference's stat size exceeds this constant, the library throws this ArgumentError before starting the browser upload, avoiding a guaranteed-to-fail transfer.","triggerScenarios":"A local PNG/JPEG/WEBP/GIF whose byte size exceeds 10MB — full-resolution exports, high-DPI screenshots, raw scans, or long animated GIFs.","commonSituations":"Designers exporting 4K renders, lossless screen recordings saved as GIF, camera originals, or datasets with source-resolution imagery.","solutions":["Resize/compress the image below 10MB (e.g. magick input.png -resize 2048x -quality 85 output.webp)","Re-export as JPEG/WEBP at lower quality","Crop or downscale before passing to the CLI"],"exampleFix":"// before\nclis/midjourney --refs ./4k-render.png   // 18MB\n// after\nmagick ./4k-render.png -resize 2048x2048 -quality 85 ./render.webp\nclis/midjourney --refs ./render.webp","handlingStrategy":"validation","validationCode":"const MAX = 10 * 1024 * 1024;\nconst s = await fs.stat(p);\nif (s.size > MAX) await compressImage(p); // e.g. magick p -resize 2048x -quality 85 out.webp","typeGuard":"const withinUploadLimit = async (p, max = 10 * 1024 * 1024) => (await fs.stat(p)).size <= max;","tryCatchPattern":"try {\n  await validateLocalReferences(refs, 'refs');\n} catch (e) {\n  if (String(e.message).includes(\"10MB upload limit\")) {\n    console.error('Compress/resize the image below 10MB:', e.message);\n  }\n  throw e;\n}","preventionTips":["Pre-check file size against 10MB in automation before uploads","Export images at web-appropriate resolutions (<=2048px) by default","Prefer JPEG/WEBP for photographic sources to keep sizes small"],"tags":["filesystem","upload-limit","argument-validation"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}