๐Ÿ“ฆ tarampampam / tinifier

๐Ÿผ CLI tool for compressing images using the TinyPNG

โ˜… 101 stars โ‘‚ 11 forks ๐Ÿ‘ 101 watching โš–๏ธ MIT License
clidockergolangtinify
๐Ÿ“ฅ Clone https://github.com/tarampampam/tinifier.git
HTTPS git clone https://github.com/tarampampam/tinifier.git
SSH git clone git@github.com:tarampampam/tinifier.git
CLI gh repo clone tarampampam/tinifier
dependabot[bot] dependabot[bot] Bump golang from 1.22-alpine to 1.23-alpine in the docker group (#165) 6092da9 1 years ago ๐Ÿ“ History
๐Ÿ“‚ 6092da9a7c3131f517106653fb89717b4fcb4874 View all commits โ†’
๐Ÿ“ .github
๐Ÿ“ art
๐Ÿ“ cmd
๐Ÿ“ internal
๐Ÿ“ pkg
๐Ÿ“„ .dockerignore
๐Ÿ“„ .editorconfig
๐Ÿ“„ .env.example
๐Ÿ“„ .gitignore
๐Ÿ“„ .golangci.yml
๐Ÿ“„ compose.yml
๐Ÿ“„ Dockerfile
๐Ÿ“„ go.mod
๐Ÿ“„ go.sum
๐Ÿ“„ LICENSE
๐Ÿ“„ Makefile
๐Ÿ“„ README.md
๐Ÿ“„ README.md

Logo

CLI tool for images compressing

Release version Build Status [Image size] License

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.

Installing

Download the latest binary file for your os/arch from [releases page] or use our [docker image] ([ghcr.io]).

Go package

Project language Go Reference Go Report

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.

Usage example

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

Using docker

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 .

Testing

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

Releasing

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.

Changelog

Release date Commits since latest release

Changes log can be [found here].

Support

Issues Issues

If you find any package errors, please, [make an issue] in current repository.

License

This is open-sourced software licensed under the MIT License.