AGENT SKILL

web-ready

Use when the user wants to take a folder of images (any mix of HEIC, RAW, PNG, JPEG, TIFF, WebP) and produce a web-ready set — EXIF stripped, resized to a sensible max dimension, encoded in modern formats (AVIF + WebP, with JPEG fallback), and optimized for size. End-to-end orchestrator over the single-purpose skills in this plugin. Triggers - "make this folder web-ready", "prep these photos for upload", "get these images ready for my blog".

License 许可
MIT
最近更新
2026-11-10
Stars
★ 0
Forks
0

01 前言 Front Matter

name
web-ready
description
Use when the user wants to take a folder of images (any mix of HEIC, RAW, PNG, JPEG, TIFF, WebP) and produce a web-ready set — EXIF stripped, resized to a sensible max dimension, encoded in modern formats (AVIF + WebP, with JPEG fallback), and optimized for size. End-to-end orchestrator over the single-purpose skills in this plugin. Triggers - "make this folder web-ready", "prep these photos for upload", "get these images ready for my blog".
allowed-tools
Bash(which *), Bash(command *), Bash(test *), Bash(brew *), Bash(magick *), Bash(convert *), Bash(identify *), Bash(exiftool *), Bash(vips *), Bash(vipsthumbnail *), Bash(vipsheader *), Bash(heif-convert *), Bash(darktable-cli *), Bash(avifenc *), Bash(cwebp *), Bash(cjpeg *), Bash(jpegoptim *), Bash(oxipng *), Bash(mkdir *), Bash(mktemp *), Bash(cp *), Bash(mv *), Bash(rm *), Bash(find *), Bash(wc *), Read, Write

03 SKILL.md 正文

Web-Ready (orchestrator)

One-shot pipeline: ingest anything → strip EXIF → resize → encode to web formats → optimize. The "make this folder uploadable" skill.

When to use

  • Photos coming off a phone (HEIC) destined for a blog.
  • Camera RAW exports being prepped for an online gallery.
  • A mixed folder of screenshots/photos that needs to ship to the web.
  • Pre-step before image upload to any CMS, S3 bucket, or Cloudflare R2.

Do not use this skill when:

  • The user wants archival output → keep originals; use the targeted skills (to-jxl, transcode-jpeg-to-jxl-lossless, optimize-png).
  • The user wants pixel-perfect originals on the web (rare, e.g. art prints) → use optimize-png/optimize-jpeg only, no resize.
  • Single-file conversion → call the underlying skill directly.

Inputs

  1. Input directory — required.
  2. Profile — preset bundle. One of:
    • blog (default): max-side 2000px, AVIF q60 + WebP q80 + JPEG q82 fallback, EXIF stripped.
    • gallery: max-side 3000px, AVIF q70 + WebP q85, EXIF stripped.
    • thumbnail: max-side 800px, AVIF q55 + WebP q75, EXIF stripped.
    • archival-web: max-side 4000px, AVIF q80 + WebP q90, EXIF preserved.
  3. Custom overrides — any of --max-side N, --avif-q N, --webp-q N, --jpeg-q N, --keep-exif, --no-jpeg-fallback.
  4. Output dir — default: <input>/web/. Inside: web/avif/, web/webp/, web/jpg/ parallel trees so the user can pick which set to upload.
  5. Recursive — --recursive. Mirrors subdirectory layout.

Procedure

  1. Pre-flight: check each tool the pipeline needs and record which are present:

    for t in magick exiftool vipsthumbnail avifenc cwebp cjpeg oxipng jpegoptim \
             heif-convert darktable-cli
    do
      command -v "$t" >/dev/null && echo "ok    $t" || echo "MISS  $t"
    done
    

    magick and exiftool are required — stop and point at image-ops-install-deps if either is missing. The rest are optional: a missing encoder drops its output format from the pipeline with a one-line note, and a missing heif-convert / darktable-cli narrows which sources can be ingested (stage 1).

    For the mozjpeg-quality JPEG fallback, resolve $MOZ_BIN as described in optimize-jpeg step 1 — a bare cjpeg on PATH is libjpeg-turbo, not mozjpeg.

  2. Stage 1: Stage and decode inputs. Every later stage works on files in a private staging directory, never the input tree:

    stage="$(mktemp -d "${TMPDIR:-/tmp}/web-ready.XXXXXX")"
    

    Each file gets a staged copy at $stage/<relative-path> (mirroring subdirectories avoids name collisions):

    • JPEG/PNG/WebP/TIFF → copy: mkdir -p "$(dirname "$staged")" && cp -p "$input" "$staged". Never pass the original itself through: stage 2 rewrites $staged in place.
    • HEIC → decode to PNG via heif-convert (or via vipsthumbnail if libvips has libheif). Fail loud if neither is available.
    • RAW (CR2, ARW, NEF, DNG, ORF, RAF) → decode via darktable-cli "$input" "$staged.tiff". There is no libvips fallback here: libvips ships no camera-RAW decoder for these formats (a DNG that happens to be TIFF-wrapped may partially load via tiffload, but CR2/ARW/NEF/ORF/RAF will not). If darktable-cli is missing, skip the file with a flagged warning naming the format, and tell the user in the summary that RAW ingestion needs darktable-cli installed.
    • Anything else (BMP, GIF, etc.) → copy, as for JPEG/PNG.
  3. Stage 2: Strip EXIF. Unless --keep-exif set, on the staged copy only:

    case "$staged" in "$stage"/*) ;; *) echo "refusing to strip outside staging: $staged" >&2; exit 1 ;; esac
    exiftool -all= --ICC_Profile:all -tagsfromfile @ -Orientation -ColorSpace "$staged"
    

    This rewrites $staged in place, which is safe only because it is a copy. The case guard enforces that. exiftool's <file>_original backup stays in $stage and goes at cleanup. Keep Orientation, ColorSpace and the ICC profile (--ICC_Profile:all excludes it from -all=). Without the profile, colours in a Display P3 or Adobe RGB photo shift.

  4. Stage 3: Resize. Per file, fit within <max-side> box preserving aspect:

    vipsthumbnail "$staged" --size "${max_side}x${max_side}" --output "$resized.png[Q=100]"
    

    Use lossless intermediate to avoid double-compression. Skip if the source's longest side is already ≤ max-side.

  5. Stage 4: Encode. For each survivor, produce up to three outputs:

    • AVIF: avifenc -q "$avif_q" -s 6 "$resized.png" "$out/avif/$basename.avif". avifenc copies the source's EXIF/XMP, and stage 2 has already removed them unless --keep-exif is set.

    • WebP: cwebp -q "$webp_q" "$resized.png" -o "$out/webp/$basename.webp"

    • JPEG fallback (unless --no-jpeg-fallback): cjpeg cannot read PNG — it decodes PPM/PGM/BMP/Targa only — so the stage-3 PNG must be decoded first:

      magick "$resized.png" ppm:- \
        | "$MOZ_BIN/cjpeg" -quality "$jpeg_q" -progressive -optimize \
        > "$out/jpg/$basename.jpg"
      

      If $MOZ_BIN did not resolve in pre-flight, use ImageMagick end to end instead — slightly larger output, but it reads PNG natively:

      magick "$resized.png" -quality "$jpeg_q" -interlace Plane "$out/jpg/$basename.jpg"
      

    Run encodes in parallel — they're independent. Check each encoder's exit status and record failures per file and per format; a format that fails for one file must not abort the other two or the rest of the batch.

  6. Stage 5: Optimize (final squeeze).

    • JPEGs: jpegoptim --strip-com --strip-exif --strip-iptc --strip-xmp --all-progressive in-place on web/jpg/. Avoid --strip-all, which also removes the ICC profile. With --keep-exif, drop the --strip-* flags.
    • PNGs (only if any survived as PNG, e.g. with --no-jpeg-fallback): oxipng -o 4 --strip safe.
    • AVIF / WebP: avifenc and cwebp already produce near-optimal output; no second pass.
  7. Cleanup: rm -rf "$stage" (only the staging directory). Write a manifest at <output>/manifest.json mapping <original-path> → {avif, webp, jpg} plus per-file size deltas.

Output

  • Three parallel trees under <output-dir>: avif/, webp/, jpg/.
  • manifest.json with the mapping and size table.
  • Summary report:
    • Files processed / skipped / failed (with reasons).
    • Total bytes per format. Typical: <orig> → AVIF <X>%, WebP <Y>%, JPEG <Z>%.
    • Recommendation line: which format to upload (AVIF if all targets support it; WebP otherwise; JPEG as universal fallback).

Notes

  • Defaults are tuned for the blog profile. gallery and archival-web raise quality for slower-but-better output.
  • The orchestrator never modifies originals. Every destructive step runs on a copy in $stage, and the output tree is separate.
  • Companion skills: convert-to-avif (single-format), optimize-png, optimize-jpeg, fast-resize; plus the /convert-to-webp command for single-format WebP. This orchestrator composes the same tools; the user is welcome to use the components directly when they want finer control.

04 同仓库更多 Skills