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-6/

Multi-Channel Image Combiner

Build a utility that combines separate grayscale channel images into a single multi-channel RGB or RGBA image.

Requirements

Your solution should:

  1. Accept file paths to 3 separate grayscale images representing Red, Green, and Blue channels
  2. Optionally accept a 4th grayscale image representing an Alpha channel
  3. Combine these separate channel images into a single multi-channel RGB or RGBA output image
  4. Validate that all input images have the same dimensions (width and height)
  5. Output the combined image to a specified path
  6. Support common image formats (PNG, JPEG)

Behavior

  • If input images have mismatched dimensions, throw an error with a clear message
  • If only RGB channels are provided (no alpha), produce an RGB image
  • If RGBA channels are provided (including alpha), produce an RGBA image
  • The output format should preserve the channel data accurately

Test Cases

  • Combining three 100x100 grayscale images (R, G, B) produces a 100x100 RGB image @test
  • Combining four 50x50 grayscale images (R, G, B, A) produces a 50x50 RGBA image @test
  • Attempting to combine images with mismatched dimensions throws an error @test

Implementation

@generates

API

/**
 * Combines separate grayscale channel images into a multi-channel image.
 *
 * @param {Object} options - Configuration options
 * @param {string} options.redPath - Path to the red channel image
 * @param {string} options.greenPath - Path to the green channel image
 * @param {string} options.bluePath - Path to the blue channel image
 * @param {string} [options.alphaPath] - Optional path to the alpha channel image
 * @param {string} options.outputPath - Path for the output combined image
 * @returns {Promise<void>}
 * @throws {Error} If input images have mismatched dimensions
 */
async function combineChannels(options) {
  // IMPLEMENTATION HERE
}

module.exports = { combineChannels };

Dependencies { .dependencies }

sharp { .dependency }

Provides image processing capabilities including channel manipulation.

Install with Tessl CLI

npx tessl i tessl/npm-sharp

tile.json