Skip to content

A command line JPG, PNG and WebP images compressor using TinyPNG API

License

Notifications You must be signed in to change notification settings

digikid/tiny-compressor

Repository files navigation

Tiny Compressor

Tiny Compressor

A command line JPG, PNG and WebP images compressor using TinyPNG API.
API key is not required.

English | Русский

Release version TypeScript MIT License

Why

  • Provides up to 80% compression without noticeable quality loss
  • Due to caching only changed files are uploaded to TinyPNG server
  • Written in TypeScript

Install

npm i digikid/tiny-compressor --global --install-links

Usage

Navigate to folder containing images and run command:

cd path/to/images
tiny-compressor

The processed files will be saved to /compressed folder.

Options

Option Description
-f, --force Compress images regardless of cache
-p, --path Output folder name
-q, --quiet Disable log
-w, --watch Watch for file changes

Caching

To avoid re-compression of files and reduce requests to TinyPNG server, all processed files are cached by default.

If you want to run compression regardless of cache, pass -f option:

tiny-compressor -f

Output folder name

You can change output folder name (without saving in settings) by passing -p parameter:

tiny-compressor -p compressed-images

Log

Notifications are generated each time files are processed. You can disable log with -q option:

tiny-compressor -q

Watch

If you want to run compression whenever files in current folder are changed, pass -w option:

tiny-compressor -w

Commands

Command Description
config Update settings
help Display usage guide
reset Clear cache
stat Print processed file history
version Print current package version

Config

Settings are saved locally and applied on all subsequent launches.

For settings update, run config command:

tiny-compressor config

Help

The help command displays a help section with a list of available options and commands list:

tiny-compressor help

Reset

Use reset command to clear processed files cache:

tiny-compressor reset

Stat

For printing processed file history use command stat:

tiny-compressor stat

Version

You can check installed package version with version command:

tiny-compressor version

License

The MIT License (MIT)