1 file was added to this release more than 14 days after its initial publication. Inspect the release files before installing.
fpng_py
A C-Python wrapper for fpng, "a very fast C++ .PNG image reader/writer for 24/32bpp images."
Installation
fpng_py is available via pypi, with pre-build wheels for macOS and Windows with SSE enabled. There are no pre-build wheels for Linux, as they would require building without SSE, which would decrease the performance by a fair bit.
via pypi
pip install fpng_py
via git
pip install git+https://github.com/K0lb3/fpng_py.git
via source
pip install .
Functions
def fpng_cpu_supports_sse41() -> bool:
"""
Returns true if the CPU supports SSE 4.1, and SSE support wasn't disabled by setting FPNG_NO_SSE=1.
"""
...
def fpng_crc32(data: bytes, prev_crc32: int = 0) -> int:
"""
Computes the CRC32 of the given data.
Fast CRC-32 SSE4.1+pclmul or a scalar fallback (slice by 4)
Parameters
----------
data : bytes
The data to compute the CRC32 of.
prev_crc32 : int, optional
The previous CRC32 value. Defaults to 0.
"""
...
def fpng_adler32(data: bytes, adler: int = 1):
"""
Computes the Adler32 of the given data.
Fast Adler32 SSE4.1 Adler-32 with a scalar fallback.
Parameters
----------
data : bytes
The data to compute the Adler32 of.
adler : int, optional
The previous Adler32 value. Defaults to 1.
"""
...
def fpng_encode_image_to_memory(
image: bytes,
w: int,
h: int,
num_chans: int = 0,
flags: CompressionFlags = CompressionFlags.NONE,
) -> bytes:
"""
Encodes the given image into a PNG file in memory.
Fast PNG encoding. The resulting file can be decoded either using a standard PNG decoder or by the fpng_decode_memory() function below.
Parameters
----------
image : bytes
binary data of RGB or RGBA image pixels, R first in memory, B/A last.
w: int
width of the image
h: int
height of the image
num_chans: int, optional
number of channels in the image, 3 for RGB, 4 for RGBA
if num_chans is 0, it will be inferred from the image data.
image's row pitch in bytes must is w*num_chans.
flags: CompressionFlags, optional
flags for the encoder. Defaults to 0.
"""
...
def fpng_encode_image_to_file(
filename: str,
image: bytes,
w: int,
h: int,
num_chans: int = 0,
flags: CompressionFlags = CompressionFlags.NONE,
) -> None:
"""
Encodes the given image into a PNG file.
Fast PNG encoding. The resulting file can be decoded either using a standard PNG decoder or by the fpng_decode_memory() function below.
Parameters
----------
filename : str
path to the file to write the PNG to.
image : bytes
binary data of RGB or RGBA image pixels, R first in memory, B/A last.
w: int
width of the image
h: int
height of the image
num_chans: int, optional
number of channels in the image, 3 for RGB, 4 for RGBA
if num_chans is 0, it will be inferred from the image data.
image's row pitch in bytes must is w*num_chans.
flags: CompressionFlags, optional
flags for the encoder. Defaults to 0.
"""
...
def fpng_get_info(image: bytes) -> Tuple[int, int, int]:
"""
Returns the width, height and number of channels of the given image.
Fast PNG decoding of files ONLY created by fpng_encode_image_to_memory() or fpng_encode_image_to_file().
If fpng_get_info() or fpng_decode_memory() returns FPNG_DECODE_NOT_FPNG, you should decode the PNG by falling back to a general purpose decoder.
fpng_get_info() parses the PNG header and iterates through all chunks to determine if it's a file written by FPNG, but does not decompress the actual image data so it's relatively fast.
Parameters
----------
image : bytes
binary data of RGB or RGBA image pixels, R first in memory, B/A last.
Returns
-------
(width, height, num_chans) : Tuple[int, int, int]
"""
...
def fpng_decode_from_memory(
image: bytes, desired_channels: int
) -> Tuple[bytes, int, int, int]:
"""
Decodes the given image from memory.
fpng_decode_memory decompresses 24/32bpp PNG files ONLY encoded by this module.
If the image is 24bpp and 32bpp is requested, the alpha values will be set to 0xFF.
If the image is 32bpp and 24bpp is requested, the alpha values will be discarded.
Parameters
----------
image : bytes
binary data of RGB or RGBA image pixels, R first in memory, B/A last.
desired_channels : int
number of channels to decode the image to.
3 for RGB, 4 for RGBA
Returns
-------
(image, width, height, num_chans) : Tuple[bytes, int, int, int]
"""
...
def fpng_decode_from_file(
filename: str, desired_channels: int
) -> Tuple[bytes, int, int, int]:
"""
Decodes the given image from a file.
fpng_decode_file decompresses 24/32bpp PNG files ONLY encoded by this module.
If the image is 24bpp and 32bpp is requested, the alpha values will be set to 0xFF.
If the image is 32bpp and 24bpp is requested, the alpha values will be discarded.
Parameters
----------
filename : str
path to the file to decode.
desired_channels : int
number of channels to decode the image to.
3 for RGB, 4 for RGBA
Returns
-------
(image, width, height, num_chans) : Tuple[bytes, int, int, int]
"""
...
Metadata
Release files for fpng-py-fix 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
File added late
1 file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release files before installing.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fpng_py_fix-0.0.3.tar.gz | 285.1 kB | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fpng_py_fix-0.0.3-cp313-cp313-win_amd64.whl | CPython 3.13 | CPython 3.13 | Windows x86-64 | Details |
| fpng_py_fix-0.0.3-cp313-cp313-macosx_15_0_arm64.whl | CPython 3.13 | CPython 3.13 | macOS 15.0+ ARM64 | Details |
Total release size: 355.9 kB
Release files / fpng_py_fix-0.0.3.tar.gz
| Download URL | fpng_py_fix-0.0.3.tar.gz |
|---|---|
| Size | 285.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8b48f640795a744b1d4ca4286f5be264defa651ab8af5c03398d5f64f727ae5d
|
|
BLAKE2b-256 checksum How to use checksums |
a268bea25a1dce93de8beb91bff32ba6abfb45cb37ebec64555edbfde79e5161
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.9
|
Release files / fpng_py_fix-0.0.3-cp313-cp313-win_amd64.whl
File added late
This file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release file before installing.
| Download URL | fpng_py_fix-0.0.3-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 34.9 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
5ca572e7a20dd42edc8fef5d0574030e578f5f1ffc58addc5af1d1862b9f8612
|
|
BLAKE2b-256 checksum How to use checksums |
b04dc3b9d9d53705326dc4548eb52c87089c6fda173843f7a2d9900b32489e56
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.9
|
Release files / fpng_py_fix-0.0.3-cp313-cp313-macosx_15_0_arm64.whl
| Download URL | fpng_py_fix-0.0.3-cp313-cp313-macosx_15_0_arm64.whl |
|---|---|
| Size | 35.9 kB |
| Tags | CPython 3.13 macOS 15.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
a66888cea3eb0430ebec51a08480f9d52d4e840031cee1c27a92555e7e7fcb96
|
|
BLAKE2b-256 checksum How to use checksums |
3947662f93969753d81b915ad676e8bbbd47222719ede5ef7ee2a3d4bc859578
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.9
|