{"record":{"id":"fe2b2b1ae79011d3","repo":"deepseek-ai/deepseek-harness","slug":"image-too-many-pixels","errorCode":"IMAGE_TOO_MANY_PIXELS","errorMessage":"Image exceeds the configured decoded-pixel limit.","messagePattern":"Image exceeds the configured decoded-pixel limit\\.","errorType":"validation","errorClass":"AttachmentError","httpStatus":null,"severity":"error","filePath":"packages/attachment/attachment-local/src/image.ts","lineNumber":119,"sourceCode":"export interface DecodedImageLimits {\n  /** Decoded-pixel (width times height) admission limit. */\n  maxPixels?: number\n  /** Per-side admission limit applied to width and height independently. */\n  maxDimension?: number\n}\n\n/**\n * Fully decode a supported raster and return its intrinsic metadata.\n * @param data - complete encoded image bytes.\n * @param limits - intrinsic-dimension admission limits.\n * @returns verified format and dimensions.\n */\nexport async function detectImage(data: Uint8Array, limits?: DecodedImageLimits): Promise<DetectedImage> {\n  try {\n    const image = sharp(data, { failOn: 'error', limitInputPixels: false })\n    const detected = await imageMetadata(image)\n    if (limits?.maxPixels !== undefined && detected.width * detected.height > limits.maxPixels) {\n      throw new AttachmentError('Image exceeds the configured decoded-pixel limit.', 'IMAGE_TOO_MANY_PIXELS')\n    }\n    if (limits?.maxDimension !== undefined && Math.max(detected.width, detected.height) > limits.maxDimension) {\n      throw new AttachmentError('Image exceeds the configured per-side pixel limit.', 'IMAGE_DIMENSION_TOO_LARGE')\n    }\n    await image.raw().toBuffer()\n    return detected\n  } catch (error) {\n    if (error instanceof AttachmentError) throw error\n    throw new AttachmentError('Unsupported or malformed image data.', 'INVALID_IMAGE', { cause: error })\n  }\n}\n","sourceCodeStart":101,"sourceCodeEnd":131,"githubUrl":"https://github.com/deepseek-ai/deepseek-harness/blob/b150a551b8d465e31e418e1b2eaf5e79bbb7d28e/packages/attachment/attachment-local/src/image.ts#L101-L131","documentation":"Admission limit: detectImage multiplies the perceived (EXIF-oriented) intrinsic width by height and refuses the image with IMAGE_TOO_MANY_PIXELS when the product exceeds limits.maxPixels — the store default is 64,000,000 (maxImagePixels). Oversized sources are refused, not downscaled; normalization shrinks only after admission succeeds.","triggerScenarios":"Submitting through validateImage / saveImage(s), or calling detectImage with limits, an image whose width*height exceeds maxImagePixels — panoramas, large renders, stitched screenshots — under the default or a lowered cap.","commonSituations":"Phone panoramas and stitched photos beyond 64 MP; print-resolution scans; deployments that lowered maxImagePixels without coordinating clients; clients assuming the server will shrink anything.","solutions":["Downscale before submission so width*height stays within the limit (keep the long edge within maxDimension too).","Raise maxImagePixels in the attachment-local config if the deployment can afford the decode memory.","Surface the effective limits to clients — store.imageLimits is a frozen public field — so they can pre-scale."],"exampleFix":"// before\nawait store.saveImage({ data: panoramaBytes, mediaType: 'image/jpeg' })\n\n// after\nconst data = await sharp(panoramaBytes)\n  .resize({ width: 8000, height: 8000, fit: 'inside', withoutEnlargement: true })\n  .jpeg().toBuffer()\nawait store.saveImage({ data, mediaType: 'image/jpeg' })","handlingStrategy":"validation","validationCode":"const { width, height } = await probeImage(bytes) // header-only pre-check\nif (width * height > store.imageLimits.maxPixels) {\n  throw new Error(`image is ${width * height} px; limit is ${store.imageLimits.maxPixels}`)\n}","typeGuard":"import { isImageAdmissionError } from '@deepseek-ai/dsh-attachment'\nconst isTooManyPixels = (e: unknown): boolean =>\n  isImageAdmissionError(e) && e.code === 'IMAGE_TOO_MANY_PIXELS'","tryCatchPattern":"try {\n  await store.saveImage(input)\n} catch (error) {\n  if (isImageAdmissionError(error) && error.code === 'IMAGE_TOO_MANY_PIXELS') {\n    // reject or downscale client-side; not a transient failure\n  }\n  throw error\n}","preventionTips":["Publish the pixel cap to upload clients and enforce a canvas-size check before upload.","Remember EXIF orientations 5-8 swap perceived width and height; limits use the perceived axes.","Use header-only dimension probes (probeImage) for pre-checks instead of full decodes."],"tags":["image","limits","pixels","admission","attachment"],"backgroundTag":"image-size-limit-exceeded","analyzedSha":"b150a551b8d465e31e418e1b2eaf5e79bbb7d28e","analyzedAt":"2026-08-24T18:12:29.105Z","schemaVersion":2},"datasetVersion":"2026-08-24T22:17:12.610Z"}