1.0.1 • Published 5 years ago
crop-tools v1.0.1
Crop Tools
Tools for calculating image crops.
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 }