fengyuanchen / cropper

⚠️ [Deprecated] No longer maintained, please use https://github.com/fengyuanchen/jquery-cropper
MIT License
7.75k stars 1.74k forks source link

Force the image width & height #958

Closed baj84 closed 6 years ago

baj84 commented 6 years ago

I am using the cropper to crop big images 6000 pixels+, instead of loading in such a large image i'm trying to use a smaller image (500x500px) and just stretch it (lose of quality isn't an issue), so that the cropping is still relative to the large image.

Is this possible?

Cheers

fengyuanchen commented 6 years ago

Just compute by the scale ratio:

const scaledRatio = 6000 / 500;

// cropping...

const croppedData = cropper.getData();

croppedData.x *= scaledRatio;
croppedData.y *= scaledRatio;
croppedData.width *= scaledRatio;
croppedData.height *= scaledRatio;

// upload the cropped data...