Skip to content

Add a solarize filter #55

Description

@swperb

A nice self-contained first contribution: add a solarize filter — the photographic Sabattier effect, where channel values above a threshold are inverted.

Spec

  • Name: solarize
  • Usage: solarize[=threshold], threshold 0–255 (default 128)
  • For each R/G/B channel c: if c >= threshold, set c = 255 - c; else leave it. Alpha untouched.

Where — mostly in src/filters.c

  1. Write f_solarize. Copy f_invert (~line 249) as a template — same shape, just add the threshold check. Read the arg with argd(a, n, 0, 128.0) (see f_brightness, ~line 264). clampb() clamps to 0–255.
  2. Register it in the FILTERS[] table (the "colour" block, ~line 578):
    {"solarize",    "solarize[=T]                    invert channels >= T (default 128)", f_solarize},
  3. Document it: add solarize to the README Filters → Colour list (README.md). Per CONTRIBUTING.md ("Adding or changing a filter", step 5), a new filter must be listed there.

Done when

  • make builds clean (-Wall -Wextra, no warnings)
  • imgcli -filters lists solarize
  • solarize appears in the README Colour filter list
  • imgcli -y -i testsrc=128x128 -vf "solarize" out.png works; solarize=64 changes the result
  • (bonus) a line in the check target of the Makefile exercising it

Small, visual, and a real feature. Difficulty: easy — happy to give pointers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions