I'm using Cropper to try and get a fixed size crop from uploaded images. The idea is that the admin of the website will be able to zoom if (if needed) and frame the new image in the Cropper that can't be changed. In this way all images that are cropped are exactly the same size.
This works unless the user zooms in. In this case the resulting image is smaller and if they zoom out it is larger.
I'm initialising the cropper with this:
$('#image').cropper({
aspectRatio: 16 / 9,
cropBoxResizable: false,
dragMode: 'move',
built: function () {
$("#image").cropper('setCropBoxData', { width: 640 });
},
cropmove: function () {
$("#image").cropper('setCropBoxData', { width: 640 });
}
});
and then getting a dataUrl for upload using this:
var image = $("#image").cropper("getCroppedCanvas").toDataURL('image/jpeg', 1);
It appears that it is cropping by looking at the area bounded by the crop box and then cropping the image using the original size. In other words the box simply defines a bound region of the image which the cropper is then cutting out of the original image at the original size. I need them to be the size defined in the Cropper settings.
Let me know if you need more.