siyuan-note/siyuan · error
prepared image exceeds size limit: %d bytes
Error message
prepared image exceeds size limit: %d bytes
What it means
After all processing (resize, PNG encode, final JPEG quality-92 encode) the output STILL exceeds maxBytes. The image cannot be compressed under the cap at quality 92, so it is rejected.
Source
Thrown at kernel/util/openai.go:684
if err = png.Encode(&output, decoded); err != nil {
return PreparedImage{}, errors.New("encode image failed: " + err.Error())
}
if maxBytes <= 0 || output.Len() <= maxBytes {
return PreparedImage{
Data: output.Bytes(),
MIMEType: "image/png",
Width: bounds.Dx(),
Height: bounds.Dy(),
SourceSize: len(data),
}, nil
}
}
var output bytes.Buffer
if err = jpeg.Encode(&output, decoded, &jpeg.Options{Quality: 92}); err != nil {
return PreparedImage{}, errors.New("encode image failed: " + err.Error())
}
if maxBytes > 0 && output.Len() > maxBytes {
return PreparedImage{}, fmt.Errorf("prepared image exceeds size limit: %d bytes", maxBytes)
}
return PreparedImage{
Data: output.Bytes(),
MIMEType: "image/jpeg",
Width: bounds.Dx(),
Height: bounds.Dy(),
SourceSize: len(data),
}, nil
}
// ValidateGeneratedImage 校验生成图片的格式、尺寸和体积。
func ValidateGeneratedImage(data []byte) (mimeType, extension string, err error) {
if len(data) == 0 {
return "", "", errors.New("generated image is empty")
}
if len(data) > maxGeneratedImageBytes {
return "", "", errors.New("generated image exceeds size limit")
}View on GitHub (pinned to 251596fc0d)
Solutions
- Downscale the source resolution before sending.
- Pre-compress to a lower JPEG quality externally.
- Raise maxBytes if the provider allows a larger upload.
Defensive patterns
Strategy: validation
Try / catch
img, err := util.PrepareModelImage(data, maxBytes, maxPixels, maxEdge)
if err != nil {
log.Warnf("image too large for vision budget after encode: %s", err)
return skipImage()
} Prevention
- Downscale before attaching to fit the byte budget
- Tune maxBytes to the provider's actual cap
When it happens
Trigger: Very large or complex image whose JPEG q92 output is still over maxBytes (e.g. 20MP photo with maxBytes=1MB).
Common situations: Aggressive maxBytes combined with high-resolution input; provider with a tight upload cap.
Related errors
- image exceeds size limit: %d bytes
- image exceeds pixel limit: %d
- image data is empty
- SVG images are not accepted by multimodal models
- unsupported image type: %s
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/58bd30911a538665.
Report an issue: GitHub.