INNER CODE UNIT · Rust
try_print_gif
atanunq/viu · src/app.rs:150
fn try_print_gif<R>(conf: &Config, input_stream: R, (tx, rx): TxRx) -> ViuResult
where
R: Read + BufRead + Seek,
{
//read all frames of the gif and resize them all at once before starting to print them
let resized_frames: Vec<(Duration, DynamicImage)> = GifDecoder::new(input_stream)?
.into_frames()
.collect_frames()?
.into_iter()
.map(|f| {
let delay = Duration::from(f.delay());
// Keep the image as it is for Kitty and iTerm, it will be printed in full resolution there
if (conf.viuer_config.use_iterm && viuer::is_iterm_supported())
|| (conf.viuer_config.use_kitty
&& viuer::get_kitty_support() != viuer::KittySupport::None)
{
(delay, DynamicImage::ImageRgba8(f.into_buffer()))
} else {