Skip to main content

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

Project description

Python module and command line tool for tinypng.com

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 or Voormedia B.V.

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

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

Project details


Download files

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

Source Distributions

tinypng-2.1.4.zip (10.7 kB view details)

Uploaded Source

tinypng-2.1.4.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

tinypng-2.1.4-py2.py3-none-any.whl (7.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file tinypng-2.1.4.zip.

File metadata

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

File hashes

Hashes for tinypng-2.1.4.zip
Algorithm Hash digest
SHA256 c999b586d4eb41689085964167a2b9376dd9ee75a08810fb250e78891d94a5cc
MD5 d230d9bb48ba68e525f4722e1f27cec1
BLAKE2b-256 a94623d462739ba441b46dbbe0204d98a77cd54c0476d568454f87ce17957b88

See more details on using hashes here.

File details

Details for the file tinypng-2.1.4.tar.gz.

File metadata

  • Download URL: tinypng-2.1.4.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for tinypng-2.1.4.tar.gz
Algorithm Hash digest
SHA256 10df70b1974a8323b4f5978bd266ae81af603436e325a1758a40fb88ffb57699
MD5 82f0fbc2d1d7e754fceb1ee4d41159c8
BLAKE2b-256 1868575ecbca6c9a356a0b05056b95484871817493fcc155013fdc7bd3c2ec9d

See more details on using hashes here.

File details

Details for the file tinypng-2.1.4-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for tinypng-2.1.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c8e0e35c8da667f65dc2c5ed267a4a1e1cd67b7f80dba71f652fdb21549e1b99
MD5 36d3fc7e721f606b3592d15830b7a69f
BLAKE2b-256 229b5de328d2391db9b4c874d71d346b0da35ef40255df5524eab9370539df6c

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