go-libwebp

Experimental translation from libwebp to Go source.
Log | Files | Refs | README | LICENSE

cwebp.1 (14132B)


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