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

Image Archive Converter

Build a tool that converts images to JPEG 2000 format for long-term archival storage with configurable quality and lossless options.

Requirements

The tool should accept input images in common formats and convert them to JPEG 2000 (JP2) format. It must support:

  1. Quality-based compression: Allow users to specify a quality level (1-100) for lossy compression
  2. Lossless compression: Support true lossless encoding when requested
  3. Tiled output: Enable tiled encoding for efficient access to large images

The converter should handle both single image conversion and batch processing.

Implementation

@generates

API

/**
 * Converts an image to JPEG 2000 format
 *
 * @param {string|Buffer} input - Path to input image or image buffer
 * @param {object} options - Conversion options
 * @param {number} [options.quality] - Quality level (1-100) for lossy compression
 * @param {boolean} [options.lossless] - Use lossless compression (default: false)
 * @param {boolean} [options.tileOutput] - Enable tiled encoding (default: false)
 * @returns {Promise<Buffer>} - JP2 encoded image buffer
 */
async function convertToJP2(input, options) {
  // Implementation
}

module.exports = { convertToJP2 };

Test Cases

Basic Conversion

  • Converting a PNG image with quality 80 produces a valid JP2 buffer @test
  • The output buffer starts with the JP2 signature bytes @test

Quality Settings

  • Converting with quality 50 produces a smaller file than quality 90 @test

Lossless Mode

  • Converting with lossless=true preserves image data perfectly @test

Tiled Output

  • Converting with tileOutput=true enables tiled encoding @test

Dependencies { .dependencies }

sharp { .dependency }

Provides image processing and JP2 encoding capabilities.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-sharp

tile.json