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 Distribution

zignal_processing-0.4.0.tar.gz (17.4 kB view details)

Uploaded Source

Built Distributions

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

zignal_processing-0.4.0-cp313-cp313-win_amd64.whl (326.5 kB view details)

Uploaded CPython 3.13Windows x86-64

zignal_processing-0.4.0-cp313-cp313-manylinux1_x86_64.whl (307.5 kB view details)

Uploaded CPython 3.13

zignal_processing-0.4.0-cp313-cp313-macosx_11_0_arm64.whl (259.5 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

zignal_processing-0.4.0-cp313-cp313-macosx_10_9_x86_64.whl (292.5 kB view details)

Uploaded CPython 3.13macOS 10.9+ x86-64

zignal_processing-0.4.0-cp312-cp312-win_amd64.whl (326.5 kB view details)

Uploaded CPython 3.12Windows x86-64

zignal_processing-0.4.0-cp312-cp312-manylinux1_x86_64.whl (307.5 kB view details)

Uploaded CPython 3.12

zignal_processing-0.4.0-cp312-cp312-macosx_11_0_arm64.whl (259.4 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

zignal_processing-0.4.0-cp312-cp312-macosx_10_9_x86_64.whl (292.5 kB view details)

Uploaded CPython 3.12macOS 10.9+ x86-64

zignal_processing-0.4.0-cp311-cp311-win_amd64.whl (326.6 kB view details)

Uploaded CPython 3.11Windows x86-64

zignal_processing-0.4.0-cp311-cp311-manylinux1_x86_64.whl (307.3 kB view details)

Uploaded CPython 3.11

zignal_processing-0.4.0-cp311-cp311-macosx_11_0_arm64.whl (259.3 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

zignal_processing-0.4.0-cp311-cp311-macosx_10_9_x86_64.whl (292.4 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

zignal_processing-0.4.0-cp310-cp310-win_amd64.whl (326.7 kB view details)

Uploaded CPython 3.10Windows x86-64

zignal_processing-0.4.0-cp310-cp310-manylinux1_x86_64.whl (307.5 kB view details)

Uploaded CPython 3.10

zignal_processing-0.4.0-cp310-cp310-macosx_11_0_arm64.whl (259.4 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

zignal_processing-0.4.0-cp310-cp310-macosx_10_9_x86_64.whl (292.6 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

File details

Details for the file zignal_processing-0.4.0.tar.gz.

File metadata

  • Download URL: zignal_processing-0.4.0.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for zignal_processing-0.4.0.tar.gz
Algorithm Hash digest
SHA256 b88dc7390af2d4f3f656b13c9f782be6e37bc5226434c7b1227122e58176df71
MD5 4e4b93eb5c982339359a509ff8ca9a83
BLAKE2b-256 27c391d245a58d09ddd88b979a0bf65219f110ab5699eb37378c2287ba61e132

See more details on using hashes here.

File details

Details for the file zignal_processing-0.4.0-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for zignal_processing-0.4.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 f426acfebfd8cd10a765bb3eac708493b07d5a8de706f2403198d32e7d3b3a0d
MD5 e29fbee4a7466b8d7efb7a107997bc5b
BLAKE2b-256 976c0baee536b5bee625b25284541a596bca9afcfa222a3bb6a0ef26f1e8b9c1

See more details on using hashes here.

File details

Details for the file zignal_processing-0.4.0-cp313-cp313-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for zignal_processing-0.4.0-cp313-cp313-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 f147419ef646cde0a0365c811165b038701abf9ad85d55adb65a8f2c7df92bbb
MD5 9a8261217553f7e5b3277d288620a49e
BLAKE2b-256 bfa85a7ff78192558fac4a363af4075dfc2ef3776e54d3a912bd7b5f5833c42e

See more details on using hashes here.

File details

Details for the file zignal_processing-0.4.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for zignal_processing-0.4.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 719e6ee107300e7b40601030f1ec0df55f5cc5525a98f053db42d9a16baf8d3a
MD5 79d5707689bcbc45cf0c8225e602ccfc
BLAKE2b-256 91708fe096dbbb3be8706f076b1b59c7f33fcd6b87e3e5be2803fb63f7053847

See more details on using hashes here.

File details

Details for the file zignal_processing-0.4.0-cp313-cp313-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for zignal_processing-0.4.0-cp313-cp313-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 bfca45d5d89bfdc66803e9a392bac283a558a32c5a7b10d83f45eb42fe2ca08f
MD5 998949497ebc9f498848f633b1eec1d3
BLAKE2b-256 0ce421cb3da0895a44c9c4e1d369573c4ac87d10e6ba756af38e05a7444d578c

See more details on using hashes here.

File details

Details for the file zignal_processing-0.4.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for zignal_processing-0.4.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 5b41adfc1c65b0b6f714aba8bb419618a7f52a361b0a28a668945cfa24e415b2
MD5 7f36fedf860207e84847544d8a4277fa
BLAKE2b-256 b6e257ec0e883192a8cb3656ec459bf45883dc180ad8c8e83524f75c253cd3d0

See more details on using hashes here.

File details

Details for the file zignal_processing-0.4.0-cp312-cp312-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for zignal_processing-0.4.0-cp312-cp312-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 e26c7eb3a7393db9c1cdb9d91404aaba0e2dd142d7637e15a7fb2bb4d2371759
MD5 7222281a2799203f8c967964539b2891
BLAKE2b-256 4aadbf51831f031d9e9fcb07adb8b54137fb5002e40c625d6dc2d3a19b2eb3ac

See more details on using hashes here.

File details

Details for the file zignal_processing-0.4.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for zignal_processing-0.4.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 094217c21834c28dd7f293a3e8a3813f9b1c676c524026845f8bbcb214bb04ed
MD5 5b124d326bae61e883f7eefc59922c12
BLAKE2b-256 2f70ad9f46a6a9c5c1fa561023b9763f1d96982f822bbe00e0001dae3a5f5d70

See more details on using hashes here.

File details

Details for the file zignal_processing-0.4.0-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for zignal_processing-0.4.0-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0f28a3d02fad3dc0de13c91e8c32745fa0ad965fc6e020a6095143db6fc26982
MD5 d8257f1a2e2530cf5ddb8c653d4e0c4a
BLAKE2b-256 29b99263c45793721a8ade8a729acf7e350296d50cda91e49718e4b5ee3fd50a

See more details on using hashes here.

File details

Details for the file zignal_processing-0.4.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for zignal_processing-0.4.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 e0faee41a78241f6d14cf7725ce67058856ef872ca2439c9d7698b234427cfff
MD5 22f4b2de8de198802ad778a4fa3082b7
BLAKE2b-256 832bd26d5e911858191230374704fe1e50ddbc0909af5e1461df891c17036e82

See more details on using hashes here.

File details

Details for the file zignal_processing-0.4.0-cp311-cp311-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for zignal_processing-0.4.0-cp311-cp311-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 72dc4510d59e0130895cd4b82e4b40d9a41b60b76051a34de36bfa3e47a880e0
MD5 5ba2cee15f05751ac9ce9e932d97ffcd
BLAKE2b-256 a6600930a5f0e81ef7a1fd1f60f74b6734724ddf7eb790738071b3b83de3317e

See more details on using hashes here.

File details

Details for the file zignal_processing-0.4.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for zignal_processing-0.4.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 88dc00013961ed5476008a14c7754baff2217100e424bfc64c1195d1737933ee
MD5 e2814a68bb4d75fe9a6ef94fad675274
BLAKE2b-256 0d1fffaee19bef1cd5e1cc8c95cafac635ae3b07e4cea279b4349812c8794833

See more details on using hashes here.

File details

Details for the file zignal_processing-0.4.0-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for zignal_processing-0.4.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 97899c7de3a35f291d8b57a83f11398df7b4c0736ced7698599e418113412ae8
MD5 730a755f32486514148a3e7797d715d6
BLAKE2b-256 cec3ca60e77ff174728aa816c0367462fa6094a5bde86e08f5b97795d028c38f

See more details on using hashes here.

File details

Details for the file zignal_processing-0.4.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for zignal_processing-0.4.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d3b0393cab41033359160ec5beff082b9f86d36e9c19ca6b22506a85256678df
MD5 db85bf163b9a651cb675e61db6ac6635
BLAKE2b-256 ecd621332b7b952124b31bdedec86b064e7573c37e24c93ddf1a1f4fd8951efc

See more details on using hashes here.

File details

Details for the file zignal_processing-0.4.0-cp310-cp310-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for zignal_processing-0.4.0-cp310-cp310-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 2960dbd3ba6b406ff6ec219050bd1b5bc5f913cc3c893b191ad3dc1d3ed852b5
MD5 fc5001dbea0a3ec5d37c22f639889492
BLAKE2b-256 91ac07151608268e15e88a7274312b37d8163fa409aa29806c810fc2d8801310

See more details on using hashes here.

File details

Details for the file zignal_processing-0.4.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for zignal_processing-0.4.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e1fc40071156d4e9e27b6819ad72ea12887c7cc3586690aa3e22871165985813
MD5 7e8f41b1b2ece838fef986fe5bb472e9
BLAKE2b-256 80a6ed9644bb02ee4699765b723e3cb1f034a94e4e724e0d66174f1617e9ade7

See more details on using hashes here.

File details

Details for the file zignal_processing-0.4.0-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for zignal_processing-0.4.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c468dbafceada83fbd4f3f292a54ffa850d192d8429d3caf658f573ba1e5c29c
MD5 b34ff68a0ebf54c55e6836d0067635f9
BLAKE2b-256 9d8107ba92250a46cb2fb152fdbcb79a50a66cd3ab0061e8b182c34659e2ffea

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