Installation
Requirements
Node.js 20+. The native sharp image library comes with the package: npm installs the prebuilt binary for your platform together with it, so there is nothing else to set up (see Image Hash for the rare case when it is missing). No external tools need to be on PATH.
Installation
npm install -g @macrulez/mediatoolzThe mediatoolz command is then available from any directory. Or run it without installing:
npx @macrulez/mediatoolz image-batch ./photos -r -o ./out -f webpQuick start
mediatoolz image-hash public/img -r --per-file # hazehash/blurhash/thumbhash placeholders for every image
mediatoolz image-batch src/img -r -o public/img -w 400,800,1200 -f avif,webp # responsive sizes and formats into another folder
mediatoolz image-batch photos -r -o out -f webp # only change the format, keep the size
mediatoolz image-batch assets -r --replace -w 1600 --dry-run # preview shrinking originals in place (backup + restore)
mediatoolz ui # a web interface for both commandsmediatoolz --help lists both commands with their own flags inline; mediatoolz <command> --help gives one command's full flag list with defaults.
Moving from DevToolz
image-hash and image-batch lived in DevToolz up to version 0.4.3. In DevToolz 0.5.0 both commands only print where they went and exit with code 2, so a script that still calls devtoolz image-batch … fails loudly instead of silently doing nothing. To move over:
- Use
mediatoolz image-batch …andmediatoolz image-hash …with the same flags. - Move the folders with your configs and sharpening presets:
.devtoolz/image-batch/becomes.mediatoolz/image-batch/, both in a project and in your home folder. - Backups made by
--replace(.image-batch-backup/) keep their name and can be restored bymediatoolz image-batch restore. sharpcomes with mediatoolz now, so the managed copy in~/.devtoolz/depsis not used and can be deleted. The default cache file ofimage-hashis.mediatoolz-image-hash-cache.json.- The web interface is
mediatoolz ui;devtoolz uikeeps only the code checks and the cleanup.