Skip to content

Releases: bfactory-ai/zignal

zignal 0.1.0

21 Jul 02:26

Choose a tag to compare

Zignal 0.1.0 Release Notes

First Public Release - Zero-Dependency Image Processing for Zig

This first public release of Zignal, a zero-dependency image processing library heavily inspired by dlib.
Zignal is already powering virtual makeup try-on technology at Ameli by B Factory Inc on the web and on Android.

Core Features

Image Processing

  • Native Image Type: Generic Image(T) supporting any pixel type (u8, f32, RGB, RGBA, etc.)
  • Memory-Efficient Views: Sub-images that share memory with parent images (zero-copy)
  • Image I/O: Native codecs with no external dependencies
    • PNG: Full codec with comprehensive format support
      • All PNG color types: RGB, RGBA, Grayscale, Palette
      • 8-bit and 16-bit depths, interlaced images
      • Transparency and gamma correction support
    • JPEG: Decoder for most common variants
      • Baseline and progressive JPEG support with chroma subsampling
      • YCbCr and grayscale color spaces
      • High-quality decoding with proper color space handling
  • Image Transformations: Resize, crop, rotate, flip operations
  • Pixel-Level Operations: Direct pixel manipulation with type safety

Color Science (12 Color Spaces)

Comprehensive color space ecosystem with seamless conversions:

  • sRGB Family: Rgb, Rgba (packed struct for WASM efficiency)
  • Perceptual: Hsl, Hsv for intuitive color manipulation
  • Lab Family: Lab, Lch for perceptually uniform editing
  • Modern: Oklab, Oklch for improved perceptual uniformity
  • Device: Xyz, Lms for color science applications
  • Specialized: Xyb, Ycbcr for advanced workflows

Key Benefits:

  • Automatic conversion between any color spaces: you can use a Lab color to draw a line on a Rgb image.
  • Consistent API across all color types
  • Optimized packed structs for WASM interoperability

Geometry & Transforms

  • Primitives: Point, Rectangle with comprehensive operations
  • Transform System: Projective, Affine, and Similarity transforms using homogeneous coordinates
  • Convex Hull: Efficient convex hull computation for point sets

Drawing & Canvas API

Advanced 2D rendering with antialiasing:

  • Primitives: Lines, circles, polygons with smooth rendering
  • Curves: Quadratic and cubic Bézier curve support
  • Filled Shapes: Polygon filling with antialiasing
  • Coordinate Transforms: Full transform pipeline support

Linear Algebra

Comprehensive matrix operations:

  • Generic Matrix: Matrix(T) for any numeric type
  • SVD Decomposition: High-precision Singular Value Decomposition (ported from dlib)
  • GEMM Operations: Optimized matrix multiplication
  • OpsBuilder: Fluent API for complex matrix operations
  • Static Matrices: SMatrix for compile-time sized matrices

Principal Component Analysis

  • PCA Implementation: Full PCA with eigenvalue decomposition
  • Dimensionality Reduction: Project data to lower dimensions
  • Visualization: Built-in support for 2D/3D projections

Image Processing

  • Feature distrubtion matching for domain adaptation

Procedural Generation

  • Perlin Noise: High-quality noise generation for textures and terrain
  • Configurable: Adjustable frequency, amplitude, and octaves
  • 2D/3D Support: Generate noise in multiple dimensions

Python Bindings

Current Features

  • Complete Color Space Support: All 12 color spaces with full conversion matrix
  • Image Loading: Load JPEG and PNG images with native codecs
  • Type Safety: Proper validation and error handling
  • Pythonic API: Natural property access and method calls
  • High Performance: Zero-copy operations where possible

Planned Features (Future Releases):

  • Image Processing: Save operations, transformations, filtering
  • Geometry Operations: Points, rectangles, transforms
  • Drawing API: Canvas operations and shape rendering
  • Matrix Operations: Linear algebra and PCA
  • Advanced Features: Feature parity with native Zig API

WebAssembly Support

Zignal is designed WASM-first with interactive browser examples:

  • Production Ready: All features compile to WASM
  • Interactive Examples: Live demos for color spaces, image processing, and algorithms
  • Zero-Copy Operations: Direct memory sharing with JavaScript

Live Examples:

Performance & Design

Explicit Allocation Philosophy

  • All operations work either in-place or can use a allocator
  • Minimal memory footprint for embedded applications

SIMD Acceleration

  • Used throughout the library: GEMM, image filtering...
  • Automatic detection of 4×u8 structs for SIMD optimization
  • Vectorized operations for RGB/RGBA pixel processing

Type Safety

  • Compile-time guarantees for image operations
  • Generic programming for pixel type flexibility
  • Runtime validation for color space operations

Cross-Platform Support

Tier 1 Platforms (CI Tested):

  • Linux (x86_64, aarch64)
  • mac OS (Intel, Apple Silicon)
  • Windows (x86_64)
  • WebAssembly (all browsers)

Build System:

  • Native Zig build system with cross-compilation
  • Python wheel building for all major platforms
  • Comprehensive CI/CD with automated testing

Documentation & Examples

  • Comprehensive API Documentation: Generated from source
  • Interactive Examples: 15+ examples covering all major features
  • Production Use Case: Virtual makeup try-on application
  • Tutorial Content: From basic color conversion to advanced PCA

Production Ready

Zignal 0.1.0 is already battle-tested in production:

  • B Factory Inc: Powers virtual makeup try-on at Ameli
  • Performance Critical: Real-time image processing in mobile apps
  • Memory Efficient: Designed for resource-constrained environments

Getting Started

Zig Native

zig fetch --save https://github.com/bfactory-ai/zignal/archive/0.1.0.tar.gz
const std = @import("std");
const zignal = @import("zignal");
const Canvas = zignal.Canvas;
const Image = zignal.Image;
const Point2d = zignal.Point2d;
const Rgba = zignal.Rgba;
const savePng = zignal.savePng;

pub fn main() !void {
    const allocator = std.heap.page_allocator;

    // Create a 800x600 RGBA image
    var image: Image(Rgba) = try .initAlloc(allocator, 600, 800);
    defer image.deinit(allocator);

    // Create a drawing canvas
    const canvas: Canvas(Rgba) = .init(allocator, image);
    canvas.fill(Rgba.white);

    const red: Rgba = .{ .r = 255, .g = 0, .b = 0, .a = 255 };
    const start: Point2d(f32) = .init2d(50, 50);
    const end: Point2d(f32) = .init2d(750, 100);
    const center: Point2d(f32) = .init2d(400, 300);

    canvas.drawLine(start, end, red, 5, .soft);
    canvas.drawCircle(center, 100, red, 3, .soft);

    // Save the result to a PNG file
    try savePng(Rgba, allocator, image, "drawing.png");
}

Python

pip install zignal-processing
import zignal
rgb = zignal.Rgb(255, 128, 64)
hsv = rgb.to_hsv()
print(f"{rgb} => {hsv}")

WebAssembly

zig build -Dtarget=wasm32-freestanding -Doptimize=ReleaseSmall

Roadmap

0.2.0

  • Complete Python bindings feature parity

License

Zignal is released under the MIT License, making it free for both commercial and open-source use.


Star us on GitHub: github.com/bfactory-ai/zignal
Found a bug? Open an issue
Other Questions? join our discussions