HSL and tone filters
Filter layers apply non-destructive adjustments to all layers beneath them in the stack. All values default to zero (no-op).Creating a filter layer
Available adjustments
| Property | Range | Description |
|---|---|---|
hue / hueDeg | degrees | Hue offset (color rotation) |
saturation | -1.0 to 1.0 | Saturation delta |
lightness | -1.0 to 1.0 | Lightness delta |
alpha | -1.0 to 1.0 | Alpha delta |
brightness | -1.0 to 1.0 | Brightness adjustment |
contrast | -1.0 to 1.0 | Contrast adjustment |
temperature | -1.0 to 1.0 | Temperature shift (cool to warm) |
tint | -1.0 to 1.0 | Tint shift (green to magenta) |
sharpen | 0.0 to 1.0 | Sharpen strength |
Example: Color grading
Pixel-level filters
These filters modify a layer’s pixel buffer directly.Convolution filters
Box blur
Fast uniform blur:Gaussian blur
Smooth photographic blur:Sharpen
Enhance edge definition:Edge detect
Highlight edges in the image:Emboss
Create a 3D embossed effect:Color filters
Invert
Invert all RGB channels (alpha is preserved):Posterize
Reduce color depth per channel:Threshold
Convert to black/white based on luminance:Levels
Remap input range to output range with gamma curve:Gradient map
Map pixel luminance to colors sampled from a gradient:Filter implementation
The HSL filter pipeline is implemented in~/workspace/source/crates/kimg-core/src/filter.rs:64-277. It processes pixels in multiple passes:
- HSL adjustment + alpha delta (if needed)
- Optional sharpen kernel capture
- Tone adjustments (brightness, contrast, temperature, tint) with optional sharpen
~/workspace/source/crates/kimg-core/src/convolution.rs.
Performance notes
- Filter layers are applied during render, so they don’t modify the source pixels
- Pixel-level filters modify the buffer in place and cannot be undone
- Convolution filters with larger radii are slower but produce better results
- The sharpen adjustment in filter layers uses a 3x3 unsharp mask kernel