Skip to main content

Zero-dependency image processing library

Project description

Zignal Python Bindings

Zero-dependency image processing library written in Zig with Python bindings.

Installation

pip install zignal-processing

Quick Start

import zignal

# Create RGB color
red = zignal.Rgb(255, 0, 0)
print(f"Red color: {red}")

# Convert to HSV
hsv = red.to_hsv()
print(f"HSV: {hsv}")

# Convert to other color spaces
lab = red.to_lab()
oklab = red.to_oklab()
xyz = red.to_xyz()

Features

  • 12 Color Spaces: RGB, RGBA, HSV, HSL, Lab, XYZ, Oklab, Oklch, LCH, LMS, XYB, YCbCr
  • Seamless Conversions: Convert between any supported color spaces
  • Type Safety: Strong typing with validation for color components
  • Zero Dependencies: No external dependencies, pure Zig implementation
  • High Performance: Native performance with minimal overhead
  • Cross Platform: Works on Linux, macOS, and Windows (x86_64 and ARM64)

Supported Color Spaces

  • RGB/RGBA: Standard RGB with optional alpha channel (0-255)
  • HSV: Hue, Saturation, Value (0-360°, 0-100%, 0-100%)
  • HSL: Hue, Saturation, Lightness (0-360°, 0-100%, 0-100%)
  • Lab: CIELAB perceptual color space
  • XYZ: CIE 1931 XYZ color space
  • Oklab: Perceptually uniform color space by Björn Ottosson
  • Oklch: Cylindrical representation of Oklab
  • LCH: Cylindrical representation of Lab
  • LMS: Long, Medium, Short cone response
  • XYB: Color space used in JPEG XL
  • YCbCr: Luma and chroma components

Examples

Color Space Conversions

# Create a color in any space
hsl = zignal.Hsl(180.0, 50.0, 50.0)  # Cyan-ish color

# Convert to any other space
rgb = hsl.to_rgb()
lab = hsl.to_lab()
oklab = hsl.to_oklab()

# Chain conversions
original = zignal.Rgb(128, 64, 192)
hsv = original.to_hsv()
back_to_rgb = hsv.to_rgb()

Working with Alpha Channel

# Create RGBA color
rgba = zignal.Rgba(255, 128, 0, 200)  # Orange with transparency

# Convert RGB to RGBA (default alpha=255)
rgb = zignal.Rgb(255, 128, 0)
rgba = rgb.to_rgba()

Modern Color Spaces

# Oklab - perceptually uniform color space
oklab = zignal.Oklab(0.5, 0.1, -0.05)
oklch = oklab.to_oklch()  # Convert to cylindrical form

# Work with perceptual properties
print(f"Lightness: {oklch.l}")
print(f"Chroma: {oklch.c}")
print(f"Hue: {oklch.h}")

NumPy Integration (Optional)

If NumPy is installed, you can work with image arrays:

import numpy as np
import zignal

# Create numpy array (supports both RGB and RGBA)
arr_rgb = np.zeros((100, 200, 3), dtype=np.uint8)
arr_rgb[50, 100] = [255, 0, 0]  # Red pixel

# Convert to Image (allocates RGBA internally for SIMD performance)
img = zignal.Image.from_numpy(arr_rgb)

# For zero-copy with 4-channel arrays, use the helper:
arr_rgba = zignal.Image.add_alpha(arr_rgb)  # Adds alpha=255
img = zignal.Image.from_numpy(arr_rgba)  # Zero-copy!

# Convert back to numpy
arr2 = img.to_numpy()  # Returns RGBA (4 channels) by default
arr3 = img.to_numpy(include_alpha=False)  # Returns RGB (3 channels)

# Load and save images
img = zignal.Image.load("input.png")  # Supports PNG and JPEG
img.save("output.png")

Performance Note: The Image class uses RGBA storage internally for SIMD-optimized operations. This provides 2-5x performance improvements for resize and interpolation operations. When using 3-channel RGB arrays, they are automatically converted to RGBA with alpha=255.

Note: NumPy is not required for basic color operations.

Building from Source

Requires Zig compiler:

git clone https://github.com/bfactory-ai/zignal
cd zignal/bindings/python
pip install -e .

License

MIT License

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

zignal_processing-0.2.0.dev394-cp312-cp312-macosx_11_0_arm64.whl (156.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

zignal_processing-0.2.0.dev394-cp312-cp312-macosx_10_9_x86_64.whl (166.3 kB view details)

Uploaded CPython 3.12macOS 10.9+ x86-64

zignal_processing-0.2.0.dev394-cp311-cp311-win_amd64.whl (192.1 kB view details)

Uploaded CPython 3.11Windows x86-64

zignal_processing-0.2.0.dev394-cp311-cp311-macosx_11_0_arm64.whl (156.5 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

zignal_processing-0.2.0.dev394-cp311-cp311-macosx_10_9_x86_64.whl (166.4 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

zignal_processing-0.2.0.dev394-cp310-cp310-win_amd64.whl (192.3 kB view details)

Uploaded CPython 3.10Windows x86-64

zignal_processing-0.2.0.dev394-cp310-cp310-macosx_11_0_arm64.whl (156.4 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

zignal_processing-0.2.0.dev394-cp310-cp310-macosx_10_9_x86_64.whl (166.6 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

File details

Details for the file zignal_processing-0.2.0.dev394-cp312-cp312-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for zignal_processing-0.2.0.dev394-cp312-cp312-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 8b1b9c8ea548cf8cbee0d18ba9424eaffbf849155c9b722b6f24fb5901af5057
MD5 7c2247333ff0e98406cae19ddf6e0dd9
BLAKE2b-256 efe5736b112f863d53e631fbceaf64039131582a674e9d2ef40fb63f20a7b96f

See more details on using hashes here.

File details

Details for the file zignal_processing-0.2.0.dev394-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for zignal_processing-0.2.0.dev394-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 caba885ebf58eda6d311495d573d0602753d317c2a9843470a5e1591a630a61a
MD5 b6096c5aaee7d1c1272cd4a8489b3085
BLAKE2b-256 b567c485cba9aeda235167fb0c949b135bdefb3dce6be6a7d18d8c46b748780d

See more details on using hashes here.

File details

Details for the file zignal_processing-0.2.0.dev394-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for zignal_processing-0.2.0.dev394-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 4982b37885cf4cb1960e2eb4c0a2d82d683de63785f2fd7ff1d49ba61179bc62
MD5 e3dbbb4fc76ac8a5a3bf7da8f9d4cb59
BLAKE2b-256 f104fbe0d30447db1ddcd67ac65e3dced05981ff894a7ed1a9e25bdad22f786d

See more details on using hashes here.

File details

Details for the file zignal_processing-0.2.0.dev394-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for zignal_processing-0.2.0.dev394-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a3470cbbcf9cfdd3f2d426e7850f302bda8500f9f0616fd5ad5a0b33d6e3681f
MD5 7be72154fcbb37bedada1895fdf0f0d3
BLAKE2b-256 f803aee9c15faf3448ab4543cf367f22c428994a185b6ec4212e2232a58fe9d7

See more details on using hashes here.

File details

Details for the file zignal_processing-0.2.0.dev394-cp311-cp311-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for zignal_processing-0.2.0.dev394-cp311-cp311-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 0b599c08ffc715574139a18d556b6084892d3329385d76ff65d8650cee6a383c
MD5 bd988fe85d4df57df8fe9ad0532a1f01
BLAKE2b-256 8558e06fcd0518ef8bc1478d0584d8c3a7588d0274f185c2abeda46e169751d9

See more details on using hashes here.

File details

Details for the file zignal_processing-0.2.0.dev394-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for zignal_processing-0.2.0.dev394-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c92865f8e13f389e5d764960d4333f97e6df8bc5616d3b0f754839e3c413d1e0
MD5 0e3198044e9b93bf5efd9ebb5944b604
BLAKE2b-256 963bc9b2be1d37e59dc44196211c4ee8165af8b8084d7e7c975555006b28f666

See more details on using hashes here.

File details

Details for the file zignal_processing-0.2.0.dev394-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for zignal_processing-0.2.0.dev394-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 277dbf473ce3170c01d53656bc26adda7d009610083647b28dca16b80e7cccff
MD5 eed07c9f653d4aa4bc50aa2b2ea7f520
BLAKE2b-256 e04cb277badc93d41816cb95a4ad2ec80e52b45705583062a752cdbd1ea3e5ed

See more details on using hashes here.

File details

Details for the file zignal_processing-0.2.0.dev394-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for zignal_processing-0.2.0.dev394-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 183782743cd83337d471b109b18e6349bf88537df5e0a9a48ae1efa03ea7a48b
MD5 d0d75e448360996705e6539c8a524297
BLAKE2b-256 ce595244a0f2f46f7ee9165422f2f8b011300399ffc46b582e9422a4a49e2d87

See more details on using hashes here.

File details

Details for the file zignal_processing-0.2.0.dev394-cp310-cp310-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for zignal_processing-0.2.0.dev394-cp310-cp310-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 363e6c5d90d46c0d1ab33ed5436f0c786fa5b6fafbc08941806bb1a5d074fe20
MD5 c9b6ce2bfcbd18a58fc1acd03451a785
BLAKE2b-256 4288539ada9050b60155f990e52fdd4c7573434a8eba2d60928153ec3f829468

See more details on using hashes here.

File details

Details for the file zignal_processing-0.2.0.dev394-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for zignal_processing-0.2.0.dev394-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d6435f18a1cb94e74daacf6ca23ac784264fd2209577c72c1d3031a190a10df5
MD5 51e7cb95f83fca4b10147e4598b0b674
BLAKE2b-256 5a6b44b183afcd1ca75f702826a01a9f3f01e70b640a917ac68e9aa7117a7561

See more details on using hashes here.

File details

Details for the file zignal_processing-0.2.0.dev394-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for zignal_processing-0.2.0.dev394-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 525d0dbd978cb5727c32a1caa2edfcd5299da016c0fe800f468b52d6154fe496
MD5 21c9d518434d7b11c064e33ff3790ba7
BLAKE2b-256 0154883c4debb87e52295b9e6799508bc739e0ebf8b382c7375282772b57a559

See more details on using hashes here.

Supported by

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