Contributing photo filters and filter ops
A filter is a recipe of adjustment steps (plus an optional .cube LUT) the image editor and the server
apply the same way; Photo Filters is the reference for the file format, the ops and the
engine. An enabled plugin can ship ready-made filters and add new ops. Both are declared in manifest.yml;
disabling the plugin takes them away again.
On this page
Shipping filters#
filters:
- path: filters # <plugin>/filters/<name>/filter.ymlThe root is scanned exactly like content/filters/marketplace/: each <name>/filter.yml (plus an optional
lut.cube) is one filter, and the directory name must equal the id:. Public ids are
<plugin_id>:<name>, so a plugin filter never collides with a core, local or user filter. A filter that ships
a .cube must declare license:. A filter that fails validation is reported under load_errors in
GET /api/filters and the rest still load. Check yours with python scripts/filter_lint.py.
Adding an op#
filter_ops:
- id: retro-tape.scanlines # must be "<plugin-id>.<op>"; core ops never contain a dot
label: Scanlines
kind: spatial # colour | spatial
params:
- { id: strength, label: Strength, type: int, min: 0, max: 100, default: 30 }
- { id: gap, label: Gap, type: int, min: 2, max: 12, default: 4 }
python: ops.py:Scanlines # optional; absent means editor onlyThe declaration is what the backend and the linter validate a filter's params against, without importing
JavaScript. A param is type: int or float with a min, a max and a default inside that range.
An op is colour only if each output pixel depends on that pixel's RGB alone; then it is folded into the filter's LUT like a core colour op. Anything that needs position or neighbours is spatial and runs after the LUT. A filter lists its colour steps before its spatial steps.
The browser half is registered through the image-editor host (window.__potionui.imageEditor), next to the
declaration above: call registerAdjustment with an adjustment whose id is the op id. A colour op adds
kind: 'colour' and map(rgb, values), a pointwise function over [r, g, b] floats in 0..1, so the editor
folds it into the LUT. A spatial op uses its apply(image, values), which must return synchronously; the
editor blends its result by the filter's intensity. An op with no browser half leaves its filters unusable in
the editor. The Python half is optional and is a class named by python: (file.py:ClassName, a path
inside the plugin directory), imported only while the plugin is enabled:
from src.plugin_api.filters import ColourOp, SpatialOp
class Warmth(ColourOp):
def map(self, rgb, params):
return rgb
class Scanlines(SpatialOp):
def apply(self, image, params, amount):
return imageColourOp.map(rgb, params):rgbis a float32 array of shape(N, 3)in 0..1, vectorised over lattice nodes; return the same shape. The result is clamped to 0..1.SpatialOp.apply(image, params, amount):imageis a float32 array of shape(H, W, 3)in 0..1 andamountis the intensity as 0..1. A spatial op must scale its effect byamount: at 0 it returns the image unchanged.- Without a
python:entry the filter still works in the editor,GET /api/filtersreportsbackend_ok: falsefor any filter using it, and server-side consumers refuse it with a message naming the op.
apply_filter, compile_lut, parse_cube, validate_steps, Cube and CubeError are exported from the
same module so a plugin's own tests can check its op against the engine.