gift

Crates.iogift
lib.rsgift
version
sourcesrc
created_at2019-04-26 00:17:44.755197+00
updated_at2025-03-16 16:18:29.444623+00
descriptionA library for reading and writing GIF images
homepage
repositoryhttps://github.com/DougLau/gift
max_upload_size
id130228
Cargo.toml error:TOML parse error at line 17, column 1 | 17 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Jeryn Aldaron Lau (AldaronLau)

documentation

https://docs.rs/gift

README

GIFt

A Rust library for encoding and decoding GIF images.

Documentation

https://docs.rs/gift

Decoding

use gift::Decoder;
use std::fs::File;
use std::io::BufReader;

let gif = BufReader::new(File::open("example.gif")?);
for step in Decoder::new(gif) {
    // was there a decoding error?
    let raster = step?.raster();
    // ... work with raster
}

Encoding

use gift::{Encoder, Step};
use pix::{gray::Gray8, Palette, Raster, rgb::SRgb8};
use std::error::Error;
use std::io::Write;

fn encode<W: Write>(mut w: W) -> Result<(), Box<dyn Error>> {
    let mut raster = Raster::<Gray8>::with_clear(4, 4);
    // ... initialize raster ...
    let mut palette = Palette::new(2);
    // ... initialize palette ...
    let step = Step::with_indexed(raster, palette);
    let mut enc = Encoder::new(&mut w).into_step_enc();
    enc.encode_step(&step)?;
    Ok(())
}

NOTE: building a palette from 24- or 32-bit rasters is not yet implemented.

Commit count: 166

cargo fmt