FFWebP is a small, single-binary CLI for converting images between formats, think "ffmpeg for images". It auto-detects the input format, lets you pick the output format by file extension or --codec, supports stdin/stdout, thumbnails and rich per-codec options.
- Single binary: no external tools required
- Auto-detects input codec and infers output from the file extension
- Supports AVIF, BMP, DDS, DNG (embedded JPEG preview only), Farbfeld, GIF, HEIF/HEIC, ICO/CUR, JPEG, JPEG 2000, JPEG-LS, JPEG XL, PCX, PNG/APNG, PNM (PBM/PGM/PPM/PAM), PSD (decode-only), QOI, SVG (decode-only), TGA, TIFF, WebP, XBM, XCF (decode-only) and XPM
- Lossy or lossless output with configurable quality
- Thumbnail generation via Lanczos3 resampling
- Join ordered inputs into image grids with automatic sizing, alignment and backgrounds
- Per-codec flags for fine-grained control (see
ffwebp --help [format], e.g.ffwebp --help webp;ffwebp help [topic]also works andffwebp --help topicslists available topics)
You can bootstrap ffwebp-full with a single command. This script will detect your OS and CPU (amd64/arm64), download the correct binary and install it to /usr/local/bin/ffwebp.
curl -sL https://src.ws2.sh/ffwebp/install.sh | sh# All codecs
go build -tags full -o ffwebp ./cmd/ffwebp
# Core set (common formats)
go build -tags core -o ffwebp ./cmd/ffwebp
# Custom subset
go build -tags "jpeg,png,webp" -o ffwebp ./cmd/ffwebpNotes
- The banner at startup prints the compiled-in codecs (from build tags).
- You can enable individual codecs with tags matching their names (e.g.,
-tags avif,jpegxl,tiff). - APNG is part of the PNG adapter and is included with the
png,coreandfullbuild tags.
Basic conversion
ffwebp -i input.jpg output.webp
# or, equivalently
ffwebp -i input.jpg -o output.webpThe output file, directory or pattern can be supplied as a positional argument instead of -o/--output. Use only one form per command. If neither is supplied, output defaults to stdout.
File output is encoded into a temporary file beside the destination before publication. New files use mode 0644 filtered by the process umask; replacements preserve existing permission bits. --skip-existing never replaces an occupied destination, including one created during conversion. It prefers atomic no-replace rename (Linux/macOS/Windows) or hard-link publication. If neither is available, it exclusively creates the destination and copies the completed encoding: other readers can see a partial file during that copy, but existing files are never truncated. A failed copy removes its newly created output.
Batch destinations, including codec-driven extensions and split tiles, are resolved before workers start. Conflicting outputs and outputs that alias another job's input are rejected; replacing a job's own input is supported. Validation resolves existing symlinks and file aliases and folds Windows/macOS path case conservatively. It cannot protect against unrelated processes changing path aliases after validation. Sequence padding is a minimum width: %03d matches both 001 and 1000, sorted numerically.
Pipe stdin/stdout
cat input.png | ffwebp -o out.jpg
# or
ffwebp < input.png > out.jpgForce output codec (if the output name has no or different extension)
ffwebp -i in.png -o out.any -c jpegQuality and lossless
# Lossy quality (0-100, defaults to 85)
ffwebp -i in.png -o out.webp -q 82
# Force lossless (overrides quality)
ffwebp -i in.png -o out.webp --losslessFor AVIF and JPEG XL, --lossless enables the encoder's explicit lossless mode. AVIF also forces alpha quality 100 and 4:4:4 chroma, overriding --avif.quality-alpha and --avif.chroma. Quality 100 alone is not a portable substitute for --lossless.
Thumbnails
# Create a thumbnail no larger than 256x256
ffwebp -i big.jpg -o thumb.webp -t 256Silence logs
ffwebp -i in.jpg -o out.png -s--split COLSxROWS writes tiles left to right, top to bottom. A %d output sequence numbers each tile, starting at --start-number (default 1). %02d pads with zeros to a minimum width of two; larger numbers are never truncated. With multiple inputs, numbering continues across inputs in their resolved order, regardless of worker completion order.
# image-01.jpeg, image-02.jpeg, image-03.jpeg
ffwebp --split 3x1 -i transmission.png "image-%02d.jpeg"
# tile-r00-c00.png, tile-r00-c01.png, tile-r01-c00.png, tile-r01-c01.png
ffwebp --split 2x2 -i image.png "tile-r{r:02d}-c{c:02d}.png"
# Keep each input's name and number its tiles from 00
ffwebp --split 3x1 -i "images/*.png" "out/{/.}-{i:02d}.png"
# Separate input numbering from tile numbering
ffwebp --split 3x1 -i "images/*.png" "out/input-{#:03d}-tile-{i:02d}.png"Each numeric placeholder has one fixed meaning:
| Pattern | Meaning |
|---|---|
%d / %02d |
Output file number, continuous across the entire command |
{#} / {#:02d} |
Input number, shared by every output from that input |
{i} / {i:02d} |
Tile index within one input, starting at 0 |
{r} / {r:02d} |
Tile row, starting at 0 |
{c} / {c:02d} |
Tile column, starting at 0 |
--start-numberaffects input and output sequences. Tile indices and coordinates reset for each input, remain zero-based and require--split.- All numeric placeholders accept decimal printf formatting:
%02dor{i:02d}for zero padding,%3dor{r:3d}for space padding and%-3dor{c:-3d}for left alignment. Signs and precision work too (%+03d,{#:03d},{i:.3d}). Width and precision are limited to 1,000. - Every explicit filename pattern is expanded as written, without added coordinate suffixes. Plain filenames such as
image.pngand directory outputs retain the automaticimage_r0_c0.pngnaming when splitting. - Patterns can combine filenames, input numbers, output numbers and tile coordinates. Duplicate destinations are rejected before writing files. For example, splitting into multiple tiles with
image-{#:02d}.pngfails because every tile from one input has the same input number; useimage-{#:02d}-{i:02d}.pngorimage-%02d.pnginstead.
Run ffwebp help patterns for the full list of filename placeholders and more examples.
Repeat -i to select files in order. Each quoted glob or %d sequence expands in place; numeric filename parts sort naturally (photo2 before photo10 and _r0_c2 before _r0_c10). Explicit paths keep their order and may be repeated. Positional arguments still specify the output, not additional inputs. Repeatable inputs also work for ordinary batch conversions.
# Join all inputs in one horizontal row (equivalent to --join auto or --join autox1)
ffwebp --join -i first.png -i second.png -i third.png strip.png
# Three images in a 2-column, 2-row grid; the bottom-right cell stays empty
ffwebp -i first.png -i second.png -i third.png --join 2x2 joined.png
# Three columns, enough rows for every matching image
ffwebp -i "tiles/*.png" --join 3xauto joined.png
# Mix explicit files and sequences; make a single horizontal strip
ffwebp -i cover.png -i "frames/%03d.png" --join autox1 strip.png
# Uniform cells, cropped to fill, with a white background
ffwebp -i "photos/*.jpg" --join 4xauto --join-cell 320x240 --join-mode cover --join-align top --join-background white contact-sheet.jpg
# Thumbnail and effects run on the completed grid
ffwebp -i left.png -i right.png --join 2x1 -t 800 joined.webp- Bare
--join,--join autoand--join autox1make one horizontal row.--join 1xautomakes one vertical column.--join COLSxROWSfills cells left to right, top to bottom, like--split. Either dimension may beauto, but not both. Fewer inputs leave background-filled cells; too many inputs produce an error suggesting a larger grid orauto. - By default, each column uses its widest source and each row its tallest source. Entirely empty columns or rows use the largest populated column width or row height.
--join-cell WIDTHxHEIGHTselects uniform pixel dimensions instead. --join-mode original(default) places images at their original size without cropping. An image larger than an explicit cell is an error.fitscales up or down to fit while preserving aspect ratio;coverscales to fill and crops the overflow;stretchscales to the exact cell size without preserving aspect ratio.--join-aligndefaults tocenter. It also acceptstop,bottom,left,right,top-left,top-right,bottom-leftandbottom-right. Alignment controls padding placement and which part of a cover image remains visible.--join-backgroundacceptstransparent(default),white,black,#RGB,#RGBA,#RRGGBBor#RRGGBBAA. Quote hex colors in shell commands. It fills padding and unused cells; transparent backgrounds are composited over white for output formats without alpha.- Animated inputs use their first frame unless
--frameor--timeselects another. Joining precedes thumbnails and effects.--playpreviews the processed canvas. - Joining requires one output filename or stdout (
-c png, for example); output directories and per-input patterns are rejected. The destination must not alias an input.--joinand--splitcannot be combined and a failed input fails the entire join before output is written. Stdin can be selected once with-i -. - Logs show the resolved order, zero-based row/column placements, sizing policy, final canvas dimensions and empty-cell count. Use
--silentto suppress them. By default, join grids are limited to 10,000 cells and canvases to 32 million pixels. The global--no-limitsswitch bypasses these safety caps and the 10,000-tile split cap, printing a warning even with--silent. Codec limits, valid dimensions and integer-overflow checks still apply. The join canvas uses 8 bytes per pixel, in addition to decoded inputs and processing buffers.
Grid values may also be attached (--join=2x2). A following output filename stays positional when the grid is omitted; use -o or -- to disambiguate an output name that itself looks like a grid. Flags requiring values report a missing value when followed by another option. For literal values beginning with a dash, use an equals sign (-i=-photo.png) or a relative path (-i ./-photo.png). Negative numeric values and - for stdin/stdout remain supported.
Each codec exposes its available options via namespaced flags (for example, --webp.method, --tiff.predictor, --psd.skip-merged). Run ffwebp --help to see all global and codec-specific flags for your build.
If --codec is omitted, the output codec is chosen from the output file extension. If the output filename has no extension, pass --codec.
- CUR output (
.curor--codec cur) uses a genuine type-2 cursor header and the encoder's default hotspot(0, 0). Input hotspots are not preserved. ICO output retains its type-1 icon header. - AVIF supports animated input and output, including
--frame,--timeand conversion to other animation-capable codecs. Frame durations are rounded to milliseconds. The pinned AVIF decoder does not expose loop counts, so decoded animations default to infinite looping. Its encoder cannot express single-play animations; those inputs produce an error instead of silently looping forever. - JPEG XL supports animated input and output, frame/time selection and effects. Rational frame ticks are rounded on the cumulative millisecond timeline to avoid timing drift; play-once, finite repeats and infinite loops are preserved. See
ffwebp --help jpegxlfor container, precision and opt-in JPEG reconstruction options. - HEIF/HEIC uses
github.com/gen2brain/h265/heicfor pure-Go decoding and encoding. Both.heifand.heicoutput HEIC still images with alpha support. Encoding uses 8-bit samples and 4:2:0 chroma with--quality;--losslessselects PCM coding and 4:4:4 chroma, but RGB-to-YCbCr conversion can still introduce rounding. Only the primary image is converted; image sequences are not exposed as animations. - PNG uses
github.com/gen2brain/pngn, preserving palette transparency, grayscale and 16-bit pixels with strict decoding defaults.--png.compressionremains0=none,1=default(the default),2=best speed,3=best compression. - APNG uses the same PNG adapter, flags and signature detection:
.png,.apngand--codec apngsupport animated input/output, frame/time extraction, thumbnails, effects and conversion to other animation-capable codecs. Static input produces an ordinary PNG, even with an.apngfilename. Decoded frames are already composited; a separate default PNG image is excluded from the animation. Encoding uses the first animation frame as the default image. Durations are converted from seconds to the nearest millisecond (half milliseconds round up), then back to seconds on output. Infinite looping, single playback and finite repetition counts are preserved by mapping APNG total plays to ffwebp's GIF-style repeat counts. The pinned encoder cannot represent every delay above 65.535 seconds; unsupported long delays produce an error instead of being silently shortened. - TIFF uses
github.com/hhrutter/tiff. Output supports uncompressed (--tiff.compression 0), Deflate (1, the default) and LZW (2).--tiff.predictorapplies only to Deflate and LZW. Input supports classic TIFF, including JPEG-compressed and CMYK images, CCITT RLE, Group 3 1-D (including byte alignment) and Group 4. Only the first document page is converted; pages are not animation frames. BigTIFF, Group 3 2-D and CCITT uncompressed modes are unsupported. JPEG and CCITT are decode-only compression modes. - DNG support extracts the embedded JPEG preview; it does not develop raw sensor data. Preview dimensions and quality can differ from the raw image and files without a supported JPEG preview cannot be converted. The adapter is included in
fullbuilds or with thedngbuild tag. - SVG rendering uses resvg's PNG-returning API. Supplying both
--svg.widthand--svg.heightrenders directly at that size. Supplying just one dimension preserves the intrinsic aspect ratio, which can require a preliminary render with the pinned renderer.
- Input sniffing: the input codec is detected by reading magic bytes; if you provide an input filename, its extension is considered.
- Output selection: the output codec is inferred from the destination extension or forced via
--codec. - Timing and sizes: ffwebp prints info like decode/encode timings and output size unless
--silentis set.
See the LICENSE file.