Skip to main content

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 0.0.3

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

Source distribution (sdist)

Source distribution for fpng-py 0.0.3
File Size Uploaded
fpng_py-0.0.3.tar.gz 226.3 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for fpng-py 0.0.3
File
fpng_py-0.0.3-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
fpng_py-0.0.3-cp310-cp310-win32.whl CPython 3.10 CPython 3.10 Windows x86-32 Details
fpng_py-0.0.3-cp310-cp310-macosx_10_9_x86_64.whl CPython 3.10 CPython 3.10 macOS 10.9+ x86-64 Details
fpng_py-0.0.3-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
fpng_py-0.0.3-cp39-cp39-win32.whl CPython 3.9 CPython 3.9 Windows x86-32 Details
fpng_py-0.0.3-cp39-cp39-macosx_10_9_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.9+ x86-64 Details
fpng_py-0.0.3-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
fpng_py-0.0.3-cp38-cp38-win32.whl CPython 3.8 CPython 3.8 Windows x86-32 Details
fpng_py-0.0.3-cp38-cp38-macosx_10_9_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.9+ x86-64 Details
fpng_py-0.0.3-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details
fpng_py-0.0.3-cp37-cp37m-win32.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-32 Details
fpng_py-0.0.3-cp37-cp37m-macosx_10_9_x86_64.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64 Details

Total release size: 654.2 kB

Release files / fpng_py-0.0.3.tar.gz

Download URL fpng_py-0.0.3.tar.gz
Size 226.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d96735dcda0f421af9fd4d633bffa9373731a7e2933c21460a8bf8530dc2921a
BLAKE2b-256 checksum
How to use checksums
a3828b9f91a46315acdcf19c4c60aacb37104944ff17e0f11454290fafebebc8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / fpng_py-0.0.3-cp310-cp310-win_amd64.whl

Download URL fpng_py-0.0.3-cp310-cp310-win_amd64.whl
Size 35.7 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
600720ca889eca9ce1b7d57b0167757080de230edd3961191763db78cb8b0e60
BLAKE2b-256 checksum
How to use checksums
bfc59ab850f95e03395539e6f7bdcdc167c13faedc74203546f59c700b00b4b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / fpng_py-0.0.3-cp310-cp310-win32.whl

Download URL fpng_py-0.0.3-cp310-cp310-win32.whl
Size 34.3 kB
Tags CPython 3.10 Windows x86-32
SHA-256 checksum
How to use checksums
2b4ec5d2b2168fea1942fef7fc63c294ce5bc2708224516e64fb04db45d83929
BLAKE2b-256 checksum
How to use checksums
aeda0dc4dbe00325a2bbdf42e6b4c2aa9d6a6caef4396f03542ffd58caff7b5c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / fpng_py-0.0.3-cp310-cp310-macosx_10_9_x86_64.whl

Download URL fpng_py-0.0.3-cp310-cp310-macosx_10_9_x86_64.whl
Size 36.9 kB
Tags CPython 3.10 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
753df3c4487e5b795a956b4bf592d762dd70494de3282110d9359367536c996a
BLAKE2b-256 checksum
How to use checksums
f5e6db5fdc55f18a2de23d9348162d14d11c3c7295ebef4e07bc8bef0ae719a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / fpng_py-0.0.3-cp39-cp39-win_amd64.whl

Download URL fpng_py-0.0.3-cp39-cp39-win_amd64.whl
Size 35.7 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
47bc77da0cc4445246ddf50580b4c04f4d08f3106b9edb32682bc5550ca6227f
BLAKE2b-256 checksum
How to use checksums
0daeda33110e00e0c7fc78862b7e646325dd257d79fdf7473aec4cd642bc592b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / fpng_py-0.0.3-cp39-cp39-win32.whl

Download URL fpng_py-0.0.3-cp39-cp39-win32.whl
Size 34.3 kB
Tags CPython 3.9 Windows x86-32
SHA-256 checksum
How to use checksums
b4309d7223683456b666c4193975cb3f8a26ce3c39b72251740c39d37001f236
BLAKE2b-256 checksum
How to use checksums
3a427b52586d0c98bb7d08af431e070479a27eda08cf5eca858684e9897fd6b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / fpng_py-0.0.3-cp39-cp39-macosx_10_9_x86_64.whl

Download URL fpng_py-0.0.3-cp39-cp39-macosx_10_9_x86_64.whl
Size 36.9 kB
Tags CPython 3.9 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
abcb3fec6d753f793257d3693a1eedcec012acfa26297b2618b266deffe897bf
BLAKE2b-256 checksum
How to use checksums
d6b728ec56157dc69a9833feeff2acb1e7b487bc4677e218d4248a2cb0b398e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / fpng_py-0.0.3-cp38-cp38-win_amd64.whl

Download URL fpng_py-0.0.3-cp38-cp38-win_amd64.whl
Size 35.8 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
8b37ba078b94584c93d45a135e32e155920694a75da96855d4b1b9109c6494cc
BLAKE2b-256 checksum
How to use checksums
1928aa721c1f2f1246a6e7b3d126664040c9b350369a4ca6b4831fc0422bbf26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / fpng_py-0.0.3-cp38-cp38-win32.whl

Download URL fpng_py-0.0.3-cp38-cp38-win32.whl
Size 34.4 kB
Tags CPython 3.8 Windows x86-32
SHA-256 checksum
How to use checksums
53a27a50d9d0f46af7d483b9b62e3ab8c4172b40a6c32f4c23466ea67cdf95be
BLAKE2b-256 checksum
How to use checksums
61bcc8e8cf749e6078028d883d07a429e8095b4a9625226b7f8e49eb6c4b7760
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / fpng_py-0.0.3-cp38-cp38-macosx_10_9_x86_64.whl

Download URL fpng_py-0.0.3-cp38-cp38-macosx_10_9_x86_64.whl
Size 36.9 kB
Tags CPython 3.8 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
252c52e7e5331850099d748027a17a42b1937f011642ac5653237bda91430678
BLAKE2b-256 checksum
How to use checksums
f440d750119af3ca967405233e6f1011935dfc921c86f6a9d5ccada7729471c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / fpng_py-0.0.3-cp37-cp37m-win_amd64.whl

Download URL fpng_py-0.0.3-cp37-cp37m-win_amd64.whl
Size 35.8 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
95bddea6d19688e82227f8200e8e560547cd3caf4e573d9ecde32c7d2d4ce3a2
BLAKE2b-256 checksum
How to use checksums
a3800f0926e3840f9c2d07a912fa9d8026137f159b9bc4bb5a8ea4447696897c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / fpng_py-0.0.3-cp37-cp37m-win32.whl

Download URL fpng_py-0.0.3-cp37-cp37m-win32.whl
Size 34.4 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
6e97cfce157a797231d2cc67da2dcd85dfbd3787a66f948f2e3f2619f569449e
BLAKE2b-256 checksum
How to use checksums
c84d43514d8b3c3a6a3b59ba6a3cf4ac46a244c5d3b0d93a72c2a7ce668c1afd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / fpng_py-0.0.3-cp37-cp37m-macosx_10_9_x86_64.whl

Download URL fpng_py-0.0.3-cp37-cp37m-macosx_10_9_x86_64.whl
Size 36.8 kB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
37ca86265afc0947e3187bd2e3dad533a2491d64d8b0b6ccb76ae3932237475d
BLAKE2b-256 checksum
How to use checksums
cd0891034178cf271077a91402ebd3a6370823f220c69d10ecabd59b37aaffed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release history Release notifications | RSS feed

This release

0.0.3 This release

13 release files

0.0.2

13 release files

0.0.1

13 release files

0.0.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