Loading and saving
editThe pages of this group cover the input and output of images: loading, identifying a file without decoding it, saving, processing long animations with bounded memory, limiting what a hostile file can cost, and handling errors.
A few rules hold for all of them:
- The format of an input is detected from its content, never from its file name.
- An image loads from a path, a stream or bytes in memory, synchronously or asynchronously, with the same results and the same errors.
- Loading never keeps your file or stream open, and never closes your stream.
- Saving checks that the output can store the image before it writes anything, and a file is published only once it is complete.
Pages of this group
- Loading images: Image.Load from a path, a stream or bytes, synchronously or not, in the pixel format you want.
- Identifying images: read the format, the size and the frame count of a file without decoding its pixels.
- Saving images: choose the format from the extension or with an encoder, handle what the format cannot store, save to a stream.
- Streaming readers and writers: process animations of any length one frame at a time.
- Show an image while it downloads: show progressive JPEG, interlaced PNG and progressive JPEG XL files before they are complete.
- Resource limits: bound the size, the frame count and the memory of what you load, especially from untrusted sources.
- Handling errors: the exceptions the library throws and which ones to catch.