FAQ
Is imgsqz a library I can import?
Section titled “Is imgsqz a library I can import?”No — it’s a CLI. There’s no programmatic JavaScript API. You run the
imgsqz command (or npx @wdalhaj/imgsqz). For image processing inside Node.js
code, use sharp directly, which powers
imgsqz.
What input formats can it read?
Section titled “What input formats can it read?”Anything sharp supports — JPG, PNG, WebP,
AVIF, TIFF, GIF, SVG and more. The output is limited to jpg, png,
webp, avif, tiff.
What’s the default behavior with no flags?
Section titled “What’s the default behavior with no flags?”imgsqz photo.png writes an optimized JPG (quality 80, metadata stripped,
auto-rotated) next to the source as photo_<timestamp>.jpg. Your original is
untouched.
Why is my output file larger than the input?
Section titled “Why is my output file larger than the input?”The report shows ↑ when this happens. Common causes: re-encoding an
already-optimized file, using --lossless on photographic content, or
converting to a format that’s a poor fit. Try a lower -q, a different format,
or keep the original.
Does it overwrite my original?
Section titled “Does it overwrite my original?”Not unless you ask. The default timestamped name avoids collisions, and imgsqz
refuses to write over the input unless you pass --replace (which is itself
atomic). See Replacing files in place.
Why did my transparent PNG lose transparency?
Section titled “Why did my transparent PNG lose transparency?”You probably converted to JPG, which has no alpha channel. Target webp,
avif, or png to keep transparency. See Converting formats.
How do I keep the EXIF/ICC data?
Section titled “How do I keep the EXIF/ICC data?”Pass --no-strip-metadata. By default metadata is stripped for smaller, more
private files. Orientation is corrected either way. See
Metadata & orientation.
Can I process a whole folder?
Section titled “Can I process a whole folder?”Yes — pass a glob your shell expands: imgsqz *.png -f webp. See
Batch processing.
Why can’t I use -o with multiple files?
Section titled “Why can’t I use -o with multiple files?”--output names a single exact file, which can’t hold many results. For batches
use the default names, --no-timestamp, --replace, or a
shell loop.
Does it need libvips or a compiler installed?
Section titled “Does it need libvips or a compiler installed?”Usually no. sharp ships prebuilt binaries for common platforms and
architectures, pulled in automatically on install. See
Installation.
What Node version do I need?
Section titled “What Node version do I need?”Node.js 18 or newer. Check with node --version.
How do I run it without installing?
Section titled “How do I run it without installing?”npx @wdalhaj/imgsqz photo.png -f webp -q 70Is it free? What’s the license?
Section titled “Is it free? What’s the license?”Yes — MIT licensed. Source and issues live on GitHub.