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 -crop x_position y_position width height
96 Crop the source to a rectangle with top-left corner at coordi‐
97 nates (x_position, y_position) and size width x height. This
98 cropping area must be fully contained within the source rectan‐
99 gle. Note: the cropping is applied before any scaling.
100
101 -resize width height
102 Resize the source to a rectangle with size width x height. If
103 either (but not both) of the width or height parameters is 0,
104 the value will be calculated preserving the aspect-ratio. Note:
105 scaling is applied after cropping.
106
107 -mt Use multi-threading for encoding, if possible.
108
109 -low_memory
110 Reduce memory usage of lossy encoding by saving four times the
111 compressed size (typically). This will make the encoding slower
112 and the output slightly different in size and distortion. This
113 flag is only effective for methods 3 and up, and is off by de‐
114 fault. Note that leaving this flag off will have some side ef‐
115 fects on the bitstream: it forces certain bitstream features
116 like number of partitions (forced to 1). Note that a more de‐
117 tailed report of bitstream size is printed by cwebp when using
118 this option.
119
120
121 LOSSY OPTIONS
122 These options are only effective when doing lossy encoding (the de‐
123 fault, with or without alpha).
124
125
126 -size int
127 Specify a target size (in bytes) to try and reach for the com‐
128 pressed output. The compressor will make several passes of par‐
129 tial encoding in order to get as close as possible to this tar‐
130 get. If both -size and -psnr are used, -size value will prevail.
131
132 -psnr float
133 Specify a target PSNR (in dB) to try and reach for the com‐
134 pressed output. The compressor will make several passes of par‐
135 tial encoding in order to get as close as possible to this tar‐
136 get. If both -size and -psnr are used, -size value will prevail.
137
138 -pass int
139 Set a maximum number of passes to use during the dichotomy used
140 by options -size or -psnr. Maximum value is 10, default is 1.
141 If options -size or -psnr were used, but -pass wasn't specified,
142 a default value of '6' passes will be used.
143
144 -qrange int int
145 Specifies the permissible interval for the quality factor. This
146 is particularly useful when using multi-pass (-size or -psnr op‐
147 tions). Default is 0 100. If the quality factor is outside
148 this range, it will be clamped. If the minimum value must be
149 less or equal to the maximum one.
150
151 -af Turns auto-filter on. This algorithm will spend additional time
152 optimizing the filtering strength to reach a well-balanced qual‐
153 ity.
154
155 -jpeg_like
156 Change the internal parameter mapping to better match the ex‐
157 pected size of JPEG compression. This flag will generally pro‐
158 duce an output file of similar size to its JPEG equivalent (for
159 the same -q setting), but with less visual distortion.
160
161
162 Advanced options:
163
164
165 -f int Specify the strength of the deblocking filter, between 0 (no
166 filtering) and 100 (maximum filtering). A value of 0 will turn
167 off any filtering. Higher value will increase the strength of
168 the filtering process applied after decoding the picture. The
169 higher the value the smoother the picture will appear. Typical
170 values are usually in the range of 20 to 50.
171
172 -sharpness int
173 Specify the sharpness of the filtering (if used). Range is 0
174 (sharpest) to 7 (least sharp). Default is 0.
175
176 -strong
177 Use strong filtering (if filtering is being used thanks to the
178 -f option). Strong filtering is on by default.
179
180 -nostrong
181 Disable strong filtering (if filtering is being used thanks to
182 the -f option) and use simple filtering instead.
183
184 -sharp_yuv
185 Use more accurate and sharper RGB->YUV conversion if needed.
186 Note that this process is slower than the default 'fast'
187 RGB->YUV conversion.
188
189 -sns int
190 Specify the amplitude of the spatial noise shaping. Spatial
191 noise shaping (or sns for short) refers to a general collection
192 of built-in algorithms used to decide which area of the picture
193 should use relatively less bits, and where else to better trans‐
194 fer these bits. The possible range goes from 0 (algorithm is
195 off) to 100 (the maximal effect). The default value is 50.
196
197 -segments int
198 Change the number of partitions to use during the segmentation
199 of the sns algorithm. Segments should be in range 1 to 4. De‐
200 fault value is 4. This option has no effect for methods 3 and
201 up, unless -low_memory is used.
202
203 -partition_limit int
204 Degrade quality by limiting the number of bits used by some mac‐
205 roblocks. Range is 0 (no degradation, the default) to 100 (full
206 degradation). Useful values are usually around 30-70 for moder‐
207 ately large images. In the VP8 format, the so-called control
208 partition has a limit of 512k and is used to store the following
209 information: whether the macroblock is skipped, which segment it
210 belongs to, whether it is coded as intra 4x4 or intra 16x16
211 mode, and finally the prediction modes to use for each of the
212 sub-blocks. For a very large image, 512k only leaves room to
213 few bits per 16x16 macroblock. The absolute minimum is 4 bits
214 per macroblock. Skip, segment, and mode information can use up
215 almost all these 4 bits (although the case is unlikely), which
216 is problematic for very large images. The partition_limit factor
217 controls how frequently the most bit-costly mode (intra 4x4)
218 will be used. This is useful in case the 512k limit is reached
219 and the following message is displayed: Error code: 6 (PARTI‐
220 TION0_OVERFLOW: Partition #0 is too big to fit 512k). If using
221 -partition_limit is not enough to meet the 512k constraint, one
222 should use less segments in order to save more header bits per
223 macroblock. See the -segments option.
224
225
226 LOGGING OPTIONS
227 These options control the level of output:
228
229 -v Print extra information (encoding time in particular).
230
231 -print_psnr
232 Compute and report average PSNR (Peak-Signal-To-Noise ratio).
233
234 -print_ssim
235 Compute and report average SSIM (structural similarity metric,
236 see https://en.wikipedia.org/wiki/SSIM for additional details).
237
238 -print_lsim
239 Compute and report local similarity metric (sum of lowest error
240 amongst the collocated pixel neighbors).
241
242 -progress
243 Report encoding progress in percent.
244
245 -quiet Do not print anything.
246
247 -short Only print brief information (output file size and PSNR) for
248 testing purposes.
249
250 -map int
251 Output additional ASCII-map of encoding information. Possible
252 map values range from 1 to 6. This is only meant to help debug‐
253 ging.
254
255
256 ADDITIONAL OPTIONS
257 More advanced options are:
258
259 -s width height
260 Specify that the input file actually consists of raw Y'CbCr sam‐
261 ples following the ITU-R BT.601 recommendation, in 4:2:0 linear
262 format. The luma plane has size width x height.
263
264 -pre int
265 Specify some preprocessing steps. Using a value of '2' will
266 trigger quality-dependent pseudo-random dithering during
267 RGBA->YUVA conversion (lossy compression only).
268
269 -alpha_filter string
270 Specify the predictive filtering method for the alpha plane. One
271 of 'none', 'fast' or 'best', in increasing complexity and slow‐
272 ness order. Default is 'fast'. Internally, alpha filtering is
273 performed using four possible predictions (none, horizontal,
274 vertical, gradient). The 'best' mode will try each mode in turn
275 and pick the one which gives the smaller size. The 'fast' mode
276 will just try to form an a priori guess without testing all
277 modes.
278
279 -alpha_method int
280 Specify the algorithm used for alpha compression: 0 or 1. Algo‐
281 rithm 0 denotes no compression, 1 uses WebP lossless format for
282 compression. The default is 1.
283
284 -exact Preserve RGB values in transparent area. The default is off, to
285 help compressibility.
286
287 -blend_alpha int
288 This option blends the alpha channel (if present) with the
289 source using the background color specified in hexadecimal as
290 0xrrggbb. The alpha channel is afterward reset to the opaque
291 value 255.
292
293 -noalpha
294 Using this option will discard the alpha channel.
295
296 -hint string
297 Specify the hint about input image type. Possible values are:
298 photo, picture or graph.
299
300 -metadata string
301 A comma separated list of metadata to copy from the input to the
302 output if present. Valid values: all, none, exif, icc, xmp.
303 The default is none.
304
305 Note: each input format may not support all combinations.
306
307 -noasm Disable all assembly optimizations.
308
309
311 Please report all bugs to the issue tracker:
312 https://bugs.chromium.org/p/webp
313 Patches welcome! See this page to get started: https://www.webmpro‐
314 ject.org/code/contribute/submitting-patches/
315
316
318 cwebp -q 50 -lossless picture.png -o picture_lossless.webp
319 cwebp -q 70 picture_with_alpha.png -o picture_with_alpha.webp
320 cwebp -sns 70 -f 50 -size 60000 picture.png -o picture.webp
321 cwebp -o picture.webp -- ---picture.png
322
323
325 cwebp is a part of libwebp and was written by the WebP team.
326 The latest source tree is available at https://chromium.google‐
327 source.com/webm/libwebp
328
329 This manual page was written by Pascal Massimino <pascal.mas‐
330 simino@gmail.com>, for the Debian project (and may be used by others).
331
332
334 dwebp(1), gif2webp(1)
335 Please refer to https://developers.google.com/speed/webp/ for addi‐
336 tional information.
337
338
339
340 March 17, 2022 CWEBP(1)