# cropify

> A fast, powerful image cropping & manipulation library for Node.js

Latest version **2.0.2** (published 2025-12-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install cropify
pnpm add cropify
yarn add cropify
bun add cropify
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2025-12-16 |
| First published | 2024-01-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 45.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Author | Kunal KandePatil |
| Maintainers | flameface |
| Keywords | image, crop, canvas, resize, filter, thumbnail |

## Links

- npm: https://www.npmjs.com/package/cropify
- Repository: https://github.com/kunalkandepatil/cropify
- Homepage: https://github.com/kunalkandepatil/cropify#readme
- Issues: https://github.com/kunalkandepatil/cropify/issues
- npm.io page: https://npm.io/package/cropify

## Dependencies (1)

- [@napi-rs/canvas](https://npm.io/package/@napi-rs/canvas.md) ^0.1.74

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 2.0.2 (latest) — 2025-12-16
- 1.0.9-beta.1 (beta) — 2024-03-16
- 2.0.1 — 2025-07-17
- 2.0.0 — 2025-07-17
- 1.0.9 — 2024-03-16
- 1.0.9-beta.0 — 2024-03-16
- 1.0.8 — 2024-02-17
- 1.0.7 — 2024-02-17
- 1.0.6 — 2024-02-17
- 1.0.5 — 2024-02-13
- 1.0.4 — 2024-02-13
- 1.0.3 — 2024-02-13
- 1.0.2 — 2024-02-11
- 1.0.1 — 2024-01-19
- 1.0.0 — 2024-01-19
- … 1 more at https://npm.io/package/cropify/versions

## README

<div align="center">

<img src="https://raw.githubusercontent.com/kunalkandepatil/.github/refs/heads/main/assets/cropify/banner.svg" alt="cropify banner" />
<br>
<br>


# **˗ˏˋ cropify ´ˎ˗**
A fast, powerful image cropping & manipulation library for Node.js

[![NPM Version](https://img.shields.io/npm/v/cropify?style=flat-square&color=%232FCEFF)](https://www.npmjs.com/package/cropify)
[![NPM Downloads](https://img.shields.io/npm/dw/cropify?style=flat-square&color=%232FCEFF)](https://www.npmjs.com/package/cropify)
[![NPM License](https://img.shields.io/npm/l/cropify?style=flat-square&color=%232FCEFF)](https://github.com/kunalkandepatil/cropify/blob/main/LICENSE)
[![GitHub Repo stars](https://img.shields.io/github/stars/kunalkandepatil/cropify?style=flat-square&color=%232FCEFF)](https://github.com/kunalkandepatil/cropify)

<br>

<img src="https://raw.githubusercontent.com/kunalkandepatil/.github/refs/heads/main/assets/cropify/features.svg" alt="cropify features" />

<br>

</div>


## 📄 Documentation 
### ╰┈1️⃣ Quick Start
```bash
npm install cropify
```
```js
const { cropImage } = require('cropify');
const fs = require('fs');

// Basic cropping
const result = await cropImage({
    imagePath: 'input.jpg',
    width: 800,
    height: 600,
    cropCenter: true
});

fs.writeFileSync('output.png', result);
```

<p align="center">≪ ◦ ✦ ◦ ≫</p>

### ╰┈2️⃣ API Reference
#### Main Function `cropImage(options: CropifyOptions)`
Crops and manipulates an image based on the provided options.
**Parameters:**
- `options` - Configuration object with the following properties:

#### Basic Options
```typescript
{
    imagePath: string | Buffer | URL;  // Input image path or buffer
    x?: number;                        // X coordinate (default: 0)
    y?: number;                        // Y coordinate (default: 0)
    width?: number;                    // Output width (default: original)
    height?: number;                   // Output height (default: original)
    borderRadius?: number;             // Rounded corners radius
    circle?: boolean;                  // Circular crop
    cropCenter?: boolean;              // Center the crop
}
```

#### Advanced Options
```typescript
{
    fit?: 'cover' | 'contain' | 'fill' | 'inside' | 'outside';
    position?: 'center' | 'top' | 'bottom' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
    background?: string;               // Background color (CSS color)
}
```

#### Shape Options
```typescript
{
    shape?: {
        type: 'rectangle' | 'circle' | 'polygon' | 'star' | 'custom';
        sides?: number;                // For polygon/star (3+)
        points?: Array<{x: number, y: number}>; // For custom shapes (%)
        customPath?: string;           // SVG path (planned)
    }
}
```

#### Filter Options
```typescript
{
    filters?: {
        brightness?: number;           // -100 to 100
        contrast?: number;             // -100 to 100
        saturation?: number;           // -100 to 100
        blur?: number;                 // 0 to 20
        grayscale?: boolean;           // Convert to grayscale
        sepia?: boolean;               // Apply sepia tone
        invert?: boolean;              // Invert colors
        hue?: number;                  // Hue rotation (0-360)
    }
}
```

#### Output Options
```typescript
{
    output?: {
        format?: 'png' | 'jpeg' | 'webp';
        quality?: number;              // 0-100 (JPEG/WebP only)
        progressive?: boolean;         // Progressive JPEG (planned)
        adaptiveQuality?: boolean;     // Adaptive quality (planned)
    }
}
```


<p align="center">≪ ◦ ✦ ◦ ≫</p>

## 🎧 Support Server
<a href="https://discord.gg/W8wTjESM3t"><img src="https://raw.githubusercontent.com/kunalkandepatil/.github/refs/heads/main/assets/discord.svg" alt="support server" /></a>

---
_Source: https://npm.io/package/cropify · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
