tinifier

module
v3.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2022 License: MIT

README

Logo

CLI tool for images compressing

Release version Build Status Coverage 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

Installing

Download 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 github.com/tarampampam/tinifier/v3

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 another 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

image stats

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 will find any package errors, please, make an issue in current repository.

License

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

Directories

Path Synopsis
cmd
tinifier
Main CLI application entrypoint.
Main CLI application entrypoint.
internal
pkg/breaker
Package breaker provides OSSignals struct for OS signals handling (with context).
Package breaker provides OSSignals struct for OS signals handling (with context).
pkg/cli
Package cli contains CLI command handlers.
Package cli contains CLI command handlers.
pkg/cli/compress
Package compress contains CLI `compress` command implementation.
Package compress contains CLI `compress` command implementation.
pkg/cli/quota
Package quota contains CLI `quota` command implementation.
Package quota contains CLI `quota` command implementation.
pkg/cli/version
Package version contains CLI `version` command implementation.
Package version contains CLI `version` command implementation.
pkg/env
Package env contains all about environment variables, that can be used by current application.
Package env contains all about environment variables, that can be used by current application.
pkg/files
Package files contains easy to use filesystem functions (like files finder and filter).
Package files contains easy to use filesystem functions (like files finder and filter).
pkg/keys
Package keys provides Keeper struct for concurrent API keys management.
Package keys provides Keeper struct for concurrent API keys management.
pkg/logger
Package logger contains functions for a working with application logging.
Package logger contains functions for a working with application logging.
pkg/pool
Package pool provides compressing pipeline implementation.
Package pool provides compressing pipeline implementation.
pkg/retry
Package retry allows to use retry mechanism (call some function until it does not return non-error result or attempts count is not exceeded).
Package retry allows to use retry mechanism (call some function until it does not return non-error result or attempts count is not exceeded).
pkg/validate
Package validate contains validation functions.
Package validate contains validation functions.
pkg/version
Package version is used as a place, where application version defined.
Package version is used as a place, where application version defined.
pkg
tinypng
Package tinypng is `tinypng.com` API client implementation.
Package tinypng is `tinypng.com` API client implementation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL