diff --git a/dist/image-editor.js b/dist/image-editor.js index db3146b..574776e 100644 --- a/dist/image-editor.js +++ b/dist/image-editor.js @@ -1210,7 +1210,9 @@ function ImageEditor(canvasId, args) { dimensions: { width: 800, height: 600 - } + }, + // Default unit + unit: 'cm' }, args); @@ -1269,14 +1271,14 @@ function ImageEditor(canvasId, args) { * Crops image to desired dimensions * @param {int} width [description] * @param {int} height [description] - * @param {string} units cm|inch + * @param {string} unit cm|inch * @return {ImageEditor} */ - this.crop = function (width, height, units) { - + this.crop = function (width, height, unit) { + unit = typeof unit !== 'undefined' ? unit : _settings.unit; _canvas.getImageData().removeCropData(); - _canvas.getViewport().set(width, height, units); + _canvas.getViewport().set(width, height, unit); var shouldBeCropped = util.isAspectChanged(_canvas.getImage().width, _canvas.getImage().height, width, height); diff --git a/examples/photo-wallpaper/index.html b/examples/photo-wallpaper/index.html index 9894685..bdd1a75 100644 --- a/examples/photo-wallpaper/index.html +++ b/examples/photo-wallpaper/index.html @@ -17,7 +17,7 @@ }); function cropImage() { - editor.crop(width.value, height.value, 'cm'); + editor.crop(width.value, height.value); } function resizeEditor() { diff --git a/src/ImageEditor.js b/src/ImageEditor.js index dfcfb4e..7d59955 100644 --- a/src/ImageEditor.js +++ b/src/ImageEditor.js @@ -24,7 +24,9 @@ function ImageEditor(canvasId, args) { dimensions: { width: 800, height: 600 - } + }, + // Default unit + unit: 'cm' }, args); @@ -83,14 +85,14 @@ function ImageEditor(canvasId, args) { * Crops image to desired dimensions * @param {int} width [description] * @param {int} height [description] - * @param {string} units cm|inch + * @param {string} unit cm|inch * @return {ImageEditor} */ - this.crop = function (width, height, units) { - + this.crop = function (width, height, unit) { + unit = typeof unit !== 'undefined' ? unit : _settings.unit; _canvas.getImageData().removeCropData(); - _canvas.getViewport().set(width, height, units); + _canvas.getViewport().set(width, height, unit); var shouldBeCropped = util.isAspectChanged(_canvas.getImage().width, _canvas.getImage().height, width, height);