fengyuanchen / cropperjs

JavaScript image cropper.
https://fengyuanchen.github.io/cropperjs/
MIT License
13.16k stars 2.42k forks source link

rotate image will be bigger #1135

Closed lvqingxiang closed 10 months ago

lvqingxiang commented 10 months ago

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?

fengyuanchen commented 10 months ago

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