Wrapper of the Sharp image manipulation library for Gatsby plugins
Build a Node.js application that applies duotone color effects to images based on their luminance values.
Create a command-line tool that processes image files by applying a two-tone color gradient effect. The tool should map pixel brightness to a gradient between two specified colors, creating artistic duotone images commonly used in modern web design.
The application should accept:
The duotone transformation should:
The tool should:
Provides image processing and transformation capabilities with duotone effect support.
@test
Given an input image with path test-images/sample.jpg, apply duotone with highlight #ffffff and shadow #663399, then save to output/duotone-basic.jpg. The output should exist and have valid image data.
@test
Given an input image with path test-images/sample.jpg, apply duotone with highlight #f00e2e, shadow #192550, and opacity 50, then save to output/duotone-opacity.jpg. The output should exist and show blending with the original image.
@test
Process the same source image to three different output formats: JPEG, PNG, and WebP. All outputs should exist and be valid images with the duotone effect applied.
@test
Attempting to apply duotone with an invalid hex color (e.g., #gggggg) should throw an error with a clear message about the invalid color format.
/**
* Applies a duotone effect to an image file
*
* @param {Object} options - Configuration options
* @param {string} options.inputPath - Path to the input image
* @param {string} options.outputPath - Path for the output image
* @param {string} options.highlight - Highlight color in hex format (e.g., "#ffffff")
* @param {string} options.shadow - Shadow color in hex format (e.g., "#663399")
* @param {number} [options.opacity=100] - Opacity for blending (0-100)
* @returns {Promise<void>}
* @throws {Error} If file paths are invalid or colors are malformed
*/
async function applyDuotone(options) {
// Implementation
}
module.exports = { applyDuotone };@generates
tessl i tessl/npm-gatsby-plugin-sharp@5.15.0docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10