Skip to main content

farbfeld.py

Build Status codecov Language grade: Python PyPI version

This is a small Python module for reading and writing pixel data from farbfeld images (https://tools.suckless.org/farbfeld/).

Installation

The module is available on PyPI: https://pypi.org/project/farbfeld/

You can install it with pip:

pip install farbfeld

Usage

To read an image, open the desired file and read the pixels from it using farbfeld.read:

import farbfeld

with open('image.ff', 'rb') as f:
    data = farbfeld.read(f)

Note that since farbfeld stores pixel components as 16-bit unsigned integers, you may have to normalize them or scale them to a different range (e.g. 8-bit). For example, using NumPy and Matplotlib:

import farbfeld
import numpy as np
import matplotlib.pyplot as plt

with open('image.ff', 'rb') as f:
    data = farbfeld.read(f)
    data_8bit = np.array(data).astype(np.uint8)
    plt.imshow(data_8bit, interpolation='nearest')
    plt.show()

To write a farbfeld image, open the desired file and write the pixels into it using farbfeld.write:

import farbfeld

# An example 2x2 image
data = [
    [[1, 2, 3, 4], [5, 6, 7, 8]],
    [[9, 10, 11, 12], [13, 14, 15, 16]],
]

with open('image.ff', 'wb') as f:
    farbfeld.write(f, data)

Source code

The source code is available on GitHub: https://github.com/jmp/farbfeld

Metadata

Release files for farbfeld 0.2.2

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

Source distribution (sdist)

Source distribution for farbfeld 0.2.2
File Size Uploaded Provenance
farbfeld-0.2.2.tar.gz 4.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for farbfeld 0.2.2
File Interpreter ABI Platform
farbfeld-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 10.4 kB

Release files / farbfeld-0.2.2.tar.gz

Download URL farbfeld-0.2.2.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
986d3121a3e8dc54c9043287caac378b92c7e35931846674ba2fd60055ec4f99
BLAKE2b-256 checksum
How to use checksums
5348c81264c0566dee78ea95f8ccbf9c587c31602585fbf6a0c1131049dd0d1b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

Release files / farbfeld-0.2.2-py3-none-any.whl

Download URL farbfeld-0.2.2-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d1a129a1dd3741e814dfff5db1a112a880ea5982fbf25ab6ea4ebf4da72826eb
BLAKE2b-256 checksum
How to use checksums
59bb95e5c90dd4de9299264cf7a1384fcf346b3e9ecf9ed06fb40b966f25ae96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

Security for farbfeld 0.2.2

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.

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