v7.1.2-34 Latest Stable Release

WebP Encoding Options

Comprehensive guide to WebP encoding parameters, default values, preset recommendations, and configuration options in ImageMagick.

quickstart.sh
# Install via your favorite Package Manager
$ brew install imagemagick
# Convert PNG to WebP with compression
$ magick input.png -quality 85 output.webp
# Resize image maintaining aspect ratio
$ magick input.jpg -resize 800x600^ output.jpg

ImageMagick's WebP image format accepts a plethora of encoding options to fine-tune compression, file size, and visual quality. Explore the default parameters, recommended scenario presets, and complete property reference below.

Default Encoding Options

When encoding WebP images without explicit parameters, ImageMagick initializes the following default values:

quality = 75
alpha-filtering = 1
alpha-quality = 100
autofilter = 0
filter-sharpness = 0
filter-strength = 60
lossless = 0
method = 4
pass = 1
preprocessing = 0
segments = 4
sns-strength = 50
target-psnr = 0
target-size = 0

Recommended Encoding Presets

Depending on the visual characteristics of your source images, consider applying these optimized configuration defines:

Digital Pictures

Portraits, indoor shots, and close-up photography.

portrait.cfg
-define webp:sns-strength=80
-define webp:filter-sharpness=4
-define webp:filter-strength=35
-define webp:preprocessing=0
Outdoor Photographs

Landscapes and natural lighting environments.

outdoor.cfg
-define webp:sns-strength=80
-define webp:filter-sharpness=3
-define webp:filter-strength=30
-define webp:preprocessing=2
Hand & Line Drawings

Illustrations featuring high-contrast details.

drawing.cfg
-define webp:sns-strength=25
-define webp:filter-sharpness=6
-define webp:filter-strength=10
Small Colorful Images

Icons, UI elements, and vibrant graphics.

colorful.cfg
-define webp:sns-strength=0
-define webp:filter-strength=0
-define webp:preprocessing=0
Text Images

Documents, screenshots, and text-heavy graphics.

text.cfg
-define webp:sns-strength=0
-define webp:filter-strength=0
-define webp:preprocessing=0
-define webp:segments=2

Complete WebP Option Reference

Here is a complete list of WebP encoding options available for fine-tuning via ImageMagick:

Option Description
alpha-compression=value Resamp the alpha plane: 0 = none, 1 = compressed.
alpha-filtering=value Predictive filtering method for alpha plane: 0=none, 1=fast, 2=best.
alpha-quality=value Compression value for alpha between 0 and 100. Lossless compression uses 100; lower values result in lossy compression (default: 100).
exact=true, false Preserve RGB values in transparent areas. Disabled by default to improve compressibility.
auto-filter=true, false When enabled, spends additional time optimizing filtering strength to reach a well-balanced quality.
emulate-jpeg-size=true, false Return compression similar to JPEG but with reduced degradation.
filter-sharpness=value Filter sharpness level.
filter-strength=value Strength of the deblocking filter, between 0 (off) and 100 (maximum). Higher values increase smoothing. Typical values range from 20 to 50.
filter-type=value Filter type: 0 = simple, 1 = strong.
image-hint=default, photo, picture, graph Hint regarding the source image type.
lossless=true, false Encode the image without any quality loss.
low-memory=true, false Reduce encoder memory consumption.
method=value Compression method controlling the tradeoff between encoding speed, file size, and quality (0 to 6, default: 4). Higher values inspect more possibilities.
preprocessing=value Preprocessing mode: 0 = none, 1 = segment-smooth, 2 = pseudo-random dithering.
partitions=value Progressive decoding partitions: choose 0 to 3.
partition-limit=value Quality degradation limit: 0 for no degradation, 100 for maximum degradation.
pass=value Maximum number of passes to reach target compression size or PSNR.
segments=value Maximum number of segments to use, ranging from 1 to 4.
show-compressed=true, false Display compressed output metrics.
sns-strength=value Amplitude of spatial noise shaping (SNS) algorithms used to distribute bits efficiently (0 to 100, default: 80).
target-size=value Target size in bytes for the compressed output. The compressor performs multiple passes to approach this goal.
target-psnr=value Desired minimal peak signal-to-noise ratio distortion.
thread-level=value Enable multi-threaded encoding: 0 = disabled, 1 = enabled.
use-sharp-yuv=value Use sharp and precise RGB-to-YUV conversion when needed.