Skip to main content

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

Metadata

Release files for tinypng 3.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tinypng 3.0.0
File Size Uploaded
tinypng-3.0.0.tar.gz 5.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tinypng 3.0.0
File Interpreter ABI Platform
tinypng-3.0.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 13.5 kB

Release files / tinypng-3.0.0.tar.gz

Download URL tinypng-3.0.0.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
40c5c3f7c43f60a1ab267cc6f341ebec3084f121f60814488d823d1ccc3db724
BLAKE2b-256 checksum
How to use checksums
1b1b9276d13092b84b1c170cb3511c73f9a63a2a6bf638de4b70d12ff8206174
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / tinypng-3.0.0-py2.py3-none-any.whl

Download URL tinypng-3.0.0-py2.py3-none-any.whl
Size 7.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
af5317d6e37190097212632abff6d1a0f86c86e68c364d15b9a0821728af99e9
BLAKE2b-256 checksum
How to use checksums
c3ff830f973894d7f130101cd19a9907a36c669d3b39f789f64604bfb8a0aa65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

3.0.0 This release

2 release files

2.1.4

3 release files

2.1.3

3 release files

2.1.2

1 release file

2.1.1

1 release file

2.1.0

1 release file

2.0.1

1 release file

2.0.0

1 release file

1.4.0

1 release file

1.3.0

1 release file

1.2.1

1 release file

1.2.0

1 release file

1.1.2

2 release files

1.1.1

1 release file

1.1.0

1 release file

1.0.5

1 release file

1.0.4

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page