gitmyhub

image

Rust ★ 5.8k updated 3d ago

Encoding and decoding images in Rust

Rust library for reading, writing, and processing image files. Supports PNG, JPEG, WebP, GIF, AVIF, and more out of the box, plus resizing, cropping, rotation, blur, and color adjustments.

Rustsetup: easycomplexity 2/5

This is a Rust library for reading and writing image files. If you are building a program in Rust that needs to open a photo, modify it, and save it back out, this library handles the file format details so you do not have to.

It can read and write a wide range of common image formats: PNG, JPEG, GIF, WebP, TIFF, BMP, ICO, AVIF, and several others are all supported out of the box. You load an image from disk, get back an object you can inspect or transform, and then write it out to any supported format.

The library also includes a set of image processing operations you can apply: resize an image to new dimensions, crop a region out of it, rotate or flip it, convert it to grayscale, adjust brightness or contrast, apply a blur, and more. All of these work on the same image objects the library creates when you open a file.

For developers, the library is organized around a few core types. A DynamicImage is the general-purpose container you get when opening a file. An ImageBuffer is a more specific type tied to a particular pixel format, like RGB or RGBA. The library also defines traits that let other crates plug in additional format support, so if you need a format not included by default you can often find a third-party crate that adds it.

The README notes that some processing functions run slowly in debug builds and recommends using release mode for any performance-sensitive work. It also recommends that library authors disable the default feature set and opt in only to the specific formats they need, to keep dependency sizes down. This is a mature, actively maintained library used across many Rust projects that involve images.

Where it fits