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.
npm install bandana20This 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.
You can install this package via npm:
``bash`
npm install image-processing
`javascript
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');
`
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 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.
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.).
-
This project is licensed under the MIT License - see the LICENSE file for details.