gif-transcode

Decode, edit and re-encode animated GIFs without inflating them. Drop one below: it is read, differenced and re-encoded entirely in this tab, and never leaves your machine.

Drop a GIF here or click to choose one. Nothing is uploaded.

Install

npm install gif-transcode
import { decodeGif, encodeGif, reverseFrames } from "gif-transcode";

const gif = await decodeGif(await file.arrayBuffer());
const out = await encodeGif(reverseFrames(gif.frames), gif.width, gif.height);

Source and README · npm · MIT

Where it came from

This is the GIF pipeline behind the tools on Image Machine, lifted out unchanged. The inflation it exists to fix showed up first in the GIF cropper: cropping a 2 MB animation returned 9 MB, because every frame was being written whole instead of as a difference against the one before it.

Nothing here is a rewrite for display. The package is the same file the site runs, which is also why the numbers above match what the site produces.