webpmux
Create animated WebP images
TLDR
Create a two-frame animation
SYNOPSIS
webpmux [options] input_webp -o output_webp
webpmux -get type input_webp -o output_file
webpmux -set type source_file input_webp -o output_webp
webpmux -frame frame_options... -o output_webp
PARAMETERS
-h, -help
Displays a concise help message with available options.
-version
Prints the webpmux version number.
-v, -verbose
Enables verbose output, showing more details about the operation's progress.
-o file
Specifies the output file path for the processed WebP image or extracted data.
-get type
Extracts a specific chunk from the input WebP file. type can be 'icc' (ICC profile), 'exif' (EXIF data), 'xmp' (XMP metadata), 'frame' (a specific frame from an animation), or 'alpha' (alpha channel).
-set type source_file
Sets or replaces a specific chunk in the WebP file with data from source_file. type can be 'icc', 'exif', 'xmp', or 'alpha'.
-strip type
Removes a specific chunk from the WebP file. type can be 'icc', 'exif', 'xmp', or 'alpha'.
-frame file [options]
Adds an input WebP file as a frame to an animated WebP. This option can be used multiple times to add successive frames.
Sub-options include: -duration ms (frame duration), -xy x y (frame offset), -blend (blend with previous canvas), -no_blend (replace canvas), -dispose (dispose frame before next), -no_dispose (do not dispose).
-loop loops
Sets the number of times the animation should loop. A value of 0 means infinite looping.
-duration ms
Sets the default duration for all frames in the animation, in milliseconds (ms). This can be overridden per-frame using -frame's -duration option.
-bgcolor A,R,G,B
Specifies the background color of the canvas for transparent pixels, in alpha-red-green-blue format (e.g., '255,0,0,0' for opaque black).
-minimize_size
Attempts to optimize the output file size by adjusting animated WebP specific properties like frame disposal and blending methods.
-kmin num
Sets the minimum number of frames per key-frame group (for animated WebP inter-frame compression). Default is 3.
-kmax num
Sets the maximum number of frames per key-frame group (for animated WebP inter-frame compression). Default is 9.
DESCRIPTION
webpmux is a command-line utility from the libwebp project, designed for multiplexing WebP images. Its primary function is to combine multiple WebP images into an animated WebP file, allowing users to specify frame durations and loop counts. Beyond animation, webpmux is also invaluable for adding or extracting various types of metadata, such as ICC profiles, EXIF data, and XMP metadata, directly to or from WebP image files. It can also manage the alpha channel (transparency) within WebP images. This tool provides granular control over the WebP format, making it essential for advanced WebP manipulation beyond simple compression. It operates by taking an input WebP file (or multiple for animation) and an output file, applying the specified operations.
CAVEATS
webpmux primarily operates on WebP formatted input files. Other image formats (like PNG, JPEG) must first be converted to WebP using tools like cwebp(1) or img2webp(1) before being used as frames for animation. When creating animations, ensuring consistent dimensions or carefully managing frame offsets with -xy is crucial to avoid unexpected visual artifacts. Processing very large numbers of frames or high-resolution images can be memory-intensive.
KEY USE CASES
webpmux excels in several scenarios, providing fine-grained control over WebP files:
1. Creating Animated WebP: Combine a series of static WebP images into a single animated WebP file, with precise control over frame durations, looping, and canvas behavior.
2. Embedding Metadata: Add or update crucial metadata like ICC color profiles, EXIF data (e.g., camera settings), and XMP metadata (e.g., copyright information) directly into WebP images.
3. Extracting Data Chunks: Extract specific data chunks (metadata, alpha channel, or individual frames) from existing WebP files for inspection, modification, or reuse without affecting the image data itself.
HISTORY
webpmux is an integral part of the libwebp library, a free, open-source library developed by Google. It was introduced to provide robust capabilities for manipulating the WebP container format, specifically addressing the need for animation support and the inclusion/extraction of metadata. Its development parallels the evolution of the WebP format itself, aiming to make WebP a more versatile and feature-rich image format for the web.