CWEBP(1)
π CWEBP(1) β General Commands Manual π
okay bestie, sit down, hydrate, because we're about to learn cwebp and it's genuinely iconic β¨ this is the cwebp manual page, she's a General Commands Manual girlie, and she's about to teach you how to turn your pics into WebP files π
πΈ NAME πΈ
cwebp β compress an image file to a WebP file π¦
π SYNOPSIS π
cwebp [options] input_file -o output_file.webp
like. that's it. that's the whole vibe. input in, options sprinkled, WebP out π
β¨ DESCRIPTION β¨
This manual page documents the cwebp command, fr fr.
cwebp compresses an image using the WebP format. The input format can be either PNG, JPEG, TIFF, WebP or raw Y'CbCr samples β pick your fighter π«Ά
π¨ NOT ME FORGETTING TO MENTION: Animated PNG and WebP files are not supported. like, at all. don't come for her, she said what she said π
π OPTIONS π
The basic options are, and I'm obsessed with all of them:
-o stringβ Specify the name of the output WebP file. If you skip it,cwebpwill still perform compression but only report statistics. And if you use"-"as the output name, output gets directed to'stdout'β¨-- stringβ Explicitly specify the input file. Super useful if your input file starts with a-for instance (chaotic of it). This option must appear last. Any other options after it will be ignored, periodt π-h,-helpβ A short usage summary. The little snack. π-H,-longhelpβ A summary of all the possible options. The full meal. π-versionβ Print the version number (asmajor.minor.revision) and exit. She's brief, she's efficient, she ate.-losslessβ Encode the image without any loss. For images with fully transparent area, the invisible pixel values (R/G/B or Y/U/V) will be preserved only if the-exactoption is used π-near_lossless intβ Specify the level of near-lossless image preprocessing. This option adjusts pixel values to help compressibility, but has minimal impact on the visual quality. It triggers lossless compression mode automatically. The range is0(maximum preprocessing) to100(no preprocessing, the default). The typical value is around60. Note that lossy with-q 100can at times yield better results π-q floatβ Specify the compression factor for RGB channels between0and100. The default is75. In case of lossy compression (default), a small factor produces a smaller file with lower quality. Best quality is achieved by using a value of100. In case of lossless compression (specified by the-losslessoption), a small factor enables faster compression speed, but produces a larger file. Maximum compression is achieved by using a value of100. (yes the same number does different things depending on the mode, that's just her duality π )-z intβ Switch on lossless compression mode with the specified level between0and9, with level0being the fastest,9being the slowest. Fast mode produces larger file size than slower ones. A good default is-z 6. This option is actually a shortcut for some predefined settings for quality and method. If options-qor-mare subsequently used, they will invalidate the effect of this option π«-alpha_q intβ Specify the compression factor for alpha compression between0and100. Lossless compression of alpha is achieved using a value of100, while the lower values result in a lossy compression. The default is100.-preset stringβ Specify a set of pre-defined parameters to suit a particular type of source material. Possible values are:default,photo,picture,drawing,icon,text. Since-presetoverwrites the other parameters' values (except the-qone), this option should preferably appear first in the order of the arguments π-m intβ Specify the compression method to use. This parameter controls the trade off between encoding speed and the compressed file size and quality. Possible values range from0to6. Default value is4. When higher values are used, the encoder will spend more time inspecting additional encoding possibilities and decide on the quality gain. Lower value can result in faster processing time at the expense of larger file size and lower compression quality βοΈ-crop x_position y_position width heightβ Crop the source to a rectangle with top-left corner at coordinates (x_position,y_position) and sizewidthxheight. This cropping area must be fully contained within the source rectangle. Note: the cropping is applied before any scaling βοΈ-resize width heightβ Resize the source to a rectangle with sizewidthxheight. If either (but not both) of the width or height parameters is0, the value will be calculated preserving the aspect-ratio. Note: scaling is applied after cropping π¦-resize_mode stringβ Specify the behavior of the-resizeoption. Possible values are:down_only,up_only,always(default).down_onlywill use the values specified by-resizeif either the input width or height are larger than the given dimensions. Similarly,up_onlywill only resize if either the input width or height are smaller than the given dimensions ποΈ-mtβ Use multi-threading for encoding, if possible. more cores more slay π₯-low_memoryβ Reduce memory usage of lossy encoding by saving four times the compressed size (typically). This will make the encoding slower and the output slightly different in size and distortion. This flag is only effective for methods3and up, and is off by default. Note that leaving this flag off will have some side effects on the bitstream: it forces certain bitstream features like number of partitions (forced to1). Note that a more detailed report of bitstream size is printed bycwebpwhen using this option π§
π LOSSY OPTIONS π
These options are only effective when doing lossy encoding (the default, with or without alpha). iykyk π
-size intβ Specify a target size (in bytes) to try and reach for the compressed output. The compressor will make several passes of partial encoding in order to get as close as possible to this target. If both-sizeand-psnrare used,-sizevalue will prevail π-psnr floatβ Specify a target PSNR (in dB) to try and reach for the compressed output. The compressor will make several passes of partial encoding in order to get as close as possible to this target. If both-sizeand-psnrare used,-sizevalue will prevail.-pass intβ Set a maximum number of passes to use during the dichotomy used by options-sizeor-psnr. Maximum value is10, default is1. If options-sizeor-psnrwere used, but-passwasn't specified, a default value of'6'passes will be used. If-passis specified, but neither-sizenor-psnrare, a target PSNR of40dBwill be used π-qrange int intβ Specifies the permissible interval for the quality factor. This is particularly useful when using multi-pass (-sizeor-psnroptions). Default is0 100. If the quality factor is outside this range, it will be clamped. If the minimum value must be less or equal to the maximum one. π-afβ Turns auto-filter on. This algorithm will spend additional time optimizing the filtering strength to reach a well-balanced quality β¨-jpeg_likeβ Change the internal parameter mapping to better match the expected size of JPEG compression. This flag will generally produce an output file of similar size to its JPEG equivalent (for the same-qsetting), but with less visual distortion πΌοΈ
Advanced options:
-f intβ Specify the strength of the deblocking filter, between0(no filtering) and100(maximum filtering). A value of0will turn off any filtering. Higher value will increase the strength of the filtering process applied after decoding the picture. The higher the value the smoother the picture will appear. Typical values are usually in the range of20to50π§΄-sharpness intβ Specify the sharpness of the filtering (if used). Range is0(sharpest) to7(least sharp). Default is0πͺ-strongβ Use strong filtering (if filtering is being used thanks to the-foption). Strong filtering is on by default πͺ-nostrongβ Disable strong filtering (if filtering is being used thanks to the-foption) and use simple filtering instead π-sharp_yuvβ Use more accurate and sharper RGB->YUV conversion. Note that this process is slower than the default'fast'RGB->YUV conversion β‘-sns intβ Specify the amplitude of the spatial noise shaping. Spatial noise shaping (orsnsfor short) 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 from0(algorithm is off) to100(the maximal effect). The default value is50ποΈ-segments intβ Change the number of partitions to use during the segmentation of thesnsalgorithm. Segments should be in range1to4. Default value is4. This option has no effect for methods3and up, unless-low_memoryis used π§©-partition_limit intβ Degrade quality by limiting the number of bits used by some macroblocks. Range is0(no degradation, the default) to100(full degradation). Useful values are usually around30-70for moderately large images. In the VP8 format, the so-called control partition has a limit of512kand is used to store the following information: whether the macroblock is skipped, which segment it belongs to, whether it is coded as intra4x4or intra16x16mode, and finally the prediction modes to use for each of the sub-blocks. For a very large image,512konly leaves room for a few bits per16x16macroblock. The absolute minimum is4bits per macroblock. Skip, segment, and mode information can use up almost all these4bits (although the case is unlikely), which is problematic for very large images. Thepartition_limitfactor controls how frequently the most bit-costly mode (intra4x4) will be used. This is useful in case the512klimit is reached and the following message is displayed:
Error code: 6 (PARTITION0_OVERFLOW: Partition #0 is too big to fit 512k).
If using -partition_limit is not enough to meet the 512k constraint, one should use less segments in order to save more header bits per macroblock. See the -segments option. Note the -m and -q options also influence the encoder's decisions and ability to hit this limit π
π LOGGING OPTIONS π
These options control the level of output:
-vβ Print extra information (encoding time in particular) β±οΈ-print_psnrβ Compute and report average PSNR (Peak-Signal-To-Noise ratio) π-print_ssimβ does the math and reports the average SSIM (that's the structural similarity metric, and yeah there's a whole Wikipedia page on it: https://en.wikipedia.org/wiki/SSIM if you wanna go down that rabbit hole π¦).-print_lsimβ computes and reports the local similarity metric, which is the sum of the lowest error amongst the collocated pixel neighbors. fancy π-progressβ reports encoding progress in percent, so you can watch the little number go up π-quietβ do not print anything. silence. peace. π€«-shortβ only prints brief info (output file size and PSNR) for testing purposes.-mapint β outputs an extra ASCII-map of encoding information. Possible map values range from 1 to 6. ngl this one is literally only meant to help debugging, it's not for the general public π§
β¨ ADDITIONAL OPTIONS β¨
okay so these are the more advanced ones, bestie. buckle up π
-swidth height β tells cwebp that your input file is actually made of raw Y'CbCr samples following the ITU-R BT.601 recommendation, in 4:2:0 linear format. The luma plane has size width x height.-preint β sets some preprocessing steps. If you pass a value of'2', it'll trigger quality-dependent pseudo-random dithering during RGBA->YUVA conversion (lossy compression only, so heads up π).-alpha_filterstring β picks the predictive filtering method for the alpha plane. Options are'none','fast'or'best', listed in increasing complexity and slowness order. Default is'fast'. Internally, alpha filtering runs using four possible predictions (none, horizontal, vertical, gradient). The'best'mode will try each mode in turn and pick whichever gives the smaller size. The'fast'mode just tries to form an a priori guess without testing all the modes. lowkey efficient β¨-alpha_methodint β picks the algorithm used for alpha compression:0or1. Algorithm0means no compression,1uses WebP lossless format for compression. The default is1.-exactβ preserves RGB values in transparent areas. The default is off, because leaving it off helps compressibility.-blend_alphaint β this option blends the alpha channel (if present) with the source using the background color you specify in hexadecimal as0xrrggbb. The alpha channel is afterward reset to the opaque value255.-noalphaβ using this option will discard the alpha channel. gone. bye. π-hintstring β gives a hint about the input image type. Possible values are:photo,pictureorgraph.-metadatastring β a comma separated list of metadata to copy from the input to the output if present. Valid values:all,none,exif,icc,xmp. The default isnone.
Note: each input format may not support all combinations. so don't come for cwebp when your format doesn't have that metadata, bestie π
-noasmβ disables all assembly optimizations. π
π EXIT STATUS π
If there were no problems during execution, cwebp exits with the value of the C constant EXIT_SUCCESS. This is usually zero. slay, no notes π
If an error occurs, cwebp exits with the value of the C constant EXIT_FAILURE. This is usually one. π
πΈ EXAMPLES πΈ
here's the vibe, copy these directly:
cwebp -q 50 -lossless picture.png -o picture_lossless.webp
cwebp -q 70 picture_with_alpha.png -o picture_with_alpha.webp
cwebp -sns 70 -f 50 -size 60000 picture.png -o picture.webp
cwebp -o picture.webp -- ---picture.png
π AUTHORS π
cwebp is a part of libwebp and was written by the WebP team.
The latest source tree is available at https://chromium.googlesource.com/webm/libwebp
This manual page was written by Pascal Massimino <pascal.massimino@gmail.com>, for the Debian project (and may be used by others).
π«Ά REPORTING BUGS π«Ά
Please report all bugs to the issue tracker: https://issues.webmproject.org
Patches welcome! See this page to get started: https://www.webmproject.org/code/contribute/submitting-patches/
β SEE ALSO β
Please refer to https://developers.google.com/speed/webp/ for additional information.
and that's the whole page, bestie π β¨ this one comes from the libwebp source tree and it's dated April 10, 2025 β go forth and encode, you absolute icon ππ¦
π¦ where this page comes from
- alpine 3.23: libwebp-doc 1.6.0-r0 Β· BSD-3-Clause
- alpine 3.24: libwebp-doc 1.6.0-r0 Β· BSD-3-Clause
- arch rolling: libwebp 1.6.0-2 Β· BSD-3-Clause
- fedora 43: libwebp-tools 1.6.0-2.fc43 Β· Apache-2.0 AND LicenseRef-scancode-google-patent-license-webm AND BSD-3-Clause AND FSFULLRWD
- fedora 44: libwebp-tools 1.6.0-3.fc44 Β· Apache-2.0 AND BSD-3-Clause WITH AdditionRef-WebM-patent-license AND BSD-3-Clause AND FSFULLRWD
- nixos 26.05: libwebp 1.6.0
- nixpkgs unstable: libwebp 1.6.0
- ubuntu stonking: webp 1.6.0-0.1 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms