toeverything/AFFiNE · error · napi::Error
image dimensions exceed limit
Error message
image dimensions exceed limit
What it means
validate_dimensions in the native image processor rejects images whose width or height exceeds MAX_IMAGE_DIMENSION; oversized images bail! with this error before processing. Called from process_image_inner.
Source
Thrown at packages/backend/native/src/image.rs:92
preserve_exif(input, format, &mut output)?;
}
Ok(output)
}
fn read_dimensions(input: &[u8], format: ImageFormat) -> AnyResult<(u32, u32)> {
ImageReader::with_format(Cursor::new(input), format)
.into_dimensions()
.context("failed to decode image")
}
fn validate_dimensions(width: u32, height: u32) -> AnyResult<()> {
if width == 0 || height == 0 {
bail!("failed to decode image");
}
if width > MAX_IMAGE_DIMENSION || height > MAX_IMAGE_DIMENSION {
bail!("image dimensions exceed limit");
}
if u64::from(width) * u64::from(height) > MAX_IMAGE_PIXELS {
bail!("image pixel count exceeds limit");
}
Ok(())
}
fn decode_image(input: &[u8], format: ImageFormat) -> AnyResult<DynamicImage> {
Ok(match format {
ImageFormat::Gif => {
let decoder = GifDecoder::new(Cursor::new(input)).context("failed to decode image")?;
let frame = decoder
.into_frames()
.next()
.transpose()
.context("failed to decode image")?View on GitHub (pinned to b4c8548c09)
Solutions
- Downscale the image before processing.
- Raise the dimension limit only if memory allows.
Defensive patterns
Strategy: validation
When it happens
Trigger: Raised in validate_dimensions when a decoded image width or height exceeds MAX_IMAGE_DIMENSION.
Common situations: The source image is extremely large on one axis (e.g. a huge panorama or scan). Downscale it externally below the dimension limit before processing.
AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18).
Data as JSON: /api/errors/af1ebb144d1f5760.
Report an issue: GitHub.