TErrorCode
Bun

type

Image.ErrorCode

type ErrorCode = 'ERR_IMAGE_FORMAT_UNSUPPORTED' | 'ERR_IMAGE_TOO_MANY_PIXELS' | 'ERR_IMAGE_DECODE_FAILED' | 'ERR_IMAGE_ENCODE_FAILED' | 'ERR_IMAGE_UNKNOWN_FORMAT' | 'ERR_INVALID_STATE'

Stable error.code values set on rejections from Bun.Image terminals. Branch on these instead of parsing the message.

  • ERR_IMAGE_FORMAT_UNSUPPORTED — the requested format isn't available on this machine (HEIC/AVIF without the OS codec, TIFF on Linux). Catch this to fall back to a portable format.
  • ERR_IMAGE_TOO_MANY_PIXELS — header dimensions or resize output exceed maxPixels, or a path-backed input is over the 256 MiB cap.
  • ERR_IMAGE_DECODE_FAILED / ERR_IMAGE_ENCODE_FAILED — codec error.
  • ERR_IMAGE_UNKNOWN_FORMAT — input bytes didn't match any sniffer.
  • ERR_INVALID_STATE — the input ArrayBuffer was transferred between construction and the terminal call.
  • File-backed inputs surface the underlying syscall code (ENOENT, EACCES, …) directly.