crop-tools
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Crop Tools

Tools for calculating image crops.

npm module Coverage Status Build Status Dependencies devDependencies Status

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 }

Readme

Keywords

Package Sidebar

Install

npm i crop-tools

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

21 kB

Total Files

17

Last publish

Collaborators

  • christianhg