Skip to content

Slash command

Image tools

Converts, compresses and resizes the images in a folder with real ImageMagick commands - never overwriting an original without leaving a copy.

About

Converts, compresses and resizes the images in a folder with real ImageMagick commands - never overwriting an original without leaving a copy.

Files in v1.0.0

  • replicamd.plugin.json5168 B
  • skills/images-on-the-web.md2133 B

Contributes

{
  "commands": [
    {
      "id": "to-webp",
      "title": "Convert images here to WebP",
      "run": "command -v magick >/dev/null 2>&1 || { echo 'ImageMagick is not installed. Arch: sudo pacman -S imagemagick · macOS: brew install imagemagick'; exit 1; }; n=0; for f in *.png *.PNG *.jpg *.JPG *.jpeg *.JPEG; do [ -e \"$f\" ] || continue; out=\"${f%.*}.webp\"; [ -e \"$out\" ] && { echo \"skip $f (webp exists)\"; continue; }; magick \"$f\" -quality 82 \"$out\" && { echo \"$f -> $out\"; n=$((n+1)); }; done; [ \"$n\" -eq 0 ] && echo 'No PNG or JPEG here to convert.' || echo \"Converted $n image(s). Originals untouched.\""
    },
    {
      "id": "shrink",
      "title": "Resize images down to 1600px",
      "run": "command -v magick >/dev/null 2>&1 || { echo 'ImageMagick is not installed. Arch: sudo pacman -S imagemagick'; exit 1; }; mkdir -p resized; n=0; for f in *.png *.PNG *.jpg *.JPG *.jpeg *.JPEG *.webp; do [ -e \"$f\" ] || continue; magick \"$f\" -resize '1600x1600>' -quality 85 \"resized/$f\" && { echo \"resized/$f\"; n=$((n+1)); }; done; [ \"$n\" -eq 0 ] && { rmdir resized 2>/dev/null; echo 'No images here.'; } || echo \"Wrote $n file(s) to ./resized. Nothing was overwritten.\""
    },
    {
      "id": "compress",
      "title": "Compress images in place (keeps originals in ./original)",
      "run": "command -v magick >/dev/null 2>&1 || { echo 'ImageMagick is not installed.'; exit 1; }; mkdir -p original; n=0; skipped=0; saved=0; for f in *.png *.PNG *.jpg *.JPG *.jpeg *.JPEG; do [ -e \"$f\" ] || continue; before=$(wc -c <\"$f\"); tmp=\".compress-$$-$f\"; case \"$f\" in *.png|*.PNG) magick \"$f\" -strip -define png:compression-level=9 -define png:compression-filter=5 \"$tmp\" ;; *) magick \"$f\" -strip -quality 82 \"$tmp\" ;; esac || { rm -f \"$tmp\"; continue; }; after=$(wc -c <\"$tmp\"); if [ \"$after\" -lt \"$before\" ]; then cp -n \"$f\" \"original/$f\" || true; mv \"$tmp\" \"$f\"; echo \"$f  $before -> $after bytes\"; saved=$((saved + before - after)); n=$((n+1)); else rm -f \"$tmp\"; echo \"$f  already optimal, left alone\"; skipped=$((skipped+1)); fi; done; rmdir original 2>/dev/null; [ \"$n\" -eq 0 ] && [ \"$skipped\" -eq 0 ] && echo 'No images here.' || echo \"Compressed $n file(s), saved $saved bytes; $skipped already optimal. Untouched copies of anything changed are in ./original.\""
    },
    {
      "id": "favicon",
      "title": "Make favicons and app icons from one image",
      "run": "command -v magick >/dev/null 2>&1 || { echo 'ImageMagick is not installed.'; exit 1; }; src=$(ls -1 icon.png logo.png icon.svg logo.svg 2>/dev/null | head -1); [ -n \"$src\" ] || { echo 'Put an icon.png, logo.png, icon.svg or logo.svg in this folder first.'; exit 1; }; mkdir -p icons; for s in 16 32 48 64 128 180 192 256 512; do magick \"$src\" -background none -resize ${s}x${s} \"icons/icon-${s}.png\"; done; magick icons/icon-16.png icons/icon-32.png icons/icon-48.png icons/favicon.ico; echo \"Built icons/ from $src: 9 PNG sizes plus a multi-size favicon.ico.\""
    },
    {
      "id": "strip",
      "title": "Strip metadata from every image here",
      "run": "command -v magick >/dev/null 2>&1 || { echo 'ImageMagick is not installed.'; exit 1; }; n=0; for f in *.png *.PNG *.jpg *.JPG *.jpeg *.JPEG *.webp; do [ -e \"$f\" ] || continue; magick \"$f\" -strip \"$f\" && { echo \"stripped $f\"; n=$((n+1)); }; done; [ \"$n\" -eq 0 ] && echo 'No images here.' || echo \"Removed EXIF/GPS from $n file(s). This edits in place - commit or back up first if that matters.\""
    },
    {
      "id": "contact-sheet",
      "title": "Build a contact sheet of every image here",
      "run": "command -v magick >/dev/null 2>&1 || { echo 'ImageMagick is not installed.'; exit 1; }; ls *.png *.PNG *.jpg *.JPG *.jpeg *.JPEG *.webp >/dev/null 2>&1 || { echo 'No images here.'; exit 1; }; magick montage *.png *.PNG *.jpg *.JPG *.jpeg *.JPEG *.webp -thumbnail 240x240 -background '#111' -fill '#eee' -label '%f (%wx%h)' -geometry +8+8 contact-sheet.png 2>/dev/null; echo 'Wrote contact-sheet.png.'"
    },
    {
      "id": "inspect",
      "title": "List every image here with size and dimensions",
      "prompt": "Run `identify -format \"%f %wx%h %b %m\\n\" *.png *.jpg *.jpeg *.webp 2>/dev/null` in this folder, then tell me which images are worth fixing and why: anything far larger than its display size, anything still carrying EXIF or GPS, anything shipped as PNG that is a photograph, anything above about 300KB. Give the specific command that would fix each one. If they are all reasonable, say so rather than manufacturing work."
    }
  ],
  "skills": [
    "skills/images-on-the-web.md"
  ]
}

Versions

  • v1.0.07/26/2026 · 2 files

Install

Install in ReplicaMD

Nothing happened? ReplicaMD may not be installed yet - or open it first, then Settings → Plugins and install by id.

Plugin id:

image-tools

Bundle endpoint:

https://replicamd.nl/api/registry/plugins/image-tools/download
Author
Ardjun Debi - Tewarie @ardjun
Latest
v1.0.0
License
MIT
Installs
0
imagesmediaconvertoptimiseshell