zignal

zero-dependency image processing library.

class Image:

RGBA image for processing and manipulation.

Image( rows: int, cols: int, color: Union[int, Tuple[int, int, int], Tuple[int, int, int, int], Rgb, Rgba, Hsl, Hsv, Lab, Lch, Lms, Oklab, Oklch, Xyb, Xyz, Ycbcr, NoneType] = None)

Create a new Image with the specified dimensions and optional fill color.

Parameters

  • rows (int): Number of rows (height) of the image
  • cols (int): Number of columns (width) of the image
  • color (optional): Fill color. Can be:
    • Integer (0-255) for grayscale
    • RGB tuple (r, g, b) with values 0-255
    • RGBA tuple (r, g, b, a) with values 0-255
    • Any color object (Rgb, Hsl, Hsv, etc.)
    • Defaults to transparent (0, 0, 0, 0)

Examples

# Create a 100x200 transparent image
img = Image(100, 200)

# Create a 100x200 red image
img = Image(100, 200, (255, 0, 0))

# Create a 100x200 gray image
img = Image(100, 200, 128)

# Create an image from numpy array dimensions
img = Image(*arr.shape[:2])

# Create with semi-transparent blue
img = Image(100, 200, (0, 0, 255, 128))
def load(cls, path: str) -> Image:

Load an image from file (PNG/JPEG).

Parameters

  • path (str): Path to the image file to load

Raises

  • FileNotFoundError: If the image file is not found
  • ValueError: If the image format is not supported
  • MemoryError: If allocation fails

Examples

img = Image.load("photo.png")
print(img.rows, img.cols)
# Output: 512 768
def from_numpy( cls, array: numpy.ndarray[typing.Any, numpy.dtype[numpy.uint8]]) -> Image:

Create Image from NumPy array with shape (rows, cols, 3) or (rows, cols, 4) and dtype uint8.

For 4-channel arrays, zero-copy is used. For 3-channel arrays, the data is converted to RGBA format with alpha=255 (requires allocation). To enable zero-copy for RGB arrays, use Image.add_alpha() first.

Parameters

  • array (np.ndarray): NumPy array with shape (rows, cols, 3) or (rows, cols, 4) and dtype uint8. Must be C-contiguous.

Raises

  • TypeError: If array is None or has wrong dtype
  • ValueError: If array has wrong shape or is not C-contiguous

Notes

The array must be C-contiguous. If your array is not C-contiguous (e.g., from slicing or transposing), use np.ascontiguousarray() first:

arr = np.ascontiguousarray(arr)
img = Image.from_numpy(arr)

Examples

arr = np.zeros((100, 200, 3), dtype=np.uint8)
img = Image.from_numpy(arr)
print(img.rows, img.cols)
# Output: 100 200
def add_alpha( array: numpy.ndarray[typing.Any, numpy.dtype[numpy.uint8]], alpha: int = 255) -> numpy.ndarray[typing.Any, numpy.dtype[numpy.uint8]]:

Add alpha channel to a 3-channel RGB numpy array.

This is useful for enabling zero-copy when creating Images from RGB arrays.

Parameters

  • array (np.ndarray): NumPy array with shape (rows, cols, 3) and dtype uint8
  • alpha (int, optional): Alpha value to use for all pixels (default: 255)

Examples

rgb_arr = np.zeros((100, 200, 3), dtype=np.uint8)
rgba_arr = Image.add_alpha(rgb_arr)
print(rgba_arr.shape)
# Output: (100, 200, 4)
img = Image.from_numpy(rgba_arr)  # Zero-copy creation
def to_numpy( self, include_alpha: bool = True) -> numpy.ndarray[typing.Any, numpy.dtype[numpy.uint8]]:

Convert the image to a NumPy array (zero-copy when possible).

Parameters

  • include_alpha (bool, optional): If True (default), returns array with shape (rows, cols, 4). If False, returns array with shape (rows, cols, 3).

Examples

img = Image.load("photo.png")
arr_rgba = img.to_numpy()  # Include alpha
arr_rgb = img.to_numpy(include_alpha=False)  # RGB only
print(arr_rgba.shape, arr_rgb.shape)
# Output: (512, 768, 4) (512, 768, 3)
def save(self, path: str) -> None:

Save the image to a PNG file.

Parameters

  • path (str): Path where the PNG file will be saved. Must have .png extension.

Raises

  • ValueError: If the file does not have .png extension
  • MemoryError: If allocation fails during save
  • PermissionError: If write permission is denied
  • FileNotFoundError: If the directory does not exist

Examples

img = Image.load("input.png")
img.save("output.png")
def resize( self, size: Union[float, Tuple[int, int]], method: InterpolationMethod = <InterpolationMethod.BILINEAR: 1>) -> Image:

Resize the image to the specified size.

Parameters

  • size (float or tuple[int, int]):
    • If float: scale factor (e.g., 0.5 for half size, 2.0 for double size)
    • If tuple: target dimensions as (rows, cols)
  • method (InterpolationMethod, optional): Interpolation method to use. Default is InterpolationMethod.BILINEAR.
def letterbox( self, size: Union[int, Tuple[int, int]], method: InterpolationMethod = <InterpolationMethod.BILINEAR: 1>) -> Image:

Resize image to fit within the specified size while preserving aspect ratio.

The image is scaled to fit within the target dimensions and centered with black borders (letterboxing) to maintain the original aspect ratio.

Parameters

def canvas(self) -> Canvas:

Create a Canvas object for drawing operations on this image.

Examples

img = Image.load("photo.png")
canvas = img.canvas()
canvas.fill((255, 0, 0))  # Fill with red
canvas.draw_line((0, 0), (100, 100), (0, 255, 0))  # Draw green line
rows: int

Number of rows (height) in the image

cols: int

Number of columns (width) in the image

class InterpolationMethod(enum.IntEnum):

Interpolation methods for image resizing

NEAREST_NEIGHBOR = <InterpolationMethod.NEAREST_NEIGHBOR: 0>
CATMULL_ROM = <InterpolationMethod.CATMULL_ROM: 3>
class Canvas:

Canvas for drawing operations on images.

Canvas(image: Image)

Create a Canvas for drawing operations on an Image.

A Canvas provides drawing methods to modify the pixels of an Image. The Canvas maintains a reference to the parent Image to prevent it from being garbage collected while drawing operations are in progress.

Parameters

  • image (Image): The Image object to draw on. Must be initialized with dimensions.

Examples

# Create an image and get its canvas
img = Image(100, 100, Rgb(255, 255, 255))
canvas = Canvas(img)

# Draw on the canvas
canvas.fill(Rgb(0, 0, 0))
canvas.draw_circle((50, 50), 20, Rgb(255, 0, 0))

Notes

  • The Canvas holds a reference to the parent Image
  • All drawing operations modify the original Image pixels
  • Use Image.canvas() method as a convenient way to create a Canvas
def fill( self, color: Union[int, Tuple[int, int, int], Tuple[int, int, int, int], Rgb, Rgba, Hsl, Hsv, Lab, Lch, Lms, Oklab, Oklch, Xyb, Xyz, Ycbcr]) -> None:

Fill the entire canvas with a color.

Parameters

  • color (int, tuple or color object): Color to fill the canvas with. Can be:
    • Integer: grayscale value 0-255 (0=black, 255=white)
    • RGB tuple: (r, g, b) with values 0-255
    • RGBA tuple: (r, g, b, a) with values 0-255
    • Any color object: Rgb, Rgba, Hsl, Hsv, Lab, Lch, Lms, Oklab, Oklch, Xyb, Xyz, Ycbcr

Examples

img = Image.load("photo.png")
canvas = img.canvas()
canvas.fill(128)  # Fill with gray
canvas.fill((255, 0, 0))  # Fill with red
canvas.fill(Rgb(0, 255, 0))  # Fill with green using Rgb object
def draw_line( self, p1: Tuple[float, float], p2: Tuple[float, float], color: Union[int, Tuple[int, int, int], Tuple[int, int, int, int], Rgb, Rgba, Hsl, Hsv, Lab, Lch, Lms, Oklab, Oklch, Xyb, Xyz, Ycbcr], width: int = 1, mode: DrawMode = Ellipsis) -> None:

Draw a line between two points.

Parameters

  • p1 (tuple[float, float]): Starting point coordinates (x, y)
  • p2 (tuple[float, float]): Ending point coordinates (x, y)
  • color (int, tuple or color object): Color of the line.
  • width (int, optional): Line width in pixels (default: 1)
  • mode (DrawMode, optional): Drawing mode: DrawMode.FAST or DrawMode.SOFT (default: DrawMode.FAST)
def draw_rectangle( self, rect: Rectangle, color: Union[int, Tuple[int, int, int], Tuple[int, int, int, int], Rgb, Rgba, Hsl, Hsv, Lab, Lch, Lms, Oklab, Oklch, Xyb, Xyz, Ycbcr], width: int = 1, mode: DrawMode = Ellipsis) -> None:

Draw a rectangle outline.

Parameters

  • rect (Rectangle): Rectangle object defining the bounds
  • color (int, tuple or color object): Color of the rectangle.
  • width (int, optional): Line width in pixels (default: 1)
  • mode (DrawMode, optional): Drawing mode: DrawMode.FAST or DrawMode.SOFT (default: DrawMode.FAST)
def fill_rectangle( self, rect: Rectangle, color: Union[int, Tuple[int, int, int], Tuple[int, int, int, int], Rgb, Rgba, Hsl, Hsv, Lab, Lch, Lms, Oklab, Oklch, Xyb, Xyz, Ycbcr], mode: DrawMode = Ellipsis) -> None:

Fill a rectangle area.

Parameters

def draw_polygon( self, points: 'List[Tuple[float, float]]', color: Union[int, Tuple[int, int, int], Tuple[int, int, int, int], Rgb, Rgba, Hsl, Hsv, Lab, Lch, Lms, Oklab, Oklch, Xyb, Xyz, Ycbcr], width: int = 1, mode: DrawMode = Ellipsis) -> None:

Draw a polygon outline.

Parameters

  • points (list[tuple[float, float]]): List of (x, y) coordinates forming the polygon
  • color (int, tuple or color object): Color of the polygon.
  • width (int, optional): Line width in pixels (default: 1)
  • mode (DrawMode, optional): Drawing mode: DrawMode.FAST or DrawMode.SOFT (default: DrawMode.FAST)
def fill_polygon( self, points: 'List[Tuple[float, float]]', color: Union[int, Tuple[int, int, int], Tuple[int, int, int, int], Rgb, Rgba, Hsl, Hsv, Lab, Lch, Lms, Oklab, Oklch, Xyb, Xyz, Ycbcr], mode: DrawMode = Ellipsis) -> None:

Fill a polygon area.

Parameters

def draw_circle( self, center: Tuple[float, float], radius: float, color: Union[int, Tuple[int, int, int], Tuple[int, int, int, int], Rgb, Rgba, Hsl, Hsv, Lab, Lch, Lms, Oklab, Oklch, Xyb, Xyz, Ycbcr], width: int = 1, mode: DrawMode = Ellipsis) -> None:

Draw a circle outline.

Parameters

  • center (tuple[float, float]): Center coordinates (x, y)
  • radius (float): Circle radius
  • color (int, tuple or color object): Color of the circle.
  • width (int, optional): Line width in pixels (default: 1)
  • mode (DrawMode, optional): Drawing mode: DrawMode.FAST or DrawMode.SOFT (default: DrawMode.FAST)
def fill_circle( self, center: Tuple[float, float], radius: float, color: Union[int, Tuple[int, int, int], Tuple[int, int, int, int], Rgb, Rgba, Hsl, Hsv, Lab, Lch, Lms, Oklab, Oklch, Xyb, Xyz, Ycbcr], mode: DrawMode = Ellipsis) -> None:

Fill a circle area.

Parameters

def draw_quadratic_bezier( self, p0: Tuple[float, float], p1: Tuple[float, float], p2: Tuple[float, float], color: Union[int, Tuple[int, int, int], Tuple[int, int, int, int], Rgb, Rgba, Hsl, Hsv, Lab, Lch, Lms, Oklab, Oklch, Xyb, Xyz, Ycbcr], width: int = 1, mode: DrawMode = Ellipsis) -> None:

Draw a quadratic Bézier curve.

Parameters

  • p0 (tuple[float, float]): Start point (x, y)
  • p1 (tuple[float, float]): Control point (x, y)
  • p2 (tuple[float, float]): End point (x, y)
  • color (int, tuple or color object): Color of the curve.
  • width (int, optional): Line width in pixels (default: 1)
  • mode (DrawMode, optional): Drawing mode: DrawMode.FAST or DrawMode.SOFT (default: DrawMode.FAST)
def draw_cubic_bezier( self, p0: Tuple[float, float], p1: Tuple[float, float], p2: Tuple[float, float], p3: Tuple[float, float], color: Union[int, Tuple[int, int, int], Tuple[int, int, int, int], Rgb, Rgba, Hsl, Hsv, Lab, Lch, Lms, Oklab, Oklch, Xyb, Xyz, Ycbcr], width: int = 1, mode: DrawMode = Ellipsis) -> None:

Draw a cubic Bézier curve.

Parameters

  • p0 (tuple[float, float]): Start point (x, y)
  • p1 (tuple[float, float]): First control point (x, y)
  • p2 (tuple[float, float]): Second control point (x, y)
  • p3 (tuple[float, float]): End point (x, y)
  • color (int, tuple or color object): Color of the curve.
  • width (int, optional): Line width in pixels (default: 1)
  • mode (DrawMode, optional): Drawing mode: DrawMode.FAST or DrawMode.SOFT (default: DrawMode.FAST)
def draw_spline_polygon( self, points: 'List[Tuple[float, float]]', color: Union[int, Tuple[int, int, int], Tuple[int, int, int, int], Rgb, Rgba, Hsl, Hsv, Lab, Lch, Lms, Oklab, Oklch, Xyb, Xyz, Ycbcr], width: int = 1, tension: float = 0.5, mode: DrawMode = Ellipsis) -> None:

Draw a smooth spline through polygon points.

Parameters

  • points (list[tuple[float, float]]): List of (x, y) coordinates to interpolate through
  • color (int, tuple or color object): Color of the spline.
  • width (int, optional): Line width in pixels (default: 1)
  • tension (float, optional): Spline tension (0.0 = angular, 0.5 = smooth, default: 0.5)
  • mode (DrawMode, optional): Drawing mode: DrawMode.FAST or DrawMode.SOFT (default: DrawMode.FAST)
def fill_spline_polygon( self, points: 'List[Tuple[float, float]]', color: Union[int, Tuple[int, int, int], Tuple[int, int, int, int], Rgb, Rgba, Hsl, Hsv, Lab, Lch, Lms, Oklab, Oklch, Xyb, Xyz, Ycbcr], tension: float = 0.5, mode: DrawMode = Ellipsis) -> None:

Fill a smooth spline area through polygon points.

Parameters

  • points (list[tuple[float, float]]): List of (x, y) coordinates to interpolate through
  • color (int, tuple or color object): Fill color.
  • tension (float, optional): Spline tension (0.0 = angular, 0.5 = smooth, default: 0.5)
  • mode (DrawMode, optional): Drawing mode: DrawMode.FAST or DrawMode.SOFT (default: DrawMode.FAST)
def draw_text( self, text: str, position: Tuple[float, float], font: BitmapFont, color: Union[int, Tuple[int, int, int], Tuple[int, int, int, int], Rgb, Rgba, Hsl, Hsv, Lab, Lch, Lms, Oklab, Oklch, Xyb, Xyz, Ycbcr], scale: float = 1.0, mode: DrawMode = Ellipsis) -> None:

Draw text on the canvas.

Parameters

  • text (str): Text to draw
  • position (tuple[float, float]): Position coordinates (x, y)
  • font (BitmapFont): Font object to use for rendering
  • color (int, tuple or color object): Text color.
  • scale (float, optional): Text scale factor (default: 1.0)
  • mode (DrawMode, optional): Drawing mode: DrawMode.FAST or DrawMode.SOFT (default: DrawMode.FAST)
rows: int

Number of rows in the canvas

cols: int

Number of columns in the canvas

image: Image

Parent Image object

class DrawMode(enum.IntEnum):

Rendering quality mode for drawing operations

FAST = <DrawMode.FAST: 0>
SOFT = <DrawMode.SOFT: 1>
class Rectangle:

A rectangle defined by its left, top, right, and bottom coordinates.

Rectangle(left: float, top: float, right: float, bottom: float)

Initialize a Rectangle with specified coordinates.

Creates a rectangle from its bounding coordinates. The rectangle is defined by four values: left (x-min), top (y-min), right (x-max), and bottom (y-max).

Parameters

  • left (float): Left edge x-coordinate (minimum x)
  • top (float): Top edge y-coordinate (minimum y)
  • right (float): Right edge x-coordinate (maximum x)
  • bottom (float): Bottom edge y-coordinate (maximum y)

Examples

# Create a rectangle from (10, 20) to (110, 70)
rect = Rectangle(10, 20, 110, 70)
print(rect.width)  # 100
print(rect.height)  # 50

# Create a square
square = Rectangle(0, 0, 50, 50)

Notes

  • The constructor validates that right >= left and bottom >= top
  • Use Rectangle.init_center() for center-based construction
  • Coordinates follow image convention: origin at top-left, y increases downward
def init_center(cls, x: float, y: float, width: float, height: float) -> Rectangle:

Create a Rectangle from center coordinates.

Parameters

  • x (float): Center x coordinate
  • y (float): Center y coordinate
  • width (float): Rectangle width
  • height (float): Rectangle height

Examples

# Create a 100x50 rectangle centered at (50, 50)
rect = Rectangle.init_center(50, 50, 100, 50)
# This creates Rectangle(0, 25, 100, 75)
def is_empty(self) -> bool:

Check if the rectangle is ill-formed (empty).

A rectangle is considered empty if its left >= right or top >= bottom.

Examples

rect1 = Rectangle(0, 0, 100, 100)
print(rect1.is_empty())  # False

rect2 = Rectangle(100, 100, 0, 0)  # Invalid: right < left
print(rect2.is_empty())  # True
def area(self) -> float:

Calculate the area of the rectangle.

Examples

rect = Rectangle(0, 0, 100, 50)
print(rect.area())  # 5000.0
def contains(self, x: float, y: float) -> bool:

Check if a point is inside the rectangle.

Parameters

  • x (float): X coordinate to check
  • y (float): Y coordinate to check

Examples

rect = Rectangle(0, 0, 100, 100)
print(rect.contains(50, 50))   # True
print(rect.contains(150, 50))  # False
def grow(self, amount: float) -> Rectangle:

Create a new rectangle expanded by the given amount.

Parameters

  • amount (float): Amount to expand each border by

Examples

rect = Rectangle(50, 50, 100, 100)
grown = rect.grow(10)
# Creates Rectangle(40, 40, 110, 110)
def shrink(self, amount: float) -> Rectangle:

Create a new rectangle shrunk by the given amount.

Parameters

  • amount (float): Amount to shrink each border by

Examples

rect = Rectangle(40, 40, 110, 110)
shrunk = rect.shrink(10)
# Creates Rectangle(50, 50, 100, 100)
def intersect(self, other: Rectangle) -> 'Optional[Rectangle]':

Calculate the intersection of this rectangle with another.

Parameters

  • other (Rectangle): The other rectangle to intersect with

Examples

rect1 = Rectangle(0, 0, 100, 100)
rect2 = Rectangle(50, 50, 150, 150)
intersection = rect1.intersect(rect2)
# Returns Rectangle(50, 50, 100, 100)

rect3 = Rectangle(200, 200, 250, 250)
result = rect1.intersect(rect3)  # Returns None (no overlap)
left: float

Left coordinate of the rectangle

top: float

Top coordinate of the rectangle

right: float

Right coordinate of the rectangle

bottom: float

Bottom coordinate of the rectangle

width: float

Width of the rectangle (right - left)

height: float

Height of the rectangle (bottom - top)

class BitmapFont:

Bitmap font for text rendering

def load(cls, path: str) -> BitmapFont:

Load a bitmap font from file.

def get_default_font(cls) -> BitmapFont:

Get the built-in default 8x8 bitmap font.

class FeatureDistributionMatching:

Feature Distribution Matching for image style transfer.

FeatureDistributionMatching()

Initialize a new FeatureDistributionMatching instance.

Creates a new FDM instance that can be used to transfer color distributions between images. The instance maintains internal state for efficient batch processing of multiple images with the same target distribution.

Examples

# Create an FDM instance
fdm = FeatureDistributionMatching()

# Single image transformation
source = Image.load("portrait.png")
target = Image.load("sunset.png")
fdm.match(source, target)  # source is modified in-place
source.save("portrait_sunset.png")

# Batch processing with same style
style = Image.load("style_reference.png")
fdm.set_target(style)
for filename in image_files:
    img = Image.load(filename)
    fdm.set_source(img)
    fdm.update()
    img.save(f"styled_{filename}")

Notes

def set_target(self, image: Image) -> None:

Set the target image whose distribution will be matched.

This method computes and stores the target distribution statistics (mean and covariance) for reuse across multiple source images. This is more efficient than recomputing the statistics for each image when applying the same style to multiple images.

Parameters

  • image (Image): Target image providing the color distribution to match

Examples

fdm = FeatureDistributionMatching()
target = Image.load("sunset.png")
fdm.set_target(target)
def set_source(self, image: Image) -> None:

Set the source image to be transformed.

The source image will be modified in-place when update() is called.

Parameters

  • image (Image): Source image to be modified

Examples

fdm = FeatureDistributionMatching()
source = Image.load("portrait.png")
fdm.set_source(source)
def match(self, source: Image, target: Image) -> None:

Set both source and target images and apply the transformation.

This is a convenience method that combines set_source(), set_target(), and update() into a single call. The source image is modified in-place.

Parameters

  • source (Image): Source image to be modified
  • target (Image): Target image providing the color distribution to match

Examples

fdm = FeatureDistributionMatching()
source = Image.load("portrait.png")
target = Image.load("sunset.png")
fdm.match(source, target)  # source is now modified
source.save("portrait_sunset.png")
def update(self) -> None:

Apply the feature distribution matching transformation.

This method modifies the source image in-place to match the target distribution. Both source and target must be set before calling this method.

Raises

  • RuntimeError: If source or target has not been set

Examples

fdm = FeatureDistributionMatching()
fdm.set_target(target)
fdm.set_source(source)
fdm.update()  # source is now modified

Batch processing

fdm.set_target(style_image)
for img in images:
    fdm.set_source(img)
    fdm.update()  # Each img is modified in-place
class ConvexHull:

Convex hull computation using Graham's scan algorithm.

ConvexHull()

Initialize a new ConvexHull instance.

Creates a new ConvexHull instance that can compute the convex hull of 2D point sets using Graham's scan algorithm. The algorithm has O(n log n) time complexity where n is the number of input points.

Examples

# Create a ConvexHull instance
hull = ConvexHull()

# Find convex hull of points
points = [(0, 0), (1, 1), (2, 2), (3, 1), (4, 0), (2, 4), (1, 3)]
result = hull.find(points)
# Returns: [(0.0, 0.0), (1.0, 3.0), (2.0, 4.0), (4.0, 0.0)]

Notes

  • Returns vertices in clockwise order
  • Returns None for degenerate cases (e.g., all points collinear)
  • Requires at least 3 points for a valid hull
def find( self, points: list[tuple[float, float]]) -> 'Optional[list[tuple[float, float]]]':

Find the convex hull of a set of 2D points.

Returns the vertices of the convex hull in clockwise order as a list of (x, y) tuples, or None if the hull is degenerate (e.g., all points are collinear).

Parameters

  • points (list[tuple[float, float]]): List of (x, y) coordinate pairs. At least 3 points are required.

Examples

hull = ConvexHull()
points = [(0, 0), (1, 1), (2, 2), (3, 1), (4, 0), (2, 4), (1, 3)]
result = hull.find(points)
# Returns: [(0.0, 0.0), (1.0, 3.0), (2.0, 4.0), (4.0, 0.0)]
class Rgb:

RGB color in sRGB colorspace with components in range 0-255

Rgb(r: int, g: int, b: int)
def to_rgba(self) -> Rgba:

Convert to Rgba color space.

def to_hsl(self) -> Hsl:

Convert to Hsl color space.

def to_hsv(self) -> Hsv:

Convert to Hsv color space.

def to_lab(self) -> Lab:

Convert to Lab color space.

def to_lch(self) -> Lch:

Convert to Lch color space.

def to_lms(self) -> Lms:

Convert to Lms color space.

def to_oklab(self) -> Oklab:

Convert to Oklab color space.

def to_oklch(self) -> Oklch:

Convert to Oklch color space.

def to_xyb(self) -> Xyb:

Convert to Xyb color space.

def to_xyz(self) -> Xyz:

Convert to Xyz color space.

def to_ycbcr(self) -> Ycbcr:

Convert to Ycbcr color space.

r: int

r component

g: int

g component

b: int

b component

class Rgba:

RGBA color with alpha channel, components in range 0-255

Rgba(r: int, g: int, b: int, a: int)
def to_rgb(self) -> Rgb:

Convert to Rgb color space.

def to_hsl(self) -> Hsl:

Convert to Hsl color space.

def to_hsv(self) -> Hsv:

Convert to Hsv color space.

def to_lab(self) -> Lab:

Convert to Lab color space.

def to_lch(self) -> Lch:

Convert to Lch color space.

def to_lms(self) -> Lms:

Convert to Lms color space.

def to_oklab(self) -> Oklab:

Convert to Oklab color space.

def to_oklch(self) -> Oklch:

Convert to Oklch color space.

def to_xyb(self) -> Xyb:

Convert to Xyb color space.

def to_xyz(self) -> Xyz:

Convert to Xyz color space.

def to_ycbcr(self) -> Ycbcr:

Convert to Ycbcr color space.

r: int

r component

g: int

g component

b: int

b component

a: int

a component

class Hsv:

HSV (Hue-Saturation-Value) color representation

Hsv(h: float, s: float, v: float)
def to_rgb(self) -> Rgb:

Convert to Rgb color space.

def to_rgba(self) -> Rgba:

Convert to Rgba color space.

def to_hsl(self) -> Hsl:

Convert to Hsl color space.

def to_lab(self) -> Lab:

Convert to Lab color space.

def to_lch(self) -> Lch:

Convert to Lch color space.

def to_lms(self) -> Lms:

Convert to Lms color space.

def to_oklab(self) -> Oklab:

Convert to Oklab color space.

def to_oklch(self) -> Oklch:

Convert to Oklch color space.

def to_xyb(self) -> Xyb:

Convert to Xyb color space.

def to_xyz(self) -> Xyz:

Convert to Xyz color space.

def to_ycbcr(self) -> Ycbcr:

Convert to Ycbcr color space.

h: float

h component

s: float

s component

v: float

v component

class Hsl:

HSL (Hue-Saturation-Lightness) color representation

Hsl(h: float, s: float, l: float)
def to_rgb(self) -> Rgb:

Convert to Rgb color space.

def to_rgba(self) -> Rgba:

Convert to Rgba color space.

def to_hsv(self) -> Hsv:

Convert to Hsv color space.

def to_lab(self) -> Lab:

Convert to Lab color space.

def to_lch(self) -> Lch:

Convert to Lch color space.

def to_lms(self) -> Lms:

Convert to Lms color space.

def to_oklab(self) -> Oklab:

Convert to Oklab color space.

def to_oklch(self) -> Oklch:

Convert to Oklch color space.

def to_xyb(self) -> Xyb:

Convert to Xyb color space.

def to_xyz(self) -> Xyz:

Convert to Xyz color space.

def to_ycbcr(self) -> Ycbcr:

Convert to Ycbcr color space.

h: float

h component

s: float

s component

l: float

l component

class Lab:

CIELAB color space representation

Lab(l: float, a: float, b: float)
def to_rgb(self) -> Rgb:

Convert to Rgb color space.

def to_rgba(self) -> Rgba:

Convert to Rgba color space.

def to_hsl(self) -> Hsl:

Convert to Hsl color space.

def to_hsv(self) -> Hsv:

Convert to Hsv color space.

def to_lch(self) -> Lch:

Convert to Lch color space.

def to_lms(self) -> Lms:

Convert to Lms color space.

def to_oklab(self) -> Oklab:

Convert to Oklab color space.

def to_oklch(self) -> Oklch:

Convert to Oklch color space.

def to_xyb(self) -> Xyb:

Convert to Xyb color space.

def to_xyz(self) -> Xyz:

Convert to Xyz color space.

def to_ycbcr(self) -> Ycbcr:

Convert to Ycbcr color space.

l: float

l component

a: float

a component

b: float

b component

class Xyz:

CIE 1931 XYZ color space representation

Xyz(x: float, y: float, z: float)
def to_rgb(self) -> Rgb:

Convert to Rgb color space.

def to_rgba(self) -> Rgba:

Convert to Rgba color space.

def to_hsl(self) -> Hsl:

Convert to Hsl color space.

def to_hsv(self) -> Hsv:

Convert to Hsv color space.

def to_lab(self) -> Lab:

Convert to Lab color space.

def to_lch(self) -> Lch:

Convert to Lch color space.

def to_lms(self) -> Lms:

Convert to Lms color space.

def to_oklab(self) -> Oklab:

Convert to Oklab color space.

def to_oklch(self) -> Oklch:

Convert to Oklch color space.

def to_xyb(self) -> Xyb:

Convert to Xyb color space.

def to_ycbcr(self) -> Ycbcr:

Convert to Ycbcr color space.

x: float

x component

y: float

y component

z: float

z component

class Oklab:

Oklab perceptual color space representation

Oklab(l: float, a: float, b: float)
def to_rgb(self) -> Rgb:

Convert to Rgb color space.

def to_rgba(self) -> Rgba:

Convert to Rgba color space.

def to_hsl(self) -> Hsl:

Convert to Hsl color space.

def to_hsv(self) -> Hsv:

Convert to Hsv color space.

def to_lab(self) -> Lab:

Convert to Lab color space.

def to_lch(self) -> Lch:

Convert to Lch color space.

def to_lms(self) -> Lms:

Convert to Lms color space.

def to_oklch(self) -> Oklch:

Convert to Oklch color space.

def to_xyb(self) -> Xyb:

Convert to Xyb color space.

def to_xyz(self) -> Xyz:

Convert to Xyz color space.

def to_ycbcr(self) -> Ycbcr:

Convert to Ycbcr color space.

l: float

l component

a: float

a component

b: float

b component

class Oklch:

Oklch perceptual color space in cylindrical coordinates

Oklch(l: float, c: float, h: float)
def to_rgb(self) -> Rgb:

Convert to Rgb color space.

def to_rgba(self) -> Rgba:

Convert to Rgba color space.

def to_hsl(self) -> Hsl:

Convert to Hsl color space.

def to_hsv(self) -> Hsv:

Convert to Hsv color space.

def to_lab(self) -> Lab:

Convert to Lab color space.

def to_lch(self) -> Lch:

Convert to Lch color space.

def to_lms(self) -> Lms:

Convert to Lms color space.

def to_oklab(self) -> Oklab:

Convert to Oklab color space.

def to_xyb(self) -> Xyb:

Convert to Xyb color space.

def to_xyz(self) -> Xyz:

Convert to Xyz color space.

def to_ycbcr(self) -> Ycbcr:

Convert to Ycbcr color space.

l: float

l component

c: float

c component

h: float

h component

class Lch:

CIE LCH color space representation (cylindrical Lab)

Lch(l: float, c: float, h: float)
def to_rgb(self) -> Rgb:

Convert to Rgb color space.

def to_rgba(self) -> Rgba:

Convert to Rgba color space.

def to_hsl(self) -> Hsl:

Convert to Hsl color space.

def to_hsv(self) -> Hsv:

Convert to Hsv color space.

def to_lab(self) -> Lab:

Convert to Lab color space.

def to_lms(self) -> Lms:

Convert to Lms color space.

def to_oklab(self) -> Oklab:

Convert to Oklab color space.

def to_oklch(self) -> Oklch:

Convert to Oklch color space.

def to_xyb(self) -> Xyb:

Convert to Xyb color space.

def to_xyz(self) -> Xyz:

Convert to Xyz color space.

def to_ycbcr(self) -> Ycbcr:

Convert to Ycbcr color space.

l: float

l component

c: float

c component

h: float

h component

class Lms:

LMS color space representing Long, Medium, Short wavelength cone responses

Lms(l: float, m: float, s: float)
def to_rgb(self) -> Rgb:

Convert to Rgb color space.

def to_rgba(self) -> Rgba:

Convert to Rgba color space.

def to_hsl(self) -> Hsl:

Convert to Hsl color space.

def to_hsv(self) -> Hsv:

Convert to Hsv color space.

def to_lab(self) -> Lab:

Convert to Lab color space.

def to_lch(self) -> Lch:

Convert to Lch color space.

def to_oklab(self) -> Oklab:

Convert to Oklab color space.

def to_oklch(self) -> Oklch:

Convert to Oklch color space.

def to_xyb(self) -> Xyb:

Convert to Xyb color space.

def to_xyz(self) -> Xyz:

Convert to Xyz color space.

def to_ycbcr(self) -> Ycbcr:

Convert to Ycbcr color space.

l: float

l component

m: float

m component

s: float

s component

class Xyb:

XYB color space used in JPEG XL image compression

Xyb(x: float, y: float, b: float)
def to_rgb(self) -> Rgb:

Convert to Rgb color space.

def to_rgba(self) -> Rgba:

Convert to Rgba color space.

def to_hsl(self) -> Hsl:

Convert to Hsl color space.

def to_hsv(self) -> Hsv:

Convert to Hsv color space.

def to_lab(self) -> Lab:

Convert to Lab color space.

def to_lch(self) -> Lch:

Convert to Lch color space.

def to_lms(self) -> Lms:

Convert to Lms color space.

def to_oklab(self) -> Oklab:

Convert to Oklab color space.

def to_oklch(self) -> Oklch:

Convert to Oklch color space.

def to_xyz(self) -> Xyz:

Convert to Xyz color space.

def to_ycbcr(self) -> Ycbcr:

Convert to Ycbcr color space.

x: float

x component

y: float

y component

b: float

b component

class Ycbcr:

YCbCr color space used in JPEG and video encoding

Ycbcr(y: float, cb: float, cr: float)
def to_rgb(self) -> Rgb:

Convert to Rgb color space.

def to_rgba(self) -> Rgba:

Convert to Rgba color space.

def to_hsl(self) -> Hsl:

Convert to Hsl color space.

def to_hsv(self) -> Hsv:

Convert to Hsv color space.

def to_lab(self) -> Lab:

Convert to Lab color space.

def to_lch(self) -> Lch:

Convert to Lch color space.

def to_lms(self) -> Lms:

Convert to Lms color space.

def to_oklab(self) -> Oklab:

Convert to Oklab color space.

def to_oklch(self) -> Oklch:

Convert to Oklch color space.

def to_xyb(self) -> Xyb:

Convert to Xyb color space.

def to_xyz(self) -> Xyz:

Convert to Xyz color space.

y: float

y component

cb: float

cb component

cr: float

cr component