export function getScaleRange(image, height, width) { const min = Math.max(height / image.height, width / image.width); // cover return { min, max: min + 2 }; // max should ideally be 1 } export function getDefaultCrop(image, height, width) { if (!image) return null; const scale = getScaleRange(image, height, width).min; return { scale, x: (image.width * scale - width) / 2, y: (image.height * scale - height) / 2, }; }