crop-background-image
v2.0.6
Published
A helper class to crop background-less images.
Downloads
12
Readme
Image Cropping Utility with TypeScript
This TypeScript project contains a function that crops the edges of images with transparent backgrounds by detecting the edge colors.
Usage
The project includes a class named CropImageHelper
, which contains a function named cropImage
that can be used as shown below:
import { CropImageHelper } from "crop-background-image";
async function cropExample() {
try {
const imageUrl = "Here comes the image URL.";
const croppedImage = await new CropImageHelper(imageUrl).cropImage();
// croppedImage contains the base64 encoded data of the cropped image
console.log("Cropped Image:", croppedImage);
} catch (error) {
console.error("Error:", error);
}
}
cropExample();
| Before | After | | --------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | | | |
| Before | After | | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | | | |