Skip to content

MediaToolz

v0.1.1CLI ToolNode.js

A CLI for working with images: it resizes, converts and recompresses them in bulk by the rules of a config, and generates hazehash, blurhash and thumbhash placeholders for them.

MediaToolz
Get started →
npm install -g @macrulez/mediatoolz
01 — Purpose

When you'd reach for this

Images rarely arrive in the form they have to be shown in — here are four situations where the same two commands do the whole job.

The designer handed over five-megabyte originals, and the site needs three widths in modern formats

One image-batch run with the rules of a config lays every image out in the widths you need in avif, webp and jpg, with names from a template such as hero-800w.webp. The config holds only the rules, so the same one serves the next project.

The repository swelled with originals nobody shows at full size

image-batch --replace shrinks oversized images right where they are: a preview with the real before and after sizes first, then a confirmation and a backup with a journal, a file is replaced only when it became smaller, and restore brings everything back.

While an image loads, the page shows a gray rectangle

image-hash computes a compact placeholder for every image — hazehash, blurhash or thumbhash — and writes it to JSON, CSV or a ready TS module. --check fails in CI when the hash file is stale, so the placeholders never drift from the pictures.

A folder of old png and jpg files has to become webp, and the size must not change

With no size flags image-batch resizes nothing: image-batch ./photos -o ./out -f webp only changes the format and the quality, keeping the dimensions of the sources. The preview, the interactive file picker and the protection from overwriting work the same.

02 — Features

At a glance

Image placeholders

Image placeholders

image-hash generates hazehash, blurhash and thumbhash for raster images and, on request, a dominant color and a tiny preview. It takes files, folders and URLs and writes to stdout, one file, or a file per image (photo.jpg.blurhash.txt), in json/plain/csv/ts/js. --check fails in CI when the hash file is stale, and --dry-run shows the result as a table.

Batch image processing

Batch image processing

image-batch resizes, converts and recompresses images in bulk by the rules of a config: sizes, formats, quality, file names from a template. Results go to a separate folder, next to the sources or over them — with a confirmation, a backup and a restore command; --dry-run shows the real before and after sizes.

Web interface

Web interface

mediatoolz ui starts a local web interface: forms, tables and previews instead of flags, a file browser for picking folders, a gallery of placeholders next to the images, configs and sharpening presets with a before and after preview. File changes are confirmed and the originals are backed up. The server listens on 127.0.0.1 only, behind a one-time token.