πΌ CLI tool for compressing images using the TinyPNG
https://github.com/tarampampam/tinifier.git
tinifier is a CLI tool for compressing images using the TinyPNG API, with parallel
processing to speed up the workflow.
TinyPNG uses intelligent lossy compression techniques to reduce the file size of your WEBP, AVIF, JPEG, and
PNG files. By selectively decreasing the number of colors in an image, fewer bytes are needed to store the
data. The effect is nearly imperceptible, but it significantly reduces file size.
> Images uploaded to TinyPNG are automatically removed after a maximum of 48 hours, and only you are allowed
to download them.
Execute the following commands in order:
# setup the repository automatically
curl -1sLf https://dl.cloudsmith.io/public/tarampampam/tinifier/setup.deb.sh | sudo -E bash
# install the package
sudo apt install tinifier
Uninstalling
sudo apt remove tinifier
rm /etc/apt/sources.list.d/tarampampam-tinifier.list
# setup the repository automatically
curl -1sLf https://dl.cloudsmith.io/public/tarampampam/tinifier/setup.rpm.sh | sudo -E bash
# install the package
sudo dnf install tinifier # RedHat, CentOS, etc.
sudo yum install tinifier # Fedora, etc.
sudo zypper install tinifier # OpenSUSE, etc.
Uninstalling
# RedHat, CentOS, Fedora, etc.
sudo dnf remove tinifier
rm /etc/yum.repos.d/tarampampam-tinifier.repo
rm /etc/yum.repos.d/tarampampam-tinifier-source.repo
# OpenSUSE, etc.
sudo zypper remove tinifier
zypper rr tarampampam-tinifier
zypper rr tarampampam-tinifier-source
# bash is required for the setup script
sudo apk add --no-cache bash
# setup the repository automatically
curl -1sLf https://dl.cloudsmith.io/public/tarampampam/tinifier/setup.alpine.sh | sudo -E bash
# install the package
sudo apk add tinifier
Uninstalling
sudo apk del tinifier
$EDITOR /etc/apk/repositories # remove the line with the repository
There are three packages available in the AUR:
pamac build tinifier
Uninstalling
pacman -Rs tinifier
Download the latest binary for your architecture/OS from the releases page. For example, to install
the latest version to the /usr/local/bin directory on an amd64 system (e.g., Debian, Ubuntu), you can run:
# download and install the binary
curl -SsL \
https://github.com/tarampampam/tinifier/releases/latest/download/tinifier-linux-amd64.gz | \
gunzip -c | sudo tee /usr/local/bin/tinifier > /dev/null
# make the binary executable
sudo chmod +x /usr/local/bin/tinifier
Uninstalling
sudo rm /usr/local/bin/tinifier
[!TIP]
Each release includes binaries for linux, darwin (macOS) and windows (amd64andarm64architectures).
You can download the binary for your system from the releases page (sectionAssets). And - yes,
all what you need is just download and run single binary file.
Also, you can use the Docker image:
| Registry | Image |
|---|---|
| [GitHub Container Registry] | ghcr.io/tarampampam/tinifier |
| [Docker Hub] (mirror) | tarampampam/tinifier |
[!NOTE]
Itβs recommended to avoid using thelatesttag, as major upgrades may include breaking changes.
Instead, use specific tags in:X.Y.Zor only:Xformat for version consistency.
You can configure tinifier using a YAML file. Refer to this example for
available options.
You can specify the configuration file's location using the --config-file option. By default, however, the
tool searches for the file in the user's configuration directory:
~/.configs/tinifier.yml%APPDATA%\tinifier.yml~/Library/Application Support/tinifier.yml[!IMPORTANT]
A TinyPNG API key is required. To obtain one:
- Visit tinypng.com/developers
- Fill out the form (enter your name and email address) and click "Get your API key"
- Check your email and click the verification link
- Activate your API key on the dashboard and save it
[!TIP]
If you need to process a large number of files and have a Gmail account, you can use the following
trick - register multiple accounts on tinypng.com using aliases such asyour_mailbox+key1@gmail.com,your_mailbox+key2@gmail.com, etc. This allows you to use a single mailbox to retrieve as many free API
keys as needed.
tinifier -k 'YOUR-API-KEY-GOES-HERE' ./img.png
tinifier -k 'API-KEY-1,API-KEY-2' -e png ./images-directory ./img-1.png ./img-2.png
tinifier -k 'YOUR-API-KEY-GOES-HERE' --ext png,jpg --threads 20 -r ./some-dir
Description:
CLI tool for compressing images using the TinyPNG.
Usage:
tinifier [<options>] [<files-or-directories>]
Version:
0.0.0@undefined
Options:
--config-file="β¦", -c="β¦" Path to the configuration file (default: depends/on/your-os/tinifier.yml) [$CONFIG_FILE]
--api-key="β¦", -k="β¦" TinyPNG API keys <https://tinypng.com/dashboard/api> (separated by commas) [$API_KEYS]
--ext="β¦", -e="β¦" Extensions of files to compress (separated by commas) (default: png,jpeg,jpg,webp,avif) [$FILE_EXTENSIONS]
--threads="β¦", -t="β¦" Number of threads to use for compressing (default: 16) [$THREADS]
--max-errors="β¦" Maximum number of errors to stop the process (set 0 to disable) (default: 10) [$MAX_ERRORS]
--retry-attempts="β¦" Number of retry attempts for upload/download/replace operations (default: 3) [$RETRY_ATTEMPTS]
--delay-between-retries="β¦" Delay between retry attempts (default: 1s) [$DELAY_BETWEEN_RETRIES]
--recursive, -r Search for files in listed directories recursively [$RECURSIVE]
--skip-if-diff-less="β¦" Skip files if the diff between the original and compressed file sizes < N% (default: 1) [$SKIP_IF_DIFF_LESS]
--preserve-time, -p Preserve the original file modification date/time (including EXIF) [$PRESERVE_TIME]
--keep-original-file Leave the original (uncompressed) file next to the compressed one (with the .orig extension) [$KEEP_ORIGINAL_FILE]
--help, -h Show help
--version, -v Print the version
This is open-sourced software licensed under the MIT License.