8000 feat(plugin-color): add a multiply color action and sepia(amount) by hipstersmoothie · Pull Request #1517 · jimp-dev/jimp · GitHub
[go: up one dir, main page]

Skip to content

feat(plugin-color): add a multiply color action and sepia(amount) - #1517

Merged
hipstersmoothie merged 1 commit into
mainfrom
feat/multiply-sepia-1015
Nov 23, 2026
Merged

hipstersmoothie merged 1 commit into
mainfrom
feat/multiply-sepia-1015

Conversation

@hipstersmoothie
Copy link
Copy Markdown
Collaborator

Fixes #1015

The issue asks for filterous-style rgbAdjust (per-channel multiply) and colorFilter, plus a sepia intensity, to build Instagram-style filters.

What changed

multiply color action

// per-channel factors (filterous's rgbAdjust)
image.color([{ apply: "multiply", params: [1.2, 1.05, 0.9] }]);
// a color, like the multiply blend mode: each channel × color / 255
image.color([{ apply: "multiply", params: ["#ffe0c0"] }]);
image.color([{ apply: "multiply", params: [{ r: 255, g: 224, b: 192 }] }]);
  • params is either three numeric factors [r, g, b], or a single color in the same form mix/xor take ({ r, g, b } 0-255 or a CSS color, converted to the image's colour space). Invalid CSS colors throw (Invalid color "…"), per 2.0.
  • I kept factors as a positional [r, g, b] triple (like the issue's rgbAdjust([r, g, b])) so they can't be confused with an { r, g, b } color, which is 0-255 everywhere else in color(). A color means the multiply blend mode (factor = channel / 255), which can only darken; factors can also brighten.
  • Results are rounded and clamped to 0-255; any factor is accepted (negative → 0), no new range errors. Alpha is untouched. Added to ColorActionName as MULTIPLY.

sepia(amount = 1)

image.sepia(); // unchanged: full sepia
image.sepia(0.5); // half way between the original and full sepia

Blends between the original pixel (0) and full sepia (1), like CSS filter: sepia(amount). Out-of-range values are clamped to 0-1. sepia()/sepia(1) give byte-identical output to before.

colorFilter is already mix

filterous's colorFilter([r, g, b, adj]) computes c - (c - color) * adj, which is exactly mix with a weight of adj * 100:

image.color([{ apply: "mix", params: [{ r: 255, g: 153, b: 0 }, 20] }]); // colorFilter([255, 153, 0, 0.2])

so no new action is needed; the README shows it alongside multiply and sepia(amount).

JSDoc examples, README and tests added (factors, rounding/clamping, color and { r, g, b } forms, invalid colors, sepia blend and clamping).

🤖 Generated with Claude Code

`color()` gets a `multiply` action that multiplies red, green and blue by
three factors, or by a color (each channel / 255, like the multiply blend
mode). `sepia()` takes an optional amount from 0 to 1 (default 1) that
blends between the original image and full sepia.

Fixes #1015

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hipstersmoothie hipstersmoothie added enhancement a request for a new feature or change in behavior minor Increment the minor version when merged labels Nov 23, 2026
@hipstersmoothie
hipstersmoothie merged commit 99c4268 into main Nov 23, 2026
6 checks passed
@hipstersmoothie
hipstersmoothie deleted the feat/multiply-sepia-1015 branch November 23, 2026 20:58
@hipstersmoothie
Copy link
Copy Markdown
Collaborator Author

🚀 PR was released in v2.0.0 🚀

@hipstersmoothie hipstersmoothie added the released This issue/pull request has been released. label Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement a request for a new feature or change in behavior minor Increment the minor version when merged released This issue/pull request has been released.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

I tried to add instagram filters from this code

1 participant

0