v0.4.0

Operations

Every LayerImage operation on a single photo, with the input on the left and the result of the snippet on the right. The darken-group blend modes run on a grayscale copy (grayscale_image = image.clone().grayscale()), as in the original demo. See Examples for complete looks built from these operations.

Basic Adjustments

Grayscale

Convert to grayscale using the ITU-R 601 luminance weights.

image.grayscale()
Before/after preview of Grayscale

Brightness

Scale pixel values: a factor above 0 brightens, below 0 darkens.

image.brightness(0.2)
Before/after preview of Brightness

Contrast

Expand or compress the range around mid-gray: a factor above 1 increases contrast, between 0 and 1 decreases it.

image.contrast(1.5)
Before/after preview of Contrast

Hue

Set every pixel's hue to the target value in [0, 1] while keeping saturation and value. This is a colorize-style adjustment.

image.hue(0.3)
Before/after preview of Hue

Saturation

Scale color intensity: a factor above 0 boosts saturation, below 0 mutes it (-1 fully desaturates).

image.saturation(-0.5)
Before/after preview of Saturation

Lightness

Blend toward white (factor above 0) or black (factor below 0).

image.lightness(0.4)
Before/after preview of Lightness

Curve (All Channels)

Remap tones through control points spaced evenly across [0, 1]. Here, an S-curve deepens shadows and lifts highlights.

image.curve('rgb', [0, 0.1, 0.4, 0.65, 0.9, 1])
Before/after preview of Curve (all channels)

Curve (Single Channel)

The same curve machinery applied to the red channel only.

image.curve('r', [0, 0.2, 0.8, 1])
Before/after preview of Curve (single channel)

Resize

Resize with high-quality Lanczos resampling.

image.resize(width=240, height=160)
Before/after preview of Resize

Blend Modes: Darken

Darken

Looks at the color information in each channel and selects the base or blend color, whichever is darker, as the result color.

grayscale_image.darken('#3fe28f')
Before/after preview of Darken

Multiply

Multiplies the base color by the blend color. The result is always darker; multiplying with white leaves the color unchanged.

grayscale_image.multiply('#3fe28f')
Before/after preview of Multiply

Color Burn

Darkens the base color to reflect the blend color by increasing the contrast between the two. Blending with white produces no change.

grayscale_image.color_burn('#7fe3f8')
Before/after preview of Color Burn

Linear Burn

Darkens the base color to reflect the blend color by decreasing the brightness. Blending with white produces no change.

grayscale_image.linear_burn('#e1a8ff')
Before/after preview of Linear Burn

Blend Modes: Lighten

Lighten

Selects the base or blend color, whichever is lighter, as the result color.

image.lighten('#ff3ce1')
Before/after preview of Lighten

Screen

Multiplies the inverse of the blend and base colors. The result is always lighter, like projecting multiple slides on top of each other.

image.screen('#e633ba')
Before/after preview of Screen

Color Dodge

Brightens the base color to reflect the blend color by decreasing contrast between the two. Blending with black produces no change.

image.color_dodge('#490cc7')
Before/after preview of Color Dodge

Linear Dodge

Brightens the base color to reflect the blend color by increasing the brightness. Blending with black produces no change.

image.linear_dodge('#490cc7')
Before/after preview of Linear Dodge

Blend Modes: Contrast

Overlay

Multiplies or screens the colors depending on the base color, preserving its highlights and shadows.

image.overlay('#ffb956')
Before/after preview of Overlay

Soft Light

Darkens or lightens depending on the blend color, like shining a diffused spotlight on the image.

image.soft_light('#ff3cbc')
Before/after preview of Soft Light

Hard Light

Multiplies or screens depending on the blend color, like shining a harsh spotlight on the image.

image.hard_light('#df5dff')
Before/after preview of Hard Light

Vivid Light

Burns or dodges by increasing or decreasing the contrast, depending on the blend color.

image.vivid_light('#ac5b7f')
Before/after preview of Vivid Light

Linear Light

Burns or dodges by decreasing or increasing the brightness, depending on the blend color.

image.linear_light('#9fa500')
Before/after preview of Linear Light

Pin Light

Replaces colors depending on the blend color, which is useful for adding special effects to an image.

image.pin_light('#005546')
Before/after preview of Pin Light

Putting It Together

Method Chaining

Every operation returns the LayerImage itself, so a whole look can be built as one chained pipeline.

(image.grayscale()
      .brightness(0.1)
      .multiply('#3fe28f', opacity=0.7)
      .curve('rgb', [0, 0.1, 0.4, 0.65, 0.9, 1]))
Before/after preview of Method chaining