fengyuanchen/cropperjs

rotate image will be bigger

lvqingxiang opened this issue · 1 comments

export function getRotatedSizes({ width, height, degree }) {
degree = Math.abs(degree) % 180;

if (degree === 90) {
return {
width: height,
height: width,
};
}

const arc = ((degree % 90) * Math.PI) / 180;
const sinArc = Math.sin(arc);
const cosArc = Math.cos(arc);
const newWidth = (width * cosArc) + (height * sinArc);
const newHeight = (width * sinArc) + (height * cosArc);

return degree > 90 ? {
width: newHeight,
height: newWidth,
} : {
width: newWidth,
height: newHeight,
};
}

why here check 90? now when my rotate > 90 image will be bigger and cannot be back, is there any solution to avoid image bigger?

Why? It is required to work properly. Just fork one and customize it by yourself.