Skip to content
A Bash script for shrinking PNG files, using
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

A Bash script for shrinking PNG/JPEG files, using

sha1sum: 6a4c4d06cec19b44c8b5512a1136468a7b7dce71

Buy Me a Coffee at


Bash 4 ( and above ), and curl.

tinypng - Shrink PNG/JPEGs using service.

tinypng [-dkph] -f FILE

Shrink PNG/JPEGs using service.

On first execution, or if ~/.tinypng.apikey is not present, tinypng will ask for an API key.
Obtain your API key from, copy and paste it when prompted.

-f,--file FILE              Select a FILE to be shrinked.
-d,--download DIRECTORY     Download all shrinked images to DIRECTORY.
-o,--overwrite              When -d is being used, overwrite the source images with the downloaded ones.
-k,--key API_KEY            Use API_KEY, instead of the one stored in ~/.tinypng.apikey.
-p,--print                  When -d is being used, the URLs of the shrinked images are not being printed to stdout.
Use this option to force printing even when using -d.
Otherwise, this option is set implicitly.
-- FILES                    Ignore any options to come.
Everything after this option is considered a file.
-h,--help                   Show this message and exit successfully.

Shrink foo.jpg, bar.png, baz.png and print the result URLs to stdout.
$ tinypng -f foo.jpg -f bar.png -f baz.png
$ tinypng -- foo.jpg bar.png baz.png
Shrink foo.jpg, bar.png, baz.png and download the result images to tiny_pngs/ directory
$ tinypng -d tiny_pngs/ -- foo.jpg bar.png baz.png


Rany Albeg Wein


Use it as if you wrote it yourself.

You can’t perform that action at this time.