Skip to content
Skills Library
Documents & office · Conversion & formats

optimize-jpeg

/optimize-jpeg

Use when the user wants to shrink JPEG files — losslessly with `jpegoptim` (~5–15% reduction, no re-encode) or with re-compression via `mozjpeg` (~10–15% better than libjpeg-turbo at the same visual quality). Web-prep workhorse for photo libraries.

Licence
MIT
Last repository change
24.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 24.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Use when the user wants to shrink JPEG files — losslessly with `jpegoptim` (~5–15% reduction, no re-encode) or with re-compression via `mozjpeg` (~10–15% better than libjpeg-turbo at the same visual quality). Web-prep workhorse for photo libraries.

Original author description

Use when the user wants to shrink JPEG files — losslessly with `jpegoptim` (~5–15% reduction, no re-encode) or with re-compression via `mozjpeg` (~10–15% better than libjpeg-turbo at the same visual quality). Web-prep workhorse for photo libraries.

How it works

  1. When to use
  2. Inputs
  3. Procedure
  4. Output
  5. Notes
Original SKILL.md headings · 71 lines, 460 words
SKILL.md preview
---
name: optimize-jpeg
description: Use when the user wants to shrink JPEG files — losslessly with `jpegoptim` (~5–15% reduction, no re-encode) or with re-compression via `mozjpeg` (~10–15% better than libjpeg-turbo at the same visual quality). Web-prep workhorse for photo libraries.
---

# Optimize JPEG

Squeeze JPEG file size. Two modes:

- **lossless** (default) — `jpegoptim --strip-all`. Repacks Huffman tables and strips metadata. No re-encode, no quality change.
- **recompress** — `mozjpeg` (`cjpeg-mozjpeg`). Re-encodes with better quantisation tables; 10–15% smaller than libjpeg-turbo for the same SSIM. Quality flag controls trade-off.

## When to use

- Web-prep: photo galleries, blog images, anything destined for upload.
- Archive squeeze: lossless mode is the no-regret option for any JPEG-heavy folder.
- Pre-step inside `web-ready` orchestrator.

Do **not** use this skill when:
- Source is PNG → use `optimize-png`.
- Source is HEIC/RAW/TIFF — pipe through `web-ready` (or convert first).
- The JPEG is already heavily compressed (<70% quality estimate) — recompress will visibly degrade.

## Inputs

1. **Input** — file or directory. Required.
2. **Mode** — `lossless` (default) or `recompress`.
3. **Recursive** — `--recursive` for directory descent.
4. **In-place** — default. `--output-dir <path>` to write copies.
5. **Quality** (mode=recompress) — `cjpeg-mozjpeg -quality N`. Default `82` (web-quality). `90` for archival; `75` for aggressive web compression.
6. **Strip metadata** — default `on` for both modes. EXIF/IPTC/XMP gone. Use `--keep-metadata` to preserve.
7. **Progressive** — default `on`. Smaller files + better perceived load. `--baseline` to disable for compatibility with very old decoders.

## Procedure

1. Verify the relevant binary. `which jpegoptim` for lossless; `which cjpeg-mozjpeg` (or fallback `which cjpeg`) for recompress. If missing, point at `install-deps`.

2. Enumerate inputs (JPEG/JPG only — skip with note).

3. **Lossless** (jpegoptim):

   ```bash
   jpegoptim --strip-all --all-progressive [--dest <out-dir>] "<input>"
   ```

   `--all-progressive` forces progressive output (smaller). `--strip-all` removes EXIF/IPTC/XMP/comments. Drop these if `--keep-metadata` was set.

4. **Recompress** (mozjpeg):

   mozjpeg's CLI is decode-then-encode, so for in-place behaviour:

   ```bash
   djpeg "<input>" | cjpeg-mozjpeg -quality <q> -progressive [-optimize] > "<output>"
   ```

   Or use `jpegtran-mozjpeg` for lossless transforms when only metadata stripping + Huffman repack is desired (essentially a faster jpegoptim).

   For batch, parallelise with `xargs -P <ncpu>`.

5. Sanity-check: any output file >95% of input size in recompress mode — keep the original instead. cjpeg-mozjpeg occasionally inflates already-optimised inputs.

## Output

- Optimised JPEGs at the resolved paths.
- Summary:
  - Files processed / skipped / failed / kept-original (where recompress would have inflated).
  - Total: `<orig-MB>` → `<new-MB>` (`<pct>%` saved).
  - Visible-quality flag: if recompress was used and the source had a quality estimate <75 (via `identify -format "%Q"`), surface a warning per file.

## Notes

- mozjpeg is a drop-in libjpeg-turbo replacement with smarter trellis quantisation. It's slower than libjpeg-turbo by ~3× — fine for web-prep, not for thumbnail generation.
- For "I just want it smaller, don't touch quality": always use `lossless` mode. Free win.
- The orchestrator (`web-ready`) defaults to: resize first, then encode WebP/AVIF, fall back to mozjpeg for JPEG output. This skill exists to do JPEG-only optimisation without that pipeline.

Versions

The database has no other skills named optimize-jpeg.

Database snapshot: 13.11.2026 · package version e2a59ff95128 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100optimize-png
    Use when the user wants to shrink PNG files in a batch — losslessly with `oxipng` (typical 20–40% reduction, byte-identical decode) or aggressively with `pngquant` (lossy palette quantisation, 60–80% reduction with near-imperceptible quality loss for web use). Web-prep workhorse.
  • 100transcode-jpeg-to-jxl-lossless
    Losslessly transcode JPEG files to JPEG XL, preserving the original JPEG bitstream while achieving ~20% file size reduction. Use when archiving JPEG photo libraries where the goal is smaller files without re-compression artifacts.
  • 90esp32-jpeg-encode-backpressure
    Use when designing, reviewing, debugging or validating jpeg encode backpressure for ESP32 firmware; apply target-specific constraints, failure analysis and measurable verification before release.
  • 100heic-to-jpeg-bundle
    Convert a folder of iPhone HEIC photos to JPEG and package them for sharing — a browsable thumbnail gallery plus an optional password-protected ZIP sized to fit a static host's per-file cap. Uses macOS sips (zero install). Use when someone can't open HEIC (Windows, appraisal/CRM…
  • 100photo-gallery-delivery
    End-to-end playbook for getting a set of photos to someone who can't use what you sent — pull the originals from a cloud album, convert HEIC to JPEG, build a browsable gallery plus a password-protected ZIP, host it on an unlisted URL, and share it through a gist gateway that…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.