#qoi #image #ok #quite #save #desc

img-qoi

QOI (Quite OK Image) manipulation library

1 unstable release

0.1.0 Nov 30, 2021

#652 in Images

MIT license

65KB
1.5K SLoC

QOI (Quite OK Image) manipulation library

Examples

Convert QOI to PNG (with image crate):

use image::RgbaImage;
use img_qoi::*;

let (desc, buf_rgba) = qoi_open("foo.qoi", QoiChannels::Rgba)?;

let img = RgbaImage::from_vec(desc.width().get(), desc.height().get(), buf_rgba).unwrap();
img.save("foo.png")?;

Convert PNG to QOI (with image crate):

use std::num::NonZeroU32;
use img_qoi::*;

let img = image::open("foo.png")?;
let img = img.to_rgba8();

let desc = QoiDesc::new(
    NonZeroU32::new(img.width()).unwrap(),
    NonZeroU32::new(img.height()).unwrap()
);

// `RgbaImage` implements `Deref<[u8]>`.
qoi_save_from_buffer("foo.qoi", &desc, &*img, QoiChannels::Rgba)?;

License

MIT


lib.rs:

QOI (Quite OK Image) manipulation library.

Examples

Convert QOI to PNG (with image crate):

use image::RgbaImage;
use img_qoi::*;

let (desc, buf_rgba) = qoi_open("foo.qoi", QoiChannels::Rgba)?;

let img = RgbaImage::from_vec(desc.width().get(), desc.height().get(), buf_rgba).unwrap();
img.save("foo.png")?;

Convert PNG to QOI (with image crate):

use std::num::NonZeroU32;
use img_qoi::*;

let img = image::open("foo.png")?;
let img = img.to_rgba8();

let desc = QoiDesc::new(
    NonZeroU32::new(img.width()).unwrap(),
    NonZeroU32::new(img.height()).unwrap()
);

// `RgbaImage` implements `Deref<[u8]>`.
qoi_save_from_buffer("foo.qoi", &desc, &*img, QoiChannels::Rgba)?;

Dependencies

~0.4–0.9MB
~20K SLoC