Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ You can universally customize IPX configuration using `IPX_*` environment variab
| tint | [Docs](https://sharp.pixelplumbing.com/api-colour#tint) | `/tint_1098123/buffalo.png` |
| grayscale | [Docs](https://sharp.pixelplumbing.com/api-colour#grayscale) | `/grayscale/buffalo.png` |
| flatten | [Docs](https://sharp.pixelplumbing.com/api-operation#flatten) | `/flatten/buffalo.png` | Remove alpha channel, if any, and replace with background colour. |
| modulate | [Docs](https://sharp.pixelplumbing.com/api-operation#modulate) | `/modulate_brightness_saturation_hue/buffalo.png` | Transforms the image using brightness, saturation and hue rotation. |
| modulate | [Docs](https://sharp.pixelplumbing.com/api-operation#modulate) | `/modulate_{brightness}_{saturation}_{hue}_{lightness}/buffalo.png` | Transforms the image using brightness, saturation, hue rotation and lightness. |
| crop | [Docs](https://sharp.pixelplumbing.com/api-resize#extract) | `/crop_{left}_{top}_{width}_{height}/buffalo.png` | Alias for extract. Extract/crop a region of the image. |
| animated / a | - | `/animated/buffalo.gif` or `/a/buffalo.gif` | Experimental |

Expand Down
5 changes: 3 additions & 2 deletions src/handlers/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,13 @@ export const threshold: Handler = {

// https://sharp.pixelplumbing.com/api-operation#modulate
export const modulate: Handler = {
args: [VArg],
apply: (_context, pipe, brightness, saturation, hue) => {
args: [VArg, VArg, VArg, VArg],
apply: (_context, pipe, brightness, saturation, hue, lightness) => {
return pipe.modulate({
brightness,
saturation,
hue,
lightness,
});
},
};
Expand Down
3 changes: 2 additions & 1 deletion test/handlers/handlers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,13 @@ describe("handlers", () => {
modulate: vi.fn(),
};

modulate.apply({} as any, sharpMock as any, 100, 200, 300);
modulate.apply({} as any, sharpMock as any, 100, 200, 300, 400);

expect(sharpMock.modulate).toHaveBeenCalledWith({
brightness: 100,
saturation: 200,
hue: 300,
lightness: 400,
});
});

Expand Down