siyuan-note/siyuan · error
ErrInputTooLarge
ErrInputTooLarge
Error message
HEIF image exceeds the input size limit
What it means
ErrInputTooLarge (kernel/heif/convert.go:52) is returned when a HEIF input exceeds MaxInputBytes = 32 MiB (convert.go:38). It is enforced at every entry point: convert (convert.go:105), ImageSize (158), ReadFileLimited (69/81 when reading the asset from disk), and cache GetOrCreate (cache.go:97). The cap bounds decoder memory; encrypted assets get a 2 MiB ciphertext margin when read (serve.go reads MaxInputBytes + 2 MiB).
Source
Thrown at kernel/heif/convert.go:52
const (
thumbnailWidth = 520
previewQuality = 90
thumbnailQuality = 85
MaxInputBytes = 32 * 1024 * 1024
maxDimension = 65535
desktopMaxPixels = 50_000_000
mobileMaxPixels = 12_500_000
// 解码层仅接受至多 10-bit 4:2:0、无透明通道的单 slice 图像;这里按解码面、CTU 表、
// NRGBA 和一次合并变换预留每像素 16 字节,再单独预留源文件、RBSP 副本与 JPEG 输出。
workingBytesPerPixel = 16
desktopWorkingBudget = 960 * 1024 * 1024
mobileWorkingBudget = 320 * 1024 * 1024
desktopOutputReserve = 96 * 1024 * 1024
mobileOutputReserve = 32 * 1024 * 1024
)
var (
ErrInputTooLarge = errors.New("HEIF image exceeds the input size limit")
ErrImageTooLarge = errors.New("HEIF image exceeds the dimension limit")
ErrInvalidMode = errors.New("invalid HEIF conversion mode")
conversionSlots = make(chan struct{}, 1)
maxPixels = platformMaxPixels()
)
func platformMaxPixels() int {
if runtime.GOOS == "android" || runtime.GOOS == "ios" {
return pixelsWithinBudget(mobileWorkingBudget, mobileOutputReserve, mobileMaxPixels)
}
return pixelsWithinBudget(desktopWorkingBudget, desktopOutputReserve, desktopMaxPixels)
}
func ReadFileLimited(path string, maxBytes int64) ([]byte, error) {
if maxBytes <= 0 {
return nil, ErrInputTooLarge
}View on GitHub (pinned to afa823b6b4)
Solutions
- Re-export/compress the photo below 32 MiB (lower HEIF quality or reduce resolution)
- Convert the image to JPEG before inserting - the original is still stored as a plain asset, only HEIF preview generation is refused
- Prefer JPEG for very large captures, especially on mobile
Example fix
# before: insert photo_50mp_lossless.heic (40 MiB) # -> HEIF image exceeds the input size limit # after: re-encode below 32 MiB, then insert magick photo_50mp_lossless.heic -quality 80 photo_small.heic
Defensive patterns
Strategy: validation
Validate before calling
// Go: skip preview generation for oversized assets
if fi, err := os.Stat(assetPath); err == nil && fi.Size() > int64(heif.MaxInputBytes) {
return nil // serve the original file as-is, skip HEIF preview
} Type guard
func isHEIFInputTooLarge(err error) bool {
return errors.Is(err, heif.ErrInputTooLarge)
} Prevention
- Keep HEIF assets under 32 MiB (MaxInputBytes)
- Pre-check size with os.Stat before calling heif APIs - the check is cheap and avoids a 32 MiB read
- Transcode oversized captures to JPEG at import time
When it happens
Trigger: Inserting a .heic/.heif larger than 33554432 bytes; the preview pipeline (serve.go:1215/1255) reading such an asset; calling heif.ImageSize on oversized data (model/assets.go:69).
Common situations: High-megapixel phone HEIFs saved at near-lossless quality; panorama or burst exports; photos re-saved losslessly by editors pushing past 32 MiB.
Understand the failure class
Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.
Related errors
- ErrImageTooLarge
- empty HEIF image
- Agent capability name and description are required
- source is not an encrypted asset
- invalid asset type [%s]
AI-assisted analysis of siyuan-note/siyuan@afa823b6b4 (2026-08-18).
Data as JSON: /api/errors/a3bb405397d79493.
Report an issue: GitHub.