Go to main content

man pages section 1: User Commands

Exit Print View

Updated: Thursday, June 13, 2019

cwebp (1)


cwebp - compress an image file to a WebP file


cwebp [options] input_file -o output_file.webp


CWEBP(1)                    General Commands Manual                   CWEBP(1)

       cwebp - compress an image file to a WebP file

       cwebp [options] input_file -o output_file.webp

       This manual page documents the cwebp command.


       The basic options are:

       -o string
              perform  compression  but  only report statistics.  Using "-" as
              output name will direct output to 'stdout'.

       -- string
              Explicitly specify the input file. This option is useful if  the
              appear last.  Any other options afterward will be ignored.

       -h, -help
              A short usage summary.

       -H, -longhelp
              A summary of all the possible options.

              Print the version number (as major.minor.revision) and exit.

              Encode the image without any loss. For images with fully  trans-
              preserved only if the -exact option is used.

       -near_lossless int
              Use 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 automati-
              cally.   Range  is  0 (maximum preprocessing) to 100 (no prepro-
              cessing, the default).

       -q float
              Specify the compression factor for RGB channels  between  0  and
              100. The default is 75.
              a smaller file with lower quality. Best quality is  achieved  by
              using a value of 100.
              In  case  of  lossless  compression  (specified by the -lossless
              option), a small factor enables faster  compression  speed,  but
              produces  a  larger  file.   Maximum  compression is achieved by
              using a value of 100.

       -z int Switch on lossless compression mode  with  the  specified  level
              some predefined settings for quality and method. If  options  -q
              this option.

       -alpha_q int
              Specify the compression factor for alpha compression  between  0
              and  100.   Lossless  compression  of  alpha is achieved using a
              value of 100, while the lower values result in a lossy  compres-
              sion. The default is 100.

       -preset string
              Specify  a  set  of  pre-defined parameters to suit a particular
              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
              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.

       -resize width height
              the value will be calculated preserving the aspect-ratio.

       -crop x_position y_position width height
              Crop the source to a rectangle with top-left corner  at  coordi-
              nates  (x_position,  y_position)  and size width x height.  This
              cropping area must be fully contained within the source  rectan-

       -mt    Use multi-threading for encoding, if possible.

              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
              default.  Note  that  leaving  this flag off will have some side
              effects on the bitstream: it forces certain  bitstream  features
              detailed report of bitstream size is printed by cwebp when using
              this option.

       These  options  are  only  effective  when  doing  lossy  encoding (the
       default, with or without alpha).

       -size int
              Specify a target size (in bytes) to try and reach for  the  com-
              pressed output.  The compressor will make several passes of par-
              tial encoding in order to get as close as possible to this  tar-

       -psnr float
              Specify  a  target  PSNR  (in  dB) to try and reach for the com-
              pressed output.  The compressor will make several passes of par-

       -pass int
              Set a maximum number of passes to use during the dichotomy  used
              a default value of '6' passes will be used.

       -af    Turns  auto-filter on. This algorithm will spend additional time
              optimizing the filtering strength to reach a well-balanced qual-

              Change  the  internal  parameter  mapping  to  better  match the
              expected size of JPEG compression. This flag will generally pro-
              duce  an output file of similar size to its JPEG equivalent (for

       Advanced options:

       -f int Specify the strength of the deblocking  filter,  between  0  (no
              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 of 20 to 50.

       -sharpness int

              Use strong filtering (if filtering is being used thanks  to  the
              -f option). Strong filtering is on by default.

              Disable  strong  filtering (if filtering is being used thanks to
              the -f option) and use simple filtering instead.

              Note  that  this  process  is  slower  than  the  default 'fast'
              RGB->YUV conversion.

       -sns int
              Specify the amplitude of  the  spatial  noise  shaping.  Spatial
              should use relatively less bits, and where else to better trans-
              fer these bits. The possible range goes  from  0  (algorithm  is

       -segments int
              Change  the  number of partitions to use during the segmentation
              up, unless -low_memory is used.

       -partition_limit int
              Degrade quality by limiting the number of bits used by some mac-
              roblocks.  Range is 0 (no degradation, the default) to 100 (full
              degradation).  Useful values are usually around 30-70 for moder-
              ately  large  images.   In the VP8 format, the so-called control
              information: whether the macroblock is skipped, which segment it
              few  bits  per 16x16 macroblock.  The absolute minimum is 4 bits
              is problematic for very large images. The partition_limit factor
              and  the  following  message is displayed: Error code: 6 (PARTI-
              TION0_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.

       These options control the level of output:

       -v     Print extra information (encoding time in particular).


              Compute  and  report average SSIM (structural similarity metric,
              see http://en.wikipedia.org/wiki/SSIM for additional details).

              Compute and report local similarity metric (sum of lowest  error
              amongst the collocated pixel neighbors).

              Report encoding progress in percent.

       -quiet Do not print anything.

       -short Only  print  brief  information  (output file size and PSNR) for
              testing purposes.

       -map int
              Output additional ASCII-map of  encoding  information.  Possible
              map  values range from 1 to 6. This is only meant to help debug-

       More advanced options are:

       -s width height
              Specify that the input file actually consists of raw Y'CbCr sam-
              format.  The luma plane has size width x height.

       -pre int
              trigger   quality-dependent   pseudo-random   dithering   during
              RGBA->YUVA conversion (lossy compression only).

       -alpha_filter string
              Specify the predictive filtering method for the alpha plane. One
              of  'none', 'fast' or 'best', in increasing complexity and slow-
              ness order. Default is 'fast'. Internally,  alpha  filtering  is
              performed  using  four  possible  predictions (none, horizontal,
              will just try to form an a  priori  guess  without  testing  all

       -alpha_method int
              Specify  the algorithm used for alpha compression: 0 or 1. Algo-
              rithm 0 denotes no compression, 1 uses WebP lossless format  for
              compression. The default is 1.

       -exact Preserve  RGB values in transparent area. The default is off, to
              help compressibility.

       -blend_alpha int
              This option blends the  alpha  channel  (if  present)  with  the
              source  using  the  background color specified in hexadecimal as
              0xrrggbb. The alpha channel is afterward  reset  to  the  opaque
              value 255.

              Using this option will discard the alpha channel.

       -hint string
              Specify  the  hint  about input image type. Possible values are:
              photo, picture or graph.

       -metadata string
              The default is none.

              Note: each input format may not support all combinations.

       -noasm Disable all assembly optimizations.

       Please    report     all     bugs     to     the     issue     tracker:
       Patches  welcome!  See  this  page  to get started: http://www.webmpro-

       cwebp -q 50 -lossless picture.png -o picture_lossless.webp
       cwebp -q 70 picture_with_alpha.png -o picture_with_alpha.webp
       cwebp -o picture.webp -- ---picture.png

       The  latest  source  tree  is  available  at   https://chromium.google-

       This   manual   page  was  written  by  Pascal  Massimino  <pascal.mas-

       See attributes(7) for descriptions of the following attributes:

       |Availability   | image/library/libwebp |
       |Stability      | Pass-through volatile |
       dwebp(1), gif2webp(1)

       This     software     was    built    from    source    available    at
       source      was      downloaded     from      http://downloads.webmpro-

       Further information about this software can be found on the open source
       community website at https://www.webmproject.org/.

                               January 20, 2017                       CWEBP(1)