Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/unburn/cropify
Crop and round image corners seamlessly.
https://github.com/unburn/cropify
border-radius canvas crop crop-canvas crop-image crop-images cropify unburn
Last synced: about 2 months ago
JSON representation
Crop and round image corners seamlessly.
- Host: GitHub
- URL: https://github.com/unburn/cropify
- Owner: unburn
- Created: 2024-01-19T15:42:25.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-05-28T07:38:49.000Z (7 months ago)
- Last Synced: 2024-10-04T02:54:33.206Z (3 months ago)
- Topics: border-radius, canvas, crop, crop-canvas, crop-image, crop-images, cropify, unburn
- Language: TypeScript
- Homepage:
- Size: 5.41 MB
- Stars: 8
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
Cropify helps to crop and round image corners seamlessly.
[![NPM Version](https://img.shields.io/npm/v/cropify?style=flat-square&color=%2300ADD3)](https://www.npmjs.com/package/cropify)
[![NPM Downloads](https://img.shields.io/npm/dw/cropify?style=flat-square&color=%2300ADD3)](https://www.npmjs.com/package/cropify)
[![NPM License](https://img.shields.io/npm/l/cropify?style=flat-square&color=%2300ADD3)](https://github.com/unburn/cropify/blob/main/LICENCE)
[![GitHub Repo stars](https://img.shields.io/github/stars/unburn/cropify?style=flat-square&color=%2300ADD3)](https://github.com/unburn/cropify)# Features
- Crop images with precision using the Canvas API.
- Optional support for rounding corners with a customizable border radius.
- Designed for simplicity and performance.
- Upscale and cover image.# Installation
```
npm install cropify
```# Usage
```javascript
import { cropImage } from "cropify";
import fs from "fs";// OR
const { cropImage } = require("cropify");
const fs = require("fs");const image = '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: image,
x: cropX,
y: cropY,
width: cropWidth,
height: cropHeight,
borderRadius: borderRadius,
cropCenter: true
}).then(x => {
console.log("Image has been cropped.")
fs.writeFileSync("cropped-image.png", x);
});
```## Output
![example](https://ik.imagekit.io/unburn/CropifyExample.svg)# Licence
[MIT](https://github.com/unburn/cropify/blob/main/LICENCE)