#base64 #image #png #jpeg #gif #wasm #compatible

image-base64-wasm

Imaging library written in Rust supported by wasm. Provides basic filters and decoders for the most common image formats.

5 releases (breaking)

Uses old Rust 2015

0.6.0 Jan 15, 2021
0.5.0 Jan 11, 2021
0.4.0 Jan 11, 2021
0.3.0 Dec 15, 2020
0.2.0 Dec 15, 2020

#55 in #gif

Download history 15/week @ 2024-03-11 4/week @ 2024-03-18 4/week @ 2024-03-25 37/week @ 2024-04-01 9/week @ 2024-04-08 7/week @ 2024-04-15 5/week @ 2024-04-22 11/week @ 2024-04-29 10/week @ 2024-05-06 13/week @ 2024-05-13 16/week @ 2024-05-20 10/week @ 2024-05-27 39/week @ 2024-06-03 21/week @ 2024-06-10 27/week @ 2024-06-17 32/week @ 2024-06-24

119 downloads per month
Used in 6 crates (3 directly)

MIT license

115KB

image-base64-wasm

crates

Convert jpeg, png, gif, ico to base64, and vise versa

Compatibility

The library is compatible with wasm

To build into wasm, uncomment the target line in .cargo/config

[build]
# target = "wasm32-unknown-unknown"

Code Example

  • Read from a file
extern crate image_base64_wasm;

fn main() {
  let base64 = "base64 String";
  let image = image_base64_wasm::from_base64(base64);
  
  let image_path = "local image file path"
  let base64 = image_base64_wasm::to_base64(image_path); 
}
  • From Vec<u8> (useful for url response body)
extern crate image_base64_wasm;

fn main() {
  let base64 = "base64 String";
  let image = image_base64_wasm::from_base64(base64);
  
  let img_data: Vec<u8> = ...; // TODO replace this part
  let base64 = image_base64_wasm::vec_to_base64(img_data); 
}

Installation

Add the dependency to your Cargo.toml under [dependencies]:

image-base64-wasm = "0.5.0"

License

MIT

Dependencies

~17MB
~135K SLoC