1CWEBP(1) General Commands Manual CWEBP(1)
2
3
4
6 cwebp - compress an image file to a WebP file
7
9 cwebp [options] input_file -o output_file.webp
10
12 This manual page documents the cwebp command.
13
14 cwebp compresses an image using the WebP format. Input format can be
15 either PNG, JPEG, TIFF, WebP or raw Y'CbCr samples. Note: Animated PNG
16 and WebP files are not supported.
17
19 The basic options are:
20
21 -o string
22 Specify the name of the output WebP file. If omitted, cwebp will
23 perform compression but only report statistics. Using "-" as
24 output name will direct output to 'stdout'.
25
26 -- string
27 Explicitly specify the input file. This option is useful if the
28 input file starts with a '-' for instance. This option must ap‐
29 pear last. Any other options afterward will be ignored.
30
31 -h, -help
32 A short usage summary.
33
34 -H, -longhelp
35 A summary of all the possible options.
36
37 -version
38 Print the version number (as major.minor.revision) and exit.
39
40 -lossless
41 Encode the image without any loss. For images with fully trans‐
42 parent area, the invisible pixel values (R/G/B or Y/U/V) will be
43 preserved only if the -exact option is used.
44
45 -near_lossless int
46 Specify the level of near-lossless image preprocessing. This op‐
47 tion adjusts pixel values to help compressibility, but has mini‐
48 mal impact on the visual quality. It triggers lossless compres‐
49 sion mode automatically. The range is 0 (maximum preprocessing)
50 to 100 (no preprocessing, the default). The typical value is
51 around 60. Note that lossy with -q 100 can at times yield better
52 results.
53
54 -q float
55 Specify the compression factor for RGB channels between 0 and
56 100. The default is 75.
57 In case of lossy compression (default), a small factor produces
58 a smaller file with lower quality. Best quality is achieved by
59 using a value of 100.
60 In case of lossless compression (specified by the -lossless op‐
61 tion), a small factor enables faster compression speed, but pro‐
62 duces a larger file. Maximum compression is achieved by using a
63 value of 100.
64
65 -z int Switch on lossless compression mode with the specified level be‐
66 tween 0 and 9, with level 0 being the fastest, 9 being the slow‐
67 est. Fast mode produces larger file size than slower ones. A
68 good default is -z 6. This option is actually a shortcut for
69 some predefined settings for quality and method. If options -q
70 or -m are subsequently used, they will invalidate the effect of
71 this option.
72
73 -alpha_q int
74 Specify the compression factor for alpha compression between 0
75 and 100. Lossless compression of alpha is achieved using a
76 value of 100, while the lower values result in a lossy compres‐
77 sion. The default is 100.
78
79 -preset string
80 Specify a set of pre-defined parameters to suit a particular
81 type of source material. Possible values are: default, photo,
82 picture, drawing, icon, text. Since -preset overwrites the other
83 parameters' values (except the -q one), this option should
84 preferably appear first in the order of the arguments.
85
86 -m int Specify the compression method to use. This parameter controls
87 the trade off between encoding speed and the compressed file
88 size and quality. Possible values range from 0 to 6. Default
89 value is 4. When higher values are used, the encoder will spend
90 more time inspecting additional encoding possibilities and de‐
91 cide on the quality gain. Lower value can result in faster pro‐
92 cessing time at the expense of larger file size and lower com‐
93 pression quality.
94
95 -resize width height
96 Resize the source to a rectangle with size width x height. If
97 either (but not both) of the width or height parameters is 0,
98 the value will be calculated preserving the aspect-ratio.
99
100 -crop x_position y_position width height
101 Crop the source to a rectangle with top-left corner at coordi‐
102 nates (x_position, y_position) and size width x height. This
103 cropping area must be fully contained within the source rectan‐
104 gle.
105
106 -mt Use multi-threading for encoding, if possible.
107
108 -low_memory
109 Reduce memory usage of lossy encoding by saving four times the
110 compressed size (typically). This will make the encoding slower
111 and the output slightly different in size and distortion. This
112 flag is only effective for methods 3 and up, and is off by de‐
113 fault. Note that leaving this flag off will have some side ef‐
114 fects on the bitstream: it forces certain bitstream features
115 like number of partitions (forced to 1). Note that a more de‐
116 tailed report of bitstream size is printed by cwebp when using
117 this option.
118
119
120 LOSSY OPTIONS
121 These options are only effective when doing lossy encoding (the de‐
122 fault, with or without alpha).
123
124
125 -size int
126 Specify a target size (in bytes) to try and reach for the com‐
127 pressed output. The compressor will make several passes of par‐
128 tial encoding in order to get as close as possible to this tar‐
129 get. If both -size and -psnr are used, -size value will prevail.
130
131 -psnr float
132 Specify a target PSNR (in dB) to try and reach for the com‐
133 pressed output. The compressor will make several passes of par‐
134 tial encoding in order to get as close as possible to this tar‐
135 get. If both -size and -psnr are used, -size value will prevail.
136
137 -pass int
138 Set a maximum number of passes to use during the dichotomy used
139 by options -size or -psnr. Maximum value is 10, default is 1.
140 If options -size or -psnr were used, but -pass wasn't specified,
141 a default value of '6' passes will be used.
142
143 -qrange int int
144 Specifies the permissible interval for the quality factor. This
145 is particularly useful when using multi-pass (-size or -psnr op‐
146 tions). Default is 0 100. If the quality factor is outside
147 this range, it will be clamped. If the minimum value must be
148 less or equal to the maximum one.
149
150 -af Turns auto-filter on. This algorithm will spend additional time
151 optimizing the filtering strength to reach a well-balanced qual‐
152 ity.
153
154 -jpeg_like
155 Change the internal parameter mapping to better match the ex‐
156 pected size of JPEG compression. This flag will generally pro‐
157 duce an output file of similar size to its JPEG equivalent (for
158 the same -q setting), but with less visual distortion.
159
160
161 Advanced options:
162
163
164 -f int Specify the strength of the deblocking filter, between 0 (no
165 filtering) and 100 (maximum filtering). A value of 0 will turn
166 off any filtering. Higher value will increase the strength of
167 the filtering process applied after decoding the picture. The
168 higher the value the smoother the picture will appear. Typical
169 values are usually in the range of 20 to 50.
170
171 -sharpness int
172 Specify the sharpness of the filtering (if used). Range is 0
173 (sharpest) to 7 (least sharp). Default is 0.
174
175 -strong
176 Use strong filtering (if filtering is being used thanks to the
177 -f option). Strong filtering is on by default.
178
179 -nostrong
180 Disable strong filtering (if filtering is being used thanks to
181 the -f option) and use simple filtering instead.
182
183 -sharp_yuv
184 Use more accurate and sharper RGB->YUV conversion if needed.
185 Note that this process is slower than the default 'fast'
186 RGB->YUV conversion.
187
188 -sns int
189 Specify the amplitude of the spatial noise shaping. Spatial
190 noise shaping (or sns for short) refers to a general collection
191 of built-in algorithms used to decide which area of the picture
192 should use relatively less bits, and where else to better trans‐
193 fer these bits. The possible range goes from 0 (algorithm is
194 off) to 100 (the maximal effect). The default value is 50.
195
196 -segments int
197 Change the number of partitions to use during the segmentation
198 of the sns algorithm. Segments should be in range 1 to 4. De‐
199 fault value is 4. This option has no effect for methods 3 and
200 up, unless -low_memory is used.
201
202 -partition_limit int
203 Degrade quality by limiting the number of bits used by some mac‐
204 roblocks. Range is 0 (no degradation, the default) to 100 (full
205 degradation). Useful values are usually around 30-70 for moder‐
206 ately large images. In the VP8 format, the so-called control
207 partition has a limit of 512k and is used to store the following
208 information: whether the macroblock is skipped, which segment it
209 belongs to, whether it is coded as intra 4x4 or intra 16x16
210 mode, and finally the prediction modes to use for each of the
211 sub-blocks. For a very large image, 512k only leaves room to
212 few bits per 16x16 macroblock. The absolute minimum is 4 bits
213 per macroblock. Skip, segment, and mode information can use up
214 almost all these 4 bits (although the case is unlikely), which
215 is problematic for very large images. The partition_limit factor
216 controls how frequently the most bit-costly mode (intra 4x4)
217 will be used. This is useful in case the 512k limit is reached
218 and the following message is displayed: Error code: 6 (PARTI‐
219 TION0_OVERFLOW: Partition #0 is too big to fit 512k). If using
220 -partition_limit is not enough to meet the 512k constraint, one
221 should use less segments in order to save more header bits per
222 macroblock. See the -segments option.
223
224
225 LOGGING OPTIONS
226 These options control the level of output:
227
228 -v Print extra information (encoding time in particular).
229
230 -print_psnr
231 Compute and report average PSNR (Peak-Signal-To-Noise ratio).
232
233 -print_ssim
234 Compute and report average SSIM (structural similarity metric,
235 see https://en.wikipedia.org/wiki/SSIM for additional details).
236
237 -print_lsim
238 Compute and report local similarity metric (sum of lowest error
239 amongst the collocated pixel neighbors).
240
241 -progress
242 Report encoding progress in percent.
243
244 -quiet Do not print anything.
245
246 -short Only print brief information (output file size and PSNR) for
247 testing purposes.
248
249 -map int
250 Output additional ASCII-map of encoding information. Possible
251 map values range from 1 to 6. This is only meant to help debug‐
252 ging.
253
254
255 ADDITIONAL OPTIONS
256 More advanced options are:
257
258 -s width height
259 Specify that the input file actually consists of raw Y'CbCr sam‐
260 ples following the ITU-R BT.601 recommendation, in 4:2:0 linear
261 format. The luma plane has size width x height.
262
263 -pre int
264 Specify some preprocessing steps. Using a value of '2' will
265 trigger quality-dependent pseudo-random dithering during
266 RGBA->YUVA conversion (lossy compression only).
267
268 -alpha_filter string
269 Specify the predictive filtering method for the alpha plane. One
270 of 'none', 'fast' or 'best', in increasing complexity and slow‐
271 ness order. Default is 'fast'. Internally, alpha filtering is
272 performed using four possible predictions (none, horizontal,
273 vertical, gradient). The 'best' mode will try each mode in turn
274 and pick the one which gives the smaller size. The 'fast' mode
275 will just try to form an a priori guess without testing all
276 modes.
277
278 -alpha_method int
279 Specify the algorithm used for alpha compression: 0 or 1. Algo‐
280 rithm 0 denotes no compression, 1 uses WebP lossless format for
281 compression. The default is 1.
282
283 -exact Preserve RGB values in transparent area. The default is off, to
284 help compressibility.
285
286 -blend_alpha int
287 This option blends the alpha channel (if present) with the
288 source using the background color specified in hexadecimal as
289 0xrrggbb. The alpha channel is afterward reset to the opaque
290 value 255.
291
292 -noalpha
293 Using this option will discard the alpha channel.
294
295 -hint string
296 Specify the hint about input image type. Possible values are:
297 photo, picture or graph.
298
299 -metadata string
300 A comma separated list of metadata to copy from the input to the
301 output if present. Valid values: all, none, exif, icc, xmp.
302 The default is none.
303
304 Note: each input format may not support all combinations.
305
306 -noasm Disable all assembly optimizations.
307
308
310 Please report all bugs to the issue tracker:
311 https://bugs.chromium.org/p/webp
312 Patches welcome! See this page to get started: https://www.webmpro‐
313 ject.org/code/contribute/submitting-patches/
314
315
317 cwebp -q 50 -lossless picture.png -o picture_lossless.webp
318 cwebp -q 70 picture_with_alpha.png -o picture_with_alpha.webp
319 cwebp -sns 70 -f 50 -size 60000 picture.png -o picture.webp
320 cwebp -o picture.webp -- ---picture.png
321
322
324 cwebp is a part of libwebp and was written by the WebP team.
325 The latest source tree is available at https://chromium.google‐
326 source.com/webm/libwebp
327
328 This manual page was written by Pascal Massimino <pascal.mas‐
329 simino@gmail.com>, for the Debian project (and may be used by others).
330
331
333 dwebp(1), gif2webp(1)
334 Please refer to https://developers.google.com/speed/webp/ for addi‐
335 tional information.
336
337
338
339 November 17, 2021 CWEBP(1)