Sharp for Image Crop Demo
Crop images to specific dimensions using Sharp.
Usage
The crop operation extracts a region from an image. Specify the width, height, and optional offsets to control the cropping area.
Parameters
width: Width of the crop area in pixelsheight: Height of the crop area in pixelsleft: Left offset (optional, default: 0)top: Top offset (optional, default: 0)
Example
javascript
await sharp('input.jpg')
.extract({ left: 100, top: 50, width: 800, height: 600 })
.toFile('cropped.jpg');