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

Image Border Tool

Create a command-line tool that adds decorative borders to images. The tool should support different border styles and allow users to customize the border size and appearance.

Capabilities

Add solid color borders

The tool should add borders with a solid color around an image.

  • When a 300x200px image is given a 20-pixel red border on all sides, the output is 340x240px with red borders @test
  • When a 400x300px image is given different border widths (top: 30px, right: 20px, bottom: 30px, left: 20px) with a blue background, the output is 440x360px with blue borders of the specified widths @test

Add edge-extended borders

The tool should support borders that extend the edge pixels of the image.

  • When a 250x150px image is given a 15-pixel border using edge extension, the output is 280x180px with borders that mirror the edge pixels @test

Add mirrored borders

The tool should support borders that mirror the image content.

  • When a 200x200px image is given a 25-pixel mirrored border on all sides, the output is 250x250px with borders that reflect the image content @test

Handle various image formats

The tool should work with common image formats.

  • When processing a JPEG image with borders, the output is a valid JPEG @test
  • When processing a PNG image with borders, the output is a valid PNG with preserved transparency if present @test

Implementation

@generates

API

/**
 * Adds a border to an image
 *
 * @param {string|Buffer} input - Path to input image or image buffer
 * @param {Object} options - Border configuration
 * @param {number} options.size - Border size in pixels (used for all sides if specific sizes not provided)
 * @param {number} [options.top] - Top border size in pixels (overrides size)
 * @param {number} [options.right] - Right border size in pixels (overrides size)
 * @param {number} [options.bottom] - Bottom border size in pixels (overrides size)
 * @param {number} [options.left] - Left border size in pixels (overrides size)
 * @param {string} [options.style='solid'] - Border style: 'solid', 'edge', 'mirror', 'repeat'
 * @param {string} [options.color='#000000'] - Border color (hex format) for solid style
 * @returns {Promise<Buffer>} Promise resolving to the processed image buffer
 */
async function addBorder(input, options) {
  // IMPLEMENTATION HERE
}

module.exports = {
  addBorder
};

Dependencies { .dependencies }

sharp { .dependency }

Provides high-performance image processing capabilities including border extension.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-sharp

tile.json