In my application I switch between images and preserve each image's
cropper values, however if I use the following code to display the cropper
with the image's previously saved cropper settings, I must calculate
ratioX and ratioY manually and supply them, even though I am supplying
ratioDim. Without supplying them, the fixed ratio is not applied.
The code below works, but see the comments.
cropX1, cropX2, cropY1, and cropY2 are all saved previously onEndCrop
targetRatio is calculated from user input values for a target output image
size.
-----------
crop.options.onloadCoords = { x1: cropX1, y1: cropY1, x2: cropX2, y2:
cropY2 };
crop.options.ratioDim = { x: targetRatio, y: 1 };
crop.options.onEndCrop = oec;
//this part could be recalculated by setParams, but is not
var gcd = crop.getGCD( crop.options.ratioDim.x, crop.options.ratioDim.y );
crop.ratioX = crop.options.ratioDim.x / gcd;
crop.ratioY = crop.options.ratioDim.y / gcd;
crop.reset();
----------------
To expand on this further, it should be rather trivial to add a function
that allows us to reset cropper settings without needing to access the
cropper parameters directly. The function could use the same syntax as
the constructor, but would obviously just reset the cropper rather than
creating a new object.