{"record":{"id":"ff4b30c261769a59","repo":"NousResearch/hermes-agent","slug":"reference-image-too-large","errorCode":null,"errorMessage":"reference image too large","messagePattern":"reference image too large","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/desktop/src/app/pet-generate/lib/read-reference-image.ts","lineNumber":22,"sourceCode":"  const img = new Image()\n\n  return new Promise((resolve, reject) => {\n    img.onload = () => resolve(img)\n    img.onerror = () => reject(new Error('unreadable image'))\n    img.src = url\n  })\n}\n\n// Read an image file as a downscaled PNG data URL. We decode from an object URL\n// (not readAsDataURL) so large files don't inflate into giant base64 strings\n// before we scale them down for generation.\nexport async function readReferenceImage(\n  file: File,\n  max = 1024,\n  maxInputBytes = DEFAULT_MAX_INPUT_BYTES\n): Promise<string> {\n  if (file.size > maxInputBytes) {\n    throw new Error('reference image too large')\n  }\n\n  const objectUrl = URL.createObjectURL(file)\n\n  try {\n    const img = await loadImage(objectUrl)\n    const scale = Math.min(1, max / Math.max(img.width, img.height))\n    const width = Math.max(1, Math.round(img.width * scale))\n    const height = Math.max(1, Math.round(img.height * scale))\n\n    const canvas = document.createElement('canvas')\n    canvas.width = width\n    canvas.height = height\n\n    const ctx = canvas.getContext('2d')\n\n    if (!ctx) {\n      throw new Error('could not create canvas context')","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/NousResearch/hermes-agent/blob/c896c09c42910c584c4c7d2325b58c14713ea42c/apps/desktop/src/app/pet-generate/lib/read-reference-image.ts#L4-L40","documentation":"Error \"reference image too large\" thrown in NousResearch/hermes-agent.","triggerScenarios":"Thrown at apps/desktop/src/app/pet-generate/lib/read-reference-image.ts:22 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a smaller reference image (downscale or compress it) and retry.","Pick an image under the size cap reported by the generator."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"c896c09c42910c584c4c7d2325b58c14713ea42c","analyzedAt":"2026-08-14T17:18:01.089Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}