sepia gives the image the warm brown tone of an old photograph.
At full strength it replaces the original colors with shades of brown, from near black to pale cream; a smaller amount keeps some of the original color.
Signature
image.sepia(amount?: number): thissepia changes the image in place and returns it, so you can chain more calls after it.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
amount |
number |
1 |
How much sepia to apply, from 0 (the original image) to 1 (full sepia), like CSS sepia(). |
Example
import { Jimp } from "jimp";
const image = await Jimp.read("photo.jpg");
image.sepia();
await image.write("photo-sepia.jpg");A softer tone
Pass an amount below 1 to blend the sepia tone with the original colors:
image.sepia(0.5); // half way between the original and full sepiaAn aged photo
Combine sepia with lower contrast and a slight fade toward white:
image .sepia(0.8) .contrast(-0.15) .color([{ apply: "lighten", params: [8] }]);Try it
Drag the slider to change amount. Hold the compare button to see the original.
image.sepia()Apply a warm sepia tone. amount blends from the original (0) to full sepia (1).
import { Jimp } from "jimp"; const image = await Jimp.read("dice.png"); // Change an option to run it await image.write("output.png");
Notes
-
How it’s computed. Each pixel goes through the standard sepia matrix, with results capped at
255:- red =
0.393 × R + 0.769 × G + 0.189 × B - green =
0.349 × R + 0.686 × G + 0.168 × B - blue =
0.272 × R + 0.534 × G + 0.131 × B
The result is then blended with the original pixel:
sepia × amount + original × (1 − amount). - red =
-
Light areas get brighter. The weights add up to more than
1for red and green, so pale areas clip to cream: white becomes(255, 255, 238). -
Out-of-range amounts are clamped to
0–1, sosepia(2)is the same assepia(1). A value that isn’t a number throws aZodError. -
Alpha is unchanged.
-
Other tones. For a monochrome image in another color, use
greyscalefollowed by themixaction ofcolor. -
Added in 2.0: the
amountparameter.sepia()is the same assepia(1). -
Changed in 2.0: each channel is computed from the original pixel. Before, green and blue were computed from the already-changed red, so pure red became
(100, 34, 45)instead of(100, 88, 69).