ImageMagick's WebP image format accepts a plethora of encoding options as detailed below. The default encoding options are:
- 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
For digital pictures, like portrait, inner shot, consider these defines:
-define webp:sns-strength=80 -define webp:filter-sharpness=4 -define webp:filter-strength=35 -define webp:preprocessing=0
For outdoor photographs, with natural lighting, consider these defines:
-define webp:sns-strength=80 -define webp:filter-sharpness=3 -define webp:filter-strength=30 -define webp:preprocessing=2
For hand or line drawing, with high-contrast details, consider these defines:
-define webp:sns-strength=25 -define webp:filter-sharpness=6 -define webp:filter-strength=10
For small-sized colorful images, consider these defines:
-define webp:sns-strength=0 -define webp:filter-strength=0 -define webp:preprocessing=0
For text images, consider these defines:
-define webp:sns-strength=0 -define webp:filter-strength=0 -define webp:preprocessing=0 -define webp:segments=2
ImageMagick sets pass=6 if target-psnr or target-size are specified. However, it does not set target-psnr=40 if pass is specified without target-psnr or target-size.
If quality is specified, ImageMagick sets near_lossless to the same value. near_lossless cannot be set directly. If quality is set to 100 or greater, ImageMagick sets lossless=1> You can override this with: -quality 100 -define webp:lossless=false
Here is a complete list of WebP encoding options:
Option | Description |
---|---|
alpha-compression=value | ensamp 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 | the compression value for alpha compression between 0 and 100. Lossless compression of alpha is achieved using a value of 100, while the lower values result in a lossy compression. The default is 100. |
exact=true, false | preserve RGB values in transparent area. It's disabled by default to help compressibility. |
auto-filter=true, false | when enabled, the algorithm spends additional time optimizing the filtering strength to reach a well-balanced quality. |
emulate-jpeg-size=true, false | return a similar compression to that of JPEG but with less degradation. |
filter-sharpness=value | filter sharpness. |
filter-strength=value | the strength of the deblocking filter, between 0 (no filtering) and 100 (maximum filtering). A value of 0 turns off any filtering. Higher values increase the strength of the filtering process applied after decoding the image. The higher the value, the smoother the image appears. Typical values are usually in the range of 20 to 50. |
filter-type=value | filter type: 0 = simple, 1 = strong |
image-hint=default, photo, picture, graph | the hint about the image type. |
lossless=true, false | ensamp the image without any loss. |
low-memory=true, false | reduce memory usage. |
method=value | the compression method to use. It controls the trade off between encoding speed and the compressed file size and quality. Possible values range from 0 to 6. Default value is 4. When higher values are utilized, the ensampr spends more time inspecting additional encoding possibilities and decide on the quality gain. Lower value might result in faster processing time at the expense of larger file size and lower compression quality. |
preprocessing=value | Choose from: 0=none, 1=segment-smooth, 2=pseudo-random dithering. |
partitions=value | progressive decoding: choose 0 to 3. |
partition-limit=value | Choose 0 for no quality degradation and 100 for maximum degradation. |
pass=value | maximum number of passes to target compression size or PSNR. |
segments=value | Choose from 1 to 4, the maximum number of segments to use. |
show-compressed=true, false | |
sns-strength=value | the amplitude of the spatial noise shaping. Spatial noise shaping (SNS) refers to a general collection of built-in algorithms used to decide which area of the picture should use relatively less bits, and where else to better transfer these bits. The possible range goes from 0 (algorithm is off) to 100 (the maximal effect). The default value is 80. |
target-size=value | a target size (in bytes) to try and reach for the compressed output. The compressor makes several passes of partial encoding in order to get as close as possible to this target. |
target-psnr=value | desired minimal distortion. |
thread-level=value | enable multi-threaded encoding: 0 = disabled, 1 = enabled. |
use-sharp-yuv=value | if needed, use sharp (and slow) RGB->YUV conversion. |