gifski

repository·main·Indexed 25 days ago

https://github.com/sindresorhus/gifski

A high-quality GIF encoder and pngquant-based GIF maker for creating high-quality animGIFs. It is available as a CLI tool, a macOS application, and a C library. gifski supports converting video files (via ffmpeg), YUV4MPEG2 (.y4m) files, and sequences of PNG images into GIFs with advanced controls for quality, motion, lossy compression, and dimensions.

Tokens
5.4K
Snippets
17
Records
42
Agent score
92%

What's inside gifski

  1. Cross-compile gifski for iOS

    main

    To build the library for iOS manually:

    1. Add the target: rustup target add aarch64-apple-ios
    2. Build the library: rustup update && cargo build --lib --release --target=aarch64-apple-ios

    The static library will be created at ./target/aarch64-apple-ios/release/libgifski.a. You can then add this to your Xcode project.

    rustup target add aarch64-apple-ios
    rustup update
    cargo build --lib --release --target=aarch64-apple-ios
  2. Optimize GIF file size

    main

    To reduce the file size of your generated GIFs, use the following strategies:

    • Dimensions: Use --width and --height to make the animation smaller. This has the largest impact.
    • Overall Quality: Use --quality=N (where N is a number, e.g., --quality=80) to lower the baseline quality.
    • Lossy Quality: Use --lossy-quality=N (e.g., --lossy-quality=60). Lower values make animations noisier/grainier but reduce file size.
    • Motion Quality: Use --motion-quality=N (e.g., --motion-quality=60). Lower values cause smearing or banding in frames with motion but reduce file size.
  3. Build Gifski from source

    main

    To build the Gifski app in Xcode, you must first install Rust, SwiftLint, and the Xcode command line tools:

    curl https://sh.rustup.rs -sSf | sh
    brew install SwiftLint
    xcode-select --install
    curl https://sh.rustup.rs -sSf | sh
    brew install SwiftLint
    xcode-select --install
  4. Build gifski dynamic library for package maintainers

    main

    To build a dynamic library and generate a pkg-config file, use cargo-c.

    rustup update
    cargo install cargo-c
    # build
    cargo cbuild --prefix=/usr --release
    # install
    cargo cinstall --prefix=/usr --release --destdir=pkgroot
    rustup update
    cargo install cargo-c
    cargo cbuild --prefix=/usr --release
    cargo cinstall --prefix=/usr --release --destdir=pkgroot
  5. Enable built-in video support

    main

    By default, gifski does not decode video directly. To enable this feature, you must have ffmpeg and libclang installed with their respective C headers in your system include paths (e.g., libavformat-dev, libavfilter-dev, libavdevice-dev, libclang-dev, clang).

    Compile with the following feature flags:

    cargo build --release --features=video
    # or
    cargo build --release --features=video-static

    Once enabled, you can run: gifski -o out.gif video.mp4

    cargo build --release --features=video
  6. Build gifski from source

    main

    To build the CLI tool from source, ensure you have an up-to-date Rust installation via rustup.

    1. git clone https://github.com/ImageOptim/gifski
    2. cd gifski
    3. cargo build --release

    The resulting binary will be located in ./target/release.

    git clone https://github.com/ImageOptim/gifski
    cd gifski
    cargo build --release
  7. Install Gifski on macOS

    main

    Gifski is a macOS app used to convert videos into high-quality GIFs.

    App Store Version Requires macOS 26 or later. You can download it from the Mac App Store.

    Older macOS Versions

    Non-App Store Version For users who cannot access the App Store. Note that this version does not receive automatic updates. Download Non-App Store Version (v3.0.3 · macOS 26+)

  8. Build the Gifski C library

    main

    To use Gifski as a library in your C/C++ project, build it using Cargo:

    cargo build --release --lib

    This produces:

    • target/release/libgifski.a (Static library - Recommended)
    • target/release/libgifski.so/dylib or gifski.dll (Dynamic library)

    To build for iOS:

    rustup target add aarch64-apple-ios
    cargo build --release --lib --target aarch64-apple-ios
  9. Use the gifski CLI to create animations

    main

    The gifski command-line tool converts video files or sequences of PNG images into high-quality GIFs. You must specify an output destination using the --output (or -o) flag. If you want to write to stdout, use "-" as the output path.

    Input Formats:

    • Video: A single video file supported by FFmpeg (requires the video feature enabled).
    • Images: Multiple PNG image files (sorted by name by default).
    • Y4M: A .y4m file.

    Note on Input Order: By default, input files are sorted. Use --no-sort to use the files exactly in the order provided.

  10. Verify Gifski system service installation

    main
    To check if the latest version of Gifski.app is correctly registered as a system service, run the pbs -dump command and grep for the application bundle path. If the service is not detected, update the system service cache using the -update flag.
  11. Debug Gifski system service logs

    main

    If the Gifski system service is not functioning correctly, you can inspect the logs by running an instance of Finder with the -NSDebugServices flag targeting the Gifski service identifier.

    /System/Library/CoreServices/Finder.app/Contents/MacOS/Finder -NSDebugServices com.sindresorhus.Gifski