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