LinuxCommandLibrary

gif2webp

Convert GIF images to WebP format

TLDR

Convert a GIF image to WebP

$ gif2webp [path/to/image.gif] -o [path/to/image.webp]
copy

SYNOPSIS

gif2webp [options] input_file.gif -o output_file.webp

PARAMETERS

input_file.gif
    The path to the input GIF file to be converted.

-o output_file.webp
    Specifies the path for the output WebP file. This option is mandatory.

-q <float>
    Specify the compression factor for RGB channels between 0 (low quality, small file) and 100 (high quality, large file). Default is 75.

-m <int>
    Specify the compression method to use, ranging from 0 (fastest, lowest compression) to 6 (slowest, best compression). Default is 4.

-lossy
    Encode using lossy compression. This is the default for animated GIFs.

-lossless
    Encode using lossless compression. This is the default for static GIFs.

-exact
    Preserve RGB values exactly during lossy compression. This is the default for static GIFs, but can be forced for animated ones.

-f <int>
    Specify the strength of the deblocking filter for lossy compression, between 0 (no filtering) and 100 (maximum filtering). Default is 0.

-min_size
    Encode for minimum size. This option often overrides other quality and compression settings to achieve the smallest possible file.

-kframes <int>
    Set the interval between key frames for animated WebP output. A value of 0 means no key frames are inserted, while 9999 means 1 keyframe per loop. Default is 9999.

-loop <int>
    Specify the number of times the animation should loop. 0 means infinite loop. Default is 0.

-mt
    Use multi-threading for encoding, potentially speeding up the conversion process on multi-core systems.

-v
    Enable verbose output, displaying conversion progress and statistics.

-h, -help
    Display help message and exit.

-version
    Display version information and exit.

DESCRIPTION

gif2webp is a command-line utility from the libwebp project, designed to convert GIF image files, including both static and animated GIFs, into the modern WebP image format. WebP offers significantly better compression than GIF, often resulting in smaller file sizes for equivalent image quality, which can dramatically improve website loading performance and reduce bandwidth consumption.

The tool allows users to specify various encoding options, such as quality factor, compression method, and whether to use lossy or lossless compression. For animated GIFs, it intelligently handles frame delays, loops, and keyframe intervals, translating them into an optimized animated WebP file. gif2webp is a crucial tool for web developers and content creators looking to optimize their visual assets for web delivery.

CAVEATS

While gif2webp generally produces smaller files, the optimal quality and file size balance for animated GIFs can require experimentation with options like -q, -m, and -kframes. Extremely complex or large source GIFs might still result in noticeable file sizes even after WebP conversion. The fidelity of color translation and frame timing can sometimes vary slightly depending on the chosen compression settings.

HISTORY

gif2webp is part of the libwebp software library, developed by Google, which introduced the WebP image format in 2010. The tool was specifically created to address the significant size of animated GIFs on the web, providing a more efficient, modern alternative. Its development has evolved with the WebP standard, incorporating improvements in compression algorithms and animation handling to ensure robust conversion of legacy GIF assets.

SEE ALSO

cwebp(1), dwebp(1), webpinfo(1), webpmux(1), convert(1)

Copied to clipboard