High performance Node.js image processing library for resizing JPEG, PNG, WebP, GIF, AVIF and TIFF images
80
Build a utility that automatically removes uniform borders from images.
Create a module that processes images by detecting and removing uniform-colored borders around the edges. The module should analyze the image to identify areas where the border color is similar to the corners and trim those areas away, leaving only the meaningful content.
The utility should handle common image formats and should be able to:
The module should accept an input image file and produce an output image file with borders removed. It should work with common formats like JPEG, PNG, and WebP.
@generates
/**
* Trims uniform borders from an image.
*
* @param {string} inputPath - Path to the input image file
* @param {string} outputPath - Path where the trimmed image will be saved
* @param {Object} options - Configuration options
* @param {number} [options.threshold=10] - Similarity threshold for border detection (0-100)
* @returns {Promise<Object>} Promise resolving to an object with trimming information
*/
async function trimBorders(inputPath, outputPath, options = {}) {
// Implementation here
}
module.exports = { trimBorders };Provides image processing capabilities including border detection and trimming.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-sharpdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10