TinyPNG
A lightweight, minimal PNG library.
Installation
pip install lib-tiny-png
Usage
from tiny_png import ColorType, load_image, save_image
width, height = 4, 2
pixels = bytes([255, 0, 0, 255] * (width * height)) # Red RGBA pixels
save_image("red.png", width, height, pixels)
image = load_image("red.png")
if image.error:
print(image.error)
else:
print(image.width, image.height, image.color_type) # 4 2 ColorType.RGBA
print(image.buffer == pixels) # True
gray = bytes(range(16))
save_image("gray.png", 4, 4, gray, ColorType.GRAYSCALE)
API Reference
ColorType
GRAYSCALE (1 byte per pixel), GRAYSCALE_ALPHA (2), RGB (3), RGBA (4).
save_image(file_path, width, height, data, color_type=ColorType.RGBA)
Saves row-major 8-bit pixels as a PNG file.
Parameters:
file_path(str) - The output file path.width,height(int) - The image size in pixels.data(bytes,bytearrayor any uint8 buffer) - Pixels of sizewidth * height * channels.color_type(ColorType, optional) - The color type of the pixels.
Returns:
bool-Trueif the image is saved.
Raises:
ValueError- If the size ofdatadoes not match the image size.
load_image(file_path)
Loads a PNG file.
Returns:
PNGData- With fieldswidth,height,color_type,buffer(bytes) anderror(str, empty on success).
Metadata
Release files for lib-tiny-png 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| lib_tiny_png-1.0.0.tar.gz | 13.1 kB | Without provenance | Details |
Release files / lib_tiny_png-1.0.0.tar.gz
| Download URL | lib_tiny_png-1.0.0.tar.gz |
|---|---|
| Size | 13.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
79f8a9bc046ceb1bc8d98490d36f89038b2ef8e3fff663102f2e538dc0e7812c
|
|
BLAKE2b-256 checksum How to use checksums |
97ee750836433c02ec4226f8ad0e16a67f8ef9e59a603c776679a2da2be09345
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.13
|
Security for lib-tiny-png 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.