11 个版本 (6 个重大更新)
使用旧的 Rust 2015
0.8.1 | 2017 年 10 月 23 日 |
---|---|
0.8.0 | 2017 年 9 月 9 日 |
0.7.1 | 2017 年 7 月 3 日 |
0.6.1 | 2017 年 6 月 25 日 |
0.2.0 | 2017 年 5 月 10 日 |
#163 in 多媒体
每月 45 次下载
37KB
759 行
engiffen
从图像序列生成 GIF。
源帧、生成的 GIF 和 Photoshop 中的 GIF
用法
作为二进制文件
# Read a bunch of bitmaps and write them to a 20-frame-per-second gif at path `hello.gif`
engiffen *.bmp -f 20 -o hello.gif
# Read a range of files
engiffen -r file01.bmp file20.bmp -o hello.gif
# The app sorts them in lexicographical order, so if your shell orders `file9`
# before `file10`, the resulting gif will not be in that order.
# Use a faster but worse quality algorithm
engiffen -r file01.bmp file20.bmp -o hello.gif -q naive
# Use the default NeuQuant algorithm, but with a reduced pixel sample rate
# Values over 1 reduces the amount of pixels the algorithm trains with
engiffen -r file01.bmp file100.bmp -o hello.gif -s 2
# Print to stdout by leaving out the -o argument
engiffen *.bmp > output.gif
# or hose your console by forgetting to redirect!
engiffen *.bmp
(如果您的 shell 不将通配符模式展开为单个参数(例如,Windows 命令行),则二进制文件将解析单个参数作为通配符模式并将其自己展开为文件名。您可以使用 --no-default-features
来安装二进制文件以跳过此功能。)
作为库
extern crate engiffen;
use engiffen::{load_images, engiffen, Gif, Quantizer};
use std::fs::File;
let paths = vec!["vector", "of", "file", "paths", "on", "disk"];
let images = load_images(&paths);
let mut output = File::create("output.gif")?;
// encode an animated gif at 10 frames per second
let gif = engiffen(&images, 10, Quantizer::Naive)?;
gif.write(&mut output);
// Optionally specify how many pixels of each frame should be sampled
// when computing the gif's palette. This value reduces the amount of
// sampling work to 1/9th of what it normally would, by only sampling
// every 3rd pixel on every 3rd row (i.e. pixels lying on a 3x3 grid).
let gif = engiffen(&images, 10, Quantizer::NeuQuant(3));
调试输出
要打印到 STDERR 的时间信息,请使用 debug-stderr
功能进行编译
$ cargo install engiffen --features debug-stderr
$ engiffen *.tif -f 15 -s 10 > out.gif
Checked image dimensions in 0 ms.
Pushed all frame pixels in 469 ms.
Computed palette in 67 ms.
Mapped pixels to palette in 3443 ms.
Wrote to stdout in 5415 ms
其他
实际从样本帧创建 GIF 的测试被忽略。在运行被忽略的规范时,请以发布模式运行,否则它们将花费很长时间。
cargo test --release -- --ignored
主要工作要做
-
增量帧处理
从服务器接收帧流以逐个处理它们。推迟对最终调色板的排序和 GIF 的编译,直到完成。
还有其他吗?
依赖项
~12MB
~69K SLoC