Quickstart
Install imagekbreducer and compress your first file.
Run it once, no install
npx imagekbreducer compress photo.jpg --to 50kb
This writes photo-compressed.jpg next to photo.jpg — it never overwrites your original (see
Output files) — and prints a one-line summary to stderr:
photo.jpg → photo-compressed.jpg 3.1 MB → 49.8 KB (98% smaller)
ikb is a shorter alias for the same binary:
npx ikb compress photo.jpg --to 50kb
Install it for repeated use
npm install -g imagekbreducer
imagekbreducer compress photo.jpg --to 50kb
ikb compress photo.jpg --to 50kb
Requires Node 22 or later.
What just happened
--to 50kb parses through the same 1024-based size parser the website uses: 50kb is
51,200 bytes, not 50,000. The tool searches encoder quality (and, unless you pass
--no-downscale, pixel dimensions) for the highest-quality file that lands at or under that
byte count — never over it, and never a fixed quality that might miss high.
If 50 KB isn’t reachable at all (a --rect-cropped icon can’t be un-cropped, a --no-downscale
flag pins the dimensions too high for the format’s own floor), the tool doesn’t fail silently or
crash: it exits with a specific code, explains why on stderr, and tells you exactly which flag
would fix it. See Exit codes.