Skip to main content

Access api.tinypng.org from the shell and python scripts

Project description

## TinyPNG API

Python module and command line tool for [tinypng.com][1]

Shrink PNG files. Advanced lossy compression for PNG images
that preserves full alpha transparency. Now also works with
JPEG files.

Note: This project is not affiliated with [tinypng.com][1]
or [Voormedia B.V.][2]

Important: You require an API key which you may obtain from
[tinypng.com/developers][3].

Besides specifying keys via command line arguments you can:

1. Set the environment variable TINYPNG_API_KEY
2. Create a .tinypng.keys file in your home directory
3. Create a tinypng.keys file in the current directory

### Programatic api

from tinypng import shrink_file

# implicitly writes to "your_file.tiny.png"
shrink_info = shrink_file("your_file.png", api_key='your_key_here')

shrink_info = shrink_file(
"your_input_file.png",
api_key='your_key_here',
out_filepath="your_output_file.png"
)

shrink_info == {
"output": {
"type": "image/png",
"filepath": "/path/your_input_file.png",
"size": 36988,
"ratio": 0.8279,
"url": "https://api.tinypng.com/output/abcdefg123456.jpg"
},
"url": "https://api.tinypng.com/output/abcdefg123456.jpg",
"compression_count": "123",
"input": {
"type": "image/png",
"size": 44679
}
}


[1]: https://tinypng.com
[2]: http://voormedia.com/
[3]: https://tinypng.com/developers

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tinypng-2.1.1.zip (10.0 kB view details)

Uploaded Source

File details

Details for the file tinypng-2.1.1.zip.

File metadata

  • Download URL: tinypng-2.1.1.zip
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for tinypng-2.1.1.zip
Algorithm Hash digest
SHA256 ebfeebed0cec704a66e09e4463123f91d5547fcd415887fc82a693a2cf9aba54
MD5 74521e8794f81d27318772096d67b999
BLAKE2b-256 18c88e0dff2e357f5e432066b06510a603baee8d9a64ca01d3ace0068c896d30

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page