Skip to main content
optimize is the one you reach for when you don’t want to think about settings. Point it at a directory, pick a preset, and it resizes and re-encodes everything inside — keeping each file’s existing format unless you say otherwise.

Arguments

string
required
The directory to optimize. Searched recursively for image files.

Options

string
default:"web"
Which preset to apply: web, social, or email. See the table below for what each one does.
string
Convert everything to this format instead of keeping each file’s source format.
string
Directory to write results into. Defaults to writing next to each input file — see the warning below for why you usually want to set this.
boolean
default:"false"
Keep EXIF/XMP in the output. Metadata is stripped unless you pass this.
boolean
deprecated
A no-op — metadata is already stripped by default. Accepted so the flag doesn’t error if you write it out of habit.
string
Write a JSON report of the results to this path. Same shape as convert.
boolean
default:"false"
Report what would be written without writing it.

Presets

Images smaller than the preset’s limit aren’t scaled up — the limit is a ceiling, not a target.

Two behaviours worth knowing

It recurses, and it will find its own previous output. Run optimize on a directory without --out and a second run picks up the files the first run created. Always write somewhere separate — bmux optimize photos --preset web --out optimized
Extensions get normalised. Keeping the source format means keeping the format, not the spelling — a .jpg input comes back as .jpeg, because that’s the canonical extension for image/jpeg. If you need the original spelling, use convert instead.

Changing format at the same time

--to overrides the keep-source-format behaviour, so you can resize and convert in one pass:

Checking first

Because optimize touches a whole directory, --dry-run is worth the habit:

Files it can’t identify

Format is detected from file contents, not the extension. Anything that isn’t a supported image is reported as failed and the rest of the batch continues:
The command exits non-zero when anything failed.