2 unstable releases

0.2.0 Nov 7, 2020
0.1.0 Oct 17, 2020

#46 in #gif


Used in ascii-gif

MIT/Apache

1.5MB
546 lines

yaged (yet another gif encoder decoder)

Gif encoder/decoder based on GIF89a specification.

Examples

Decode a gif file using ColorMap color output mode.

let file = &mut File::open(Path::new("./ascii-gif-example.gif")).unwrap();
let gif = decode(file, ColorOutput::ColorMap).unwrap();

Decode a gif file using RGBA color output mode.

let file = &mut File::open(Path::new("./ascii-gif-example.gif")).unwrap();
let gif = decode(file, ColorOutput::RGBA).unwrap();

Still work to do

  • handle interlaced flag
  • handle disposal method
  • handle user input
  • support more extension blocks
  • decoding optimization
  • implements gif encoding

lib.rs:

Gif encoder/decoder bases on GIF89a specification.

Decoding

use {std::fs::File, std::path::Path};

// decodes a gif using ColorMap ColorOutput mode
let file = &mut File::open(Path::new("./ascii-gif-example.gif")).unwrap();
let color_map_gif = yaged::decoder::decode(file, yaged::decoder::ColorOutput::ColorMap).unwrap();
color_map_gif.frames().iter().for_each(|frame| {
 assert!(frame.rgba_raster_data().is_none())
});

// decodes a gif using RGBA ColorOutput mode
let file = &mut File::open(Path::new("./ascii-gif-example.gif")).unwrap();
let rgba_gif = yaged::decoder::decode(file, yaged::decoder::ColorOutput::RGBA).unwrap();
// with this color output mode the rgba_raster_data() will be present in each frame
rgba_gif.frames().iter().for_each(|frame| {
 assert!(frame.rgba_raster_data().is_some())
});

Dependencies