This tool uses tinypng.com API endpoint for compressing your local jpg/png images (it supports parallel jobs):
API key can be set using environment variable named
TINYPNG_API_KEY
; multiple keys are allowed - use,
as a separator.
Download the latest binary file for your os/arch from releases page or use our docker image (ghcr.io).
Install the API client with go get
:
$ go get -u gh.tarampamp.am/tinifier/v4
Client sources and usage examples can be found in pkg/tinypng
directory.
tinypng.com API key is required. For API key getting you should:
- Open tinypng.com/developers
- Fill-up the form (enter your name and email address) and press "Get your API key" button
- Check for email in the mailbox from previous step (click on "verification link")
- In opened dashboard page - activate API key and save it somewhere
Compress single image:
$ tinifier compress -k 'YOUR-API-KEY-GOES-HERE' ./img.png
Compress all png
images in some directory and 2 other images:
$ tinifier compress -k 'YOUR-API-KEY-GOES-HERE' -e png ./images-directory ./img-1.png ./img-2.png
Compress jpg/png images in some directory (recursively) using 20 threads:
$ tinifier compress -k 'YOUR-API-KEY-GOES-HERE' -e png -e jpg -e PNG -e JPG -t 20 -r ./some-dir
All supported image tags can be found here and here.
Compress all images in current directory:
$ docker run --rm -ti \
-u "$(id -u):$(id -g)" \
-v "$(pwd):/rootfs:rw" \
-w /rootfs \
tarampampam/tinifier compress -k 'YOUR-API-KEY-GOES-HERE' -r .
or
$ docker run --rm -ti \
-u "$(id -u):$(id -g)" \
-v "$(pwd):/rootfs:rw" \
-w /rootfs \
-e 'TINYPNG_API_KEY=YOUR-API-KEY-GOES-HERE' \
tarampampam/tinifier compress -r .
For application testing and building we use built-in golang testing feature and docker-ce
+ docker-compose
as develop environment. So, just write into your terminal after repository cloning:
$ make test
Or build the binary file:
$ make build
New versions publishing is very simple - just make required changes in this repository, update changelog file and "publish" new release using repo releases page.
Binary files and docker images will be build and published automatically.
New release will overwrite the
latest
docker image tag in both registers.
Changes log can be found here.
If you find any package errors, please, make an issue in current repository.
This is open-sourced software licensed under the MIT License.