Resizing images with Rust and WASM in the browser pt1

submited by
Style Pass
2024-10-28 18:30:05

Rusty Image is a simple image resizer, format converter and analysis app written in rust compiled to wasm running from github pages and developed using ChatGPT. It even supports offline mode and can be installed as a standalone PWA on your device.

The core file powering RustyImageTools comes from the lib.rs file found here. This file serves as the entry point for the rust logic. Though the rust app is later converted to a wasm file, the core logic was written in this file.

The exif library is used to handle EXIF (Exchangeable Image File Format) metadata, which stores information about an image, such as camera settings, date taken, and orientation.

When analyzing images, we want to capture metadata details and color patterns. I define a struct called ImageAnalysis to store these values

By adding the #[derive(Serialize)] attribute, we’re enabling the struct to be converted (serialized) into formats like JSON. This is especially useful for web applications or any system where the data might be passed to JavaScript or some other API.

Leave a Comment