Skip to content

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 ​

bash
npm install -g @macrulez/mediatoolz

The mediatoolz command is then available from any directory. Or run it without installing:

bash
npx @macrulez/mediatoolz image-batch ./photos -r -o ./out -f webp

Quick start ​

bash
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 commands

mediatoolz --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 … and mediatoolz 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 by mediatoolz image-batch restore.
  • sharp comes with mediatoolz now, so the managed copy in ~/.devtoolz/deps is not used and can be deleted. The default cache file of image-hash is .mediatoolz-image-hash-cache.json.
  • The web interface is mediatoolz ui; devtoolz ui keeps only the code checks and the cleanup.