Skip to content

FAQ

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.

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.

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.

Pass --no-strip-metadata. By default metadata is stripped for smaller, more private files. Orientation is corrected either way. See Metadata & orientation.

Yes — pass a glob your shell expands: imgsqz *.png -f webp. See Batch processing.

--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.

Node.js 18 or newer. Check with node --version.

Terminal window
npx @wdalhaj/imgsqz photo.png -f webp -q 70

Yes — MIT licensed. Source and issues live on GitHub.