Crates.io | gifski |
lib.rs | gifski |
version | 1.32.0 |
source | src |
created_at | 2017-11-02 00:50:41.38792 |
updated_at | 2024-04-24 00:54:10.377703 |
description | pngquant-based GIF maker for nice-looking animGIFs |
homepage | https://gif.ski |
repository | https://github.com/ImageOptim/gifski |
max_upload_size | |
id | 37749 |
size | 197,828 |
Highest-quality GIF encoder based on pngquant.
gifski converts video frames to GIF animations using pngquant's fancy features for efficient cross-frame palettes and temporal dithering. It produces animated GIFs that use thousands of colors per frame.
It's a CLI tool, but it can also be compiled as a C library for seamless use in other apps.
See releases page for executables.
If you have Homebrew, you can also get it with brew install gifski
.
If you have Rust from rustup (1.63+), you can also build it from source with cargo install gifski
.
gifski is a command-line tool. There is no GUI for Windows or Linux (there is one for macOS).
The recommended way is to first export video as PNG frames. If you have ffmpeg
installed, you can run in terminal:
ffmpeg -i video.webm frame%04d.png
and then make the GIF from the frames:
gifski -o anim.gif frame*.png
You can also resize frames (with -W <width in pixels>
option). If the input was ever encoded using a lossy video codec it's recommended to at least halve size of the frames to hide compression artefacts and counter chroma subsampling that was done by the video codec.
See gifski -h
for more options.
Expect to lose a lot of quality for little gain. GIF just isn't that good at compressing, no matter how much you compromise.
--width
and --height
to make the animation smaller. This makes the biggest difference.--quality=80
(or a lower number) to lower overall quality. You can fine-tune the quality with:
--lossy-quality=60
lower values make animations noisier/grainy, but reduce file sizes.--motion-quality=60
lower values cause smearing or banding in frames with motion, but reduce file sizes.If you need to make a GIF that fits a predefined file size, you have to experiment with different sizes and quality settings. The command line tool will display estimated total file size during compression, but keep in mind that the estimate is very imprecise.
rustup update
. This project only supports up-to-date versions of Rust. You may get compile errors, warnings about "unstable edition", etc. if you don't run rustup update
regularly.git clone https://github.com/ImageOptim/gifski
cargo build --release
See gifski.h
for the C API. To build the library, run:
rustup update
cargo build --release
and link with target/release/libgifski.a
. Please observe the LICENSE.
The build process uses cargo-c
for building the dynamic library correctly and generating the pkg-config file.
rustup update
cargo install cargo-c
# build
cargo cbuild --prefix=/usr --release
# install
cargo cinstall --prefix=/usr --release --destdir=pkgroot
The cbuild
command can be omitted, since cinstall
will trigger a build if it hasn't been done already.
AGPL 3 or later. I can offer alternative licensing options, including commercial licenses. Let me know if you'd like to use it in a product incompatible with this license.
The tool optionally supports decoding video directly, but unfortunately it relies on ffmpeg 4.x, which may be very hard to get working, so it's not enabled by default.
You must have ffmpeg
and libclang
installed, both with their C headers installed in default system include paths. Details depend on the platform and version, but you usually need to install packages such as libavformat-dev
, libavfilter-dev
, libavdevice-dev
, libclang-dev
, clang
. Please note that installation of these dependencies may be quite difficult. Especially on macOS and Windows it takes expert knowledge to just get them installed without wasting several hours on endless stupid installation and compilation errors, which I can't help with. If you're cross-compiling, try uncommenting [patch.crates-io]
section at the end of Cargo.toml
, which includes some experimental fixes for ffmpeg.
Once you have dependencies installed, compile with cargo build --release --features=video
or cargo build --release --features=video-static
.
When compiled with video support ffmpeg licenses apply. You may need to have a patent license to use H.264/H.265 video (I recommend using VP9/WebM instead).
gifski -o out.gif video.mp4
The easy option is to use the included gifski.xcodeproj
file to build the library automatically for all Apple platforms. Add it as a subproject to your Xcode project, and link with gifski-staticlib
Xcode target. See the GUI app for an example how to integrate the library.
Make sure you have Rust installed via rustup. Run once:
rustup target add aarch64-apple-ios
and then to build the library:
rustup update
cargo build --lib --release --target=aarch64-apple-ios
The build will print "dropping unsupported crate type cdylib
" warning. This is normal and expected when building for iOS (the cdylib option exists for other platforms).
This will create a static library in ./target/aarch64-apple-ios/release/libgifski.a
. You can add this library to your Xcode project. See gifski.app for an example how to use libgifski from Swift.