tinifier
is a CLI tool for compressing images using the TinyPNG API, with parallel
processing to speed up the workflow.
- Compress images in parallel (configurable number of threads)
- Support for multiple API keys (automatically switches if a key exceeds its quota)
- Automatic retries for failed operations
- Recursive search for images in directories (configurable file extensions)
- Skip files if the difference between the original and compressed file sizes is below a specified percentage
- Preserve the original file modification date/time (including EXIF metadata), ensuring correct photo ordering (e.g., from smartphones) after compression
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:
- Build from source: tinifier
- Precompiled: tinifier-bin
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 (amd64
and arm64
architectures).
You can download the binary for your system from the releases page (section Assets
). 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 the latest
tag, as major upgrades may include breaking changes.
Instead, use specific tags in :X.Y.Z
or only :X
format 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:
- Linux:
~/.configs/tinifier.yml
- Windows:
%APPDATA%\tinifier.yml
- macOS:
~/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 as [email protected]
,
[email protected]
, 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]
--help, -h Show help
--version, -v Print the version
This is open-sourced software licensed under the MIT License.