bandana20
v1.0.0
Published
Create a package for image processing tasks like resizing, cropping, and applying filters. This could be useful for building image-heavy applications or handling uploads in web development.
Downloads
3
Readme
Image Processing Package
This is a simple image processing package for Node.js that provides basic functionality for resizing, cropping, and applying filters to images using the sharp
module.
Installation
You can install this package via npm:
npm install image-processing
Usage
const ImageProcessing = require('image-processing');
// Create a new instance of the ImageProcessing class
const imageProcessor = new ImageProcessing();
// Example: Resize an image
imageProcessor.resize('input.jpg', 'output_resized.jpg', 200, 200);
// Example: Crop an image
imageProcessor.crop('input.jpg', 'output_cropped.jpg', 50, 50, 200, 200);
// Example: Apply a filter (e.g., greyscale)
imageProcessor.applyFilter('input.jpg', 'output_filtered.jpg', 'greyscale');
API
resize(inputPath, outputPath, width, height)
Resize an image to the specified width and height.
inputPath
(string): Path to the input image file.outputPath
(string): Path where the resized image will be saved.width
(number): Target width of the resized image.height
(number): Target height of the resized image.
crop(inputPath, outputPath, left, top, width, height)
Crop an image to the specified dimensions.
inputPath
(string): Path to the input image file.outputPath
(string): Path where the cropped image will be saved.left
(number): X-coordinate of the top-left corner of the crop area.top
(number): Y-coordinate of the top-left corner of the crop area.width
(number): Width of the crop area.height
(number): Height of the crop area.
applyFilter(inputPath, outputPath, filterName)
Apply a filter to the image.
inputPath
(string): Path to the input image file.outputPath
(string): Path where the filtered image will be saved.filterName
(string): Name of the filter to apply (e.g., 'greyscale', 'sepia', etc.).
License
This project is licensed under the MIT License - see the LICENSE file for details.