# crop-tools

> Tools for calculating image crops

Latest version **1.0.1** (published 2019-09-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install crop-tools
pnpm add crop-tools
yarn add crop-tools
bun add crop-tools
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-09-01 |
| First published | 2019-09-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 20.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Christian Hamburger Grøngaard |
| Maintainers | christianhg |
| Keywords | cropping, images |

## Links

- npm: https://www.npmjs.com/package/crop-tools
- Repository: https://github.com/christianhg/crop-tools
- Issues: https://github.com/christianhg/crop-tools/issues
- npm.io page: https://npm.io/package/crop-tools

## Dependencies (2)

- [fit-box](https://npm.io/package/fit-box.md) ^1.1.0
- [place-box](https://npm.io/package/place-box.md) ^1.1.0

## 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

- 1.0.1 (latest) — 2019-09-01
- 1.0.0 — 2019-09-01

## README

# Crop Tools

> Tools for calculating image crops.

[![npm module](https://badge.fury.io/js/crop-tools.svg)](https://www.npmjs.org/package/crop-tools)
[![Coverage Status](https://coveralls.io/repos/github/christianhg/crop-tools/badge.svg?branch=master)](https://coveralls.io/github/christianhg/crop-tools?branch=master)
[![Build Status](https://travis-ci.org/christianhg/crop-tools.svg?branch=master)](https://travis-ci.org/christianhg/crop-tools)
[![Dependencies](https://david-dm.org/christianhg/crop-tools.svg)](https://david-dm.org/christianhg/crop-tools)
[![devDependencies Status](https://david-dm.org/christianhg/crop-tools/dev-status.svg)](https://david-dm.org/christianhg/crop-tools?type=dev)

```js
import { calculateCrop, scaleCrop } from 'crop-tools';

const crop = calculateCrop({
  imageDimensions: {
    width: 1280,
    height: 720,
  },
  cropDimensions: {
    width: 300,
    height: 400,
  },
});
// => { width: 540, height: 720, left: 370, top: 0 }

const cropUsingPOI = calculateCrop({
  imageDimensions: {
    width: 1280,
    height: 720,
  },
  cropDimensions: {
    width: 300,
    height: 400,
  },
  poi: {
    x: 25,
    y: 25,
  },
});
// => { width: 540, height: 720, left: 0, top: 0 }

const scaledCrop = scaleCrop({
  imageDimensions: {
    original: {
      width: 1280,
      height: 720,
    },
    current: {
      width: 320,
      height: 180,
    },
  },
  crop,
});
// => { width: 135, height: 180, left: 92.5, top: 0 }
```

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