DEV Community

Cover image for Crop images seamlessly in Node.js
Kunal Kande Patil
Kunal Kande Patil

Posted on • Edited on

2 1 1 1 2

Crop images seamlessly in Node.js

Cropify helps to crop and round image corners seamlessly.

Installation

npm install cropify
Enter fullscreen mode Exit fullscreen mode

Usage

const { cropImage } = require("cropify");
const fs = require("fs")

const imagePath = 'https://th.bing.com/th/id/OIGP.914kwCtAqWQ7Lkx5hT2B?pid=ImgGn';

const cropX = 0;
const cropY = 0;
const cropWidth = 1280;
const cropHeight = 720;
const borderRadius = 80;

cropImage({
    imagePath: imagePath,
    x: cropX,
    y: cropY,
    width: cropWidth,
    height: cropHeight,
    borderRadius: borderRadius,
    cropCenter: true
}).then(x => {
    fs.writeFileSync("cropped-image.png", x);
});
Enter fullscreen mode Exit fullscreen mode

Output

Example of Cropify

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay