CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-sharp

High performance Node.js image processing library for resizing JPEG, PNG, WebP, GIF, AVIF and TIFF images

80

1.01x
Overview
Eval results
Files

task.mdevals/scenario-5/

Photo Watermark Applicator

Build a utility that applies watermark overlays to images with configurable blend modes and positioning.

Requirements

Apply Basic Watermark

The utility should composite a watermark image onto a base image with customizable blend modes.

  • Given a base image (1000x800 PNG) and watermark image (200x100 PNG), compositing with "over" blend mode produces the expected output @test
  • Given a base image and watermark, compositing with "multiply" blend mode produces darker composite where they overlap @test
  • Given a base image and watermark, compositing with "screen" blend mode produces lighter composite where they overlap @test

Position Watermarks

The utility should support positioning watermarks at different locations.

  • Positioning watermark at top-left corner (gravity: "northwest") places it correctly @test
  • Positioning watermark at bottom-right corner (gravity: "southeast") places it correctly @test
  • Positioning watermark at center (gravity: "center") places it correctly @test

Apply Multiple Watermarks

The utility should support applying multiple watermark layers with different blend modes.

  • Compositing two watermarks with different blend modes (first "multiply", second "screen") produces correct layered output @test

Implementation

@generates

API

/**
 * Applies a watermark to an image with specified blend mode and position
 *
 * @param {Buffer|string} baseImage - The base image (Buffer or file path)
 * @param {Object} options - Configuration options
 * @param {Array<Object>} options.watermarks - Array of watermark configurations
 * @param {Buffer|string} options.watermarks[].image - Watermark image (Buffer or file path)
 * @param {string} options.watermarks[].blend - Blend mode (e.g., 'over', 'multiply', 'screen', 'overlay')
 * @param {string} options.watermarks[].gravity - Position gravity (e.g., 'center', 'northwest', 'southeast')
 * @returns {Promise<Buffer>} The watermarked image as a Buffer
 */
async function applyWatermark(baseImage, options) {
  // Implementation here
}

module.exports = { applyWatermark };

Dependencies { .dependencies }

sharp { .dependency }

Provides high-performance image processing with compositing and blend mode support.

Install with Tessl CLI

npx tessl i tessl/npm-sharp

tile.json