Primitives / foldkit-primitives/dom

decodeImage

function · packages/primitives/src/dom/image-decode.ts:32

function decodeImage(
  source: ImageSource,
): Command<ImageDecodeMessage, never, never>

Fetches and decodes source (img.decode()), yielding Decoded once it can be painted at once, or DecodeFailed when it cannot be fetched or read, or there is no document (a server render). Given srcset and sizes, as foldkit-media's Picture.Img has them, the browser picks the candidate it would draw, so the decoded file is the one shown.