convert
Re-encode to a different format, optionally at a byte target or a fixed quality.
Convert to a different format.
convert <inputs...> --to-format jpeg|png|webp [--to <size>] [--quality Q] [--background #hex]
Flags
| Flag | Required | Meaning |
|---|---|---|
--to-format jpeg|png|webp |
yes | the output format. Not heic (decode-only) and not avif (rejected by this command’s own validation, the same as compress/resize’s --format). |
--to <size> |
no | hit a byte target after converting, same parser as compress. |
--quality Q |
no | encoder quality, 1–100. Ignored (and meaningless) for PNG, which has no scalar quality knob. Only meaningful without --to — with a byte target, the search picks quality itself. |
--background #hex |
no | flatten color for alpha going to a non-alpha format. Default #ffffff. Same accepted shapes as resize’s --background: #rgb, #rrggbb, white, black. |
Examples
Convert a PNG to WebP:
imagekbreducer convert screenshot.png --to-format webp
Convert to JPEG at a fixed quality, flattening alpha onto black:
imagekbreducer convert icon.png --to-format jpeg --quality 85 --background black
What can go wrong
| Exit | When |
|---|---|
| 2 | --to-format missing or not one of jpeg/png/webp; --to not a parseable size; --quality not an integer 1–100; --background not a valid color |
| 3 | an input doesn’t exist, or a glob matched nothing |
| 4 | the computed output already exists and isn’t the input |
| 10–13 | only reachable when --to is given — see Exit codes |
| 20–24 | engine-side failures — see Exit codes |
quality in the --json envelope is null for PNG output, and targetBytes
is null whenever --to was omitted.