Skip to main content

Library for reading/writing farbfeld images.

Project description

farbfeld.py

Build Status codecov Language grade: Python

This is a small Python module for extracting pixel data from farbfeld images: https://tools.suckless.org/farbfeld/

Currently it only has one public function, farbfeld.read. It returns the pixels as row by row, column by column as a nested list.

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()

Source code

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

farbfeld-0.2.0.tar.gz (4.6 kB view hashes)

Uploaded Source

Built Distribution

farbfeld-0.2.0-py3-none-any.whl (5.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page