image-tool-cli
v0.1.0
Published
CLI for photo resize with CSS object-fit: cover, physical units, and RAW preview fallback
Downloads
175
Maintainers
Readme
image-tool
CLI for photo resize with CSS object-fit: cover, physical units, and RAW preview fallback. Every job is a subcommand with full --help.
Install
Requires Node.js 20+.
npm install -g image-tool-cli
image-tool --helpOr run without installing:
npx image-tool-cli --help
npx image-tool-cli resize --help
npx image-tool-cli resize ./photo.jpg -w 800 -H 600The published package name is image-tool-cli because image-tool is already taken on npm. The command stays image-tool.
Tools
resize — photo resize with object-cover
Scales the photo so it fills the requested box, then crops overflow. This matches CSS object-fit: cover: the output is always exactly --width by --height, with no letterboxing and no stretching.
image-tool resize <input> --width <size> --height <size> [options]Sizes accept px, cm, and mm. Bare numbers use --unit (default px). Physical units are converted with --dpi (default 96; use 300 for print).
| Option | Description |
| --- | --- |
| -w, --width <size> | Target width, e.g. 800, 800px, 10cm, 50mm (required) |
| -H, --height <size> | Target height. -h is reserved for help. |
| -u, --unit <px\|cm\|mm> | Unit for width/height when they have no suffix. Default: px |
| -d, --dpi <number> | Converts cm/mm to pixels and is stored on the output. Default: 96 |
| -o, --output <path> | Output path. Default: <name>-<W>x<H>-cover.<ext> |
| -p, --position <anchor> | Crop anchor, like CSS object-position. Default: center |
| -f, --format <format> | jpeg, jpg, png, webp, avif, tiff |
| -q, --quality <1-100> | Quality for jpeg/webp/avif/tiff. Default: 80 |
| --overwrite | Replace an existing output file |
| -v, --verbose | Print source, crop, and output details |
image-tool resize ./photo.jpg -w 1080px -H 1080px
image-tool resize ./photo.jpg -w 10cm -H 15cm --dpi 300
image-tool resize ./photo.jpg -w 50 -H 70 --unit mm --dpi 300
image-tool resize ./photo.jpg -w 800 -H 600 -o ./out.webp -f webp
image-tool resize ./wide.png -w 1920 -H 1080 --position top --verbose
image-tool resize ./IMG_1190.CR2 -w 16cm -H 21cm -f jpeg --verboseCamera RAW files such as Canon .CR2 are decoded by Sharp when possible. If Sharp cannot read the RAW compression (common with old-style JPEG CR2), the tool uses the largest embedded JPEG preview.
Help
image-tool --help
image-tool resize --help
image-tool help resizeDevelopment
npm install
npm run build
npm testAfter a local build:
npm run cli -- --help
npm run cli -- resize ./photo.jpg -w 800 -H 600Link the binary locally:
npm link
image-tool --help