cwebp: add -resize_mode

* `down_only`: downsample only if one of the input dimensions is larger
               than the target
* `up_only`: upsample only if one of the input dimensions is smaller
             than the target
* `always`: the original behavior

This change doesn't add related modes like area (@ in ImageMagick) or
minimum width/height (^ in ImageMagick). These can be added if a need
arises.

Bug: webp:405437935
Change-Id: I7752789dce6e3b9c3fb7d6edf63ca5559bb3463c
This commit is contained in:
James Zern
2025-04-10 13:05:30 -07:00
parent ad52d5fc7e
commit eb4f813761
3 changed files with 57 additions and 1 deletions

View File

@ -1,5 +1,5 @@
.\" Hey, EMACS: -*- nroff -*-
.TH CWEBP 1 "September 17, 2024"
.TH CWEBP 1 "April 10, 2025"
.SH NAME
cwebp \- compress an image file to a WebP file
.SH SYNOPSIS
@ -102,6 +102,14 @@ If either (but not both) of the \fBwidth\fP or \fBheight\fP parameters is 0,
the value will be calculated preserving the aspect\-ratio. Note: scaling
is applied \fIafter\fP cropping.
.TP
.BI \-resize_mode " string
Specify the behavior of the \fB\-resize\fP option. Possible values are:
\fBdown_only\fP, \fBup_only\fP, \fBalways\fP (default). \fBdown_only\fP will
use the values specified by \fB\-resize\fP if \fIeither\fP the input width or
height are larger than the given dimensions. Similarly, \fBup_only\fP will only
resize if \fIeither\fP the input width or height are smaller than the given
dimensions.
.TP
.B \-mt
Use multi\-threading for encoding, if possible.
.TP