{"_id":"2mundos-cropperjs","_rev":"4-e8ff76c3fddd9368bf05b8fedfaa667a","name":"2mundos-cropperjs","dist-tags":{"latest":"1.2.2-2m.0.1"},"versions":{"1.2.2-2m.0.0":{"name":"2mundos-cropperjs","description":"JavaScript image cropper.","version":"1.2.2-2m.0.0","main":"dist/cropper.common.js","module":"dist/cropper.esm.js","browser":"dist/cropper.js","style":"dist/cropper.css","repository":{"type":"git","url":"git+https://github.com/tpeixoto/2mundos-cropperjs.git"},"homepage":"https://fengyuanchen.github.io/cropperjs","license":"MIT","author":{"name":"Chen Fengyuan","url":"http://chenfengyuan.com"},"files":["src","dist"],"keywords":["image","crop","cropping","move","zoom","rotate","scale","cropper","cropperjs","cropper.js","html","css","javascript","front-end","web","development"],"scripts":{"build":"npm run build:css && npm run build:js","build:css":"postcss src/css/cropper.css -o dist/cropper.css --no-map","build:js":"rollup -c","clear":"del-cli dist","compress":"npm run compress:css && npm run compress:js","compress:css":"postcss dist/cropper.css -u cssnano -o dist/cropper.min.css --no-map","compress:js":"uglifyjs dist/cropper.js -o dist/cropper.min.js -c -m --comments /^!/","copy":"cpy dist/cropper.css docs/css","lint":"eslint src/js --fix","release":"npm run clear && npm run lint && npm run build && npm run compress && npm run copy && npm test","start":"npm-run-all --parallel watch:*","test":"node-qunit-phantomjs test/index.html --timeout 10","watch:css":"postcss src/css/cropper.css -o docs/css/cropper.css -m -w","watch:js":"rollup -c -m -w"},"devDependencies":{"babel-core":"^6.26.0","babel-plugin-external-helpers":"^6.22.0","babel-preset-env":"^1.6.1","cpy-cli":"^1.0.1","cssnano":"^3.10.0","del-cli":"^1.1.0","eslint":"^4.14.0","eslint-config-airbnb-base":"^12.1.0","eslint-plugin-import":"^2.8.0","node-qunit-phantomjs":"^2.0.0","npm-run-all":"^4.1.2","postcss-cli":"^4.1.1","postcss-cssnext":"^3.0.2","postcss-header":"^1.0.0","postcss-url":"^7.3.0","rollup":"^0.53.3","rollup-plugin-babel":"^3.0.3","rollup-watch":"^4.3.1","stylefmt":"^6.0.0","uglify-js":"^3.3.4"},"gitHead":"8e1c70c5a4a83a2b506d34c3647705544faa9514","bugs":{"url":"https://github.com/tpeixoto/2mundos-cropperjs/issues"},"_id":"2mundos-cropperjs@1.2.2-2m.0.0","_npmVersion":"5.6.0","_nodeVersion":"8.9.4","_npmUser":{"name":"tpeixoto2m","email":"tpeixoto@2mundos.net"},"dist":{"integrity":"sha512-NlczsrLsc3axNfxGM1agCBcxKPULWWVLf7s+/Xn1EMqT9hnJaqO1oLVvPfUzn8aXDIBz0mFXrCSbNDHFYuQleA==","shasum":"a792c16756993dfa377b11b15585ac44a1ccfb2d","tarball":"https://registry.npmjs.org/2mundos-cropperjs/-/2mundos-cropperjs-1.2.2-2m.0.0.tgz","fileCount":23,"unpackedSize":484119,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHdQ2XKjcHsmy4rikWkQ5ZKrtQqDZv50QkRptP9i9/rHAiAVO0yNgCePBKROt+BNycg7osLIeAj20aMy/1b6xxBraQ=="}]},"maintainers":[{"name":"tpeixoto2m","email":"tpeixoto@2mundos.net"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/2mundos-cropperjs_1.2.2-2m.0.0_1521222277843_0.24357817005236315"},"_hasShrinkwrap":false},"1.2.2-test.0":{"name":"2mundos-cropperjs","description":"JavaScript image cropper.","version":"1.2.2-test.0","main":"dist/cropper.common.js","module":"dist/cropper.esm.js","browser":"dist/cropper.js","style":"dist/cropper.css","repository":{"type":"git","url":"git+https://github.com/tpeixoto/2mundos-cropperjs.git"},"homepage":"https://fengyuanchen.github.io/cropperjs","license":"MIT","author":{"name":"Chen Fengyuan","url":"http://chenfengyuan.com"},"files":["src","dist"],"keywords":["image","crop","cropping","move","zoom","rotate","scale","cropper","cropperjs","cropper.js","html","css","javascript","front-end","web","development"],"scripts":{"build":"npm run build:css && npm run build:js","build:css":"postcss src/css/cropper.css -o dist/cropper.css --no-map","build:js":"rollup -c","clear":"del-cli dist","compress":"npm run compress:css && npm run compress:js","compress:css":"postcss dist/cropper.css -u cssnano -o dist/cropper.min.css --no-map","compress:js":"uglifyjs dist/cropper.js -o dist/cropper.min.js -c -m --comments /^!/","copy":"cpy dist/cropper.css docs/css","lint":"eslint src/js --fix","release":"npm run clear && npm run lint && npm run build && npm run compress && npm run copy && npm test","start":"npm-run-all --parallel watch:*","test":"node-qunit-phantomjs test/index.html --timeout 10","watch:css":"postcss src/css/cropper.css -o docs/css/cropper.css -m -w","watch:js":"rollup -c -m -w"},"devDependencies":{"babel-core":"^6.26.0","babel-plugin-external-helpers":"^6.22.0","babel-preset-env":"^1.6.1","cpy-cli":"^1.0.1","cssnano":"^3.10.0","del-cli":"^1.1.0","eslint":"^4.14.0","eslint-config-airbnb-base":"^12.1.0","eslint-plugin-import":"^2.8.0","node-qunit-phantomjs":"^2.0.0","npm-run-all":"^4.1.2","postcss-cli":"^4.1.1","postcss-cssnext":"^3.0.2","postcss-header":"^1.0.0","postcss-url":"^7.3.0","rollup":"^0.53.3","rollup-plugin-babel":"^3.0.3","rollup-watch":"^4.3.1","stylefmt":"^6.0.0","uglify-js":"^3.3.4"},"gitHead":"cb96e38170954f686b8b748260fc1aafc877dc4d","bugs":{"url":"https://github.com/tpeixoto/2mundos-cropperjs/issues"},"_id":"2mundos-cropperjs@1.2.2-test.0","_npmVersion":"5.6.0","_nodeVersion":"8.9.4","_npmUser":{"name":"tpeixoto2m","email":"tpeixoto@2mundos.net"},"dist":{"integrity":"sha512-7x2t4MlBbTRNU00MpARkviag9Uxe/U3MtYMeEJ+MpoJfbBoaIJO7eYdwuPF+wjMAMUud35iBthO6G4KYhmlUXw==","shasum":"c1564877db7a9bd19f42eb0129cd1a3c9348fca7","tarball":"https://registry.npmjs.org/2mundos-cropperjs/-/2mundos-cropperjs-1.2.2-test.0.tgz","fileCount":23,"unpackedSize":484119,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGSqjtG4uNnvgaA2grjSnqh7muFedn0NQv1ANIFt7lpUAiEApQ8EnC2RgOLmS5GmkKA7QQ6KnXedlKx8Nnz3Nz2ao8A="}]},"maintainers":[{"name":"tpeixoto2m","email":"tpeixoto@2mundos.net"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/2mundos-cropperjs_1.2.2-test.0_1521230549887_0.23466134014769802"},"_hasShrinkwrap":false},"1.2.2-2m.0.1":{"name":"2mundos-cropperjs","description":"JavaScript image cropper.","version":"1.2.2-2m.0.1","main":"dist/cropper.common.js","module":"dist/cropper.esm.js","browser":"dist/cropper.js","style":"dist/cropper.css","repository":{"type":"git","url":"git+https://github.com/tpeixoto/2mundos-cropperjs.git"},"homepage":"https://fengyuanchen.github.io/cropperjs","license":"MIT","author":{"name":"Chen Fengyuan","url":"http://chenfengyuan.com"},"files":["src","dist"],"keywords":["image","crop","cropping","move","zoom","rotate","scale","cropper","cropperjs","cropper.js","html","css","javascript","front-end","web","development"],"scripts":{"build":"npm run build:css && npm run build:js","build:css":"postcss src/css/cropper.css -o dist/cropper.css --no-map","build:js":"rollup -c","clear":"del-cli dist","compress":"npm run compress:css && npm run compress:js","compress:css":"postcss dist/cropper.css -u cssnano -o dist/cropper.min.css --no-map","compress:js":"uglifyjs dist/cropper.js -o dist/cropper.min.js -c -m --comments /^!/","copy":"cpy dist/cropper.css docs/css","lint":"eslint src/js --fix","release":"npm run clear && npm run lint && npm run build && npm run compress && npm run copy && npm test","start":"npm-run-all --parallel watch:*","test":"node-qunit-phantomjs test/index.html --timeout 10","watch:css":"postcss src/css/cropper.css -o docs/css/cropper.css -m -w","watch:js":"rollup -c -m -w"},"devDependencies":{"babel-core":"^6.26.0","babel-plugin-external-helpers":"^6.22.0","babel-preset-env":"^1.6.1","cpy-cli":"^1.0.1","cssnano":"^3.10.0","del-cli":"^1.1.0","eslint":"^4.14.0","eslint-config-airbnb-base":"^12.1.0","eslint-plugin-import":"^2.8.0","node-qunit-phantomjs":"^2.0.0","npm-run-all":"^4.1.2","postcss-cli":"^4.1.1","postcss-cssnext":"^3.0.2","postcss-header":"^1.0.0","postcss-url":"^7.3.0","rollup":"^0.53.3","rollup-plugin-babel":"^3.0.3","rollup-watch":"^4.3.1","stylefmt":"^6.0.0","uglify-js":"^3.3.4"},"gitHead":"2775d9ca4442bbbb2383875289e481c4f78c7af5","bugs":{"url":"https://github.com/tpeixoto/2mundos-cropperjs/issues"},"_id":"2mundos-cropperjs@1.2.2-2m.0.1","_npmVersion":"5.6.0","_nodeVersion":"8.9.4","_npmUser":{"name":"tpeixoto2m","email":"tpeixoto@2mundos.net"},"dist":{"integrity":"sha512-cU8Y0Ym/naRLZ9hUlgZSM5HvwyXVHLh8wiY8Le+1uvWX/B61LakJXl/abQyU9xgkJShvsa89tTkKUwe6rlHY6Q==","shasum":"14b43c4f1fb0fcdac73dbda36aa4ec4129f957fb","tarball":"https://registry.npmjs.org/2mundos-cropperjs/-/2mundos-cropperjs-1.2.2-2m.0.1.tgz","fileCount":23,"unpackedSize":484119,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD2T784iXLWkMY1qtxF4s+TG4G0IaV8K3qFpcQLNLTLfQIhAIJelDLYWjgv6eLM2y98d4Zy6DM4naABvpVO0HwkXfZo"}]},"maintainers":[{"name":"tpeixoto2m","email":"tpeixoto@2mundos.net"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/2mundos-cropperjs_1.2.2-2m.0.1_1521496843989_0.8459236278679927"},"_hasShrinkwrap":false}},"time":{"created":"2018-03-16T17:44:37.842Z","1.2.2-2m.0.0":"2018-03-16T17:44:37.985Z","modified":"2022-04-04T10:19:25.646Z","1.2.2-test.0":"2018-03-16T20:02:30.024Z","1.2.2-2m.0.1":"2018-03-19T22:00:44.132Z"},"maintainers":[{"name":"tpeixoto2m","email":"tpeixoto@2mundos.net"}],"description":"JavaScript image cropper.","homepage":"https://fengyuanchen.github.io/cropperjs","keywords":["image","crop","cropping","move","zoom","rotate","scale","cropper","cropperjs","cropper.js","html","css","javascript","front-end","web","development"],"repository":{"type":"git","url":"git+https://github.com/tpeixoto/2mundos-cropperjs.git"},"author":{"name":"Chen Fengyuan","url":"http://chenfengyuan.com"},"bugs":{"url":"https://github.com/tpeixoto/2mundos-cropperjs/issues"},"license":"MIT","readme":"# Cropper.js\n\n[![Build Status](https://travis-ci.org/fengyuanchen/cropperjs.svg)](https://travis-ci.org/fengyuanchen/cropperjs) [![Downloads](https://img.shields.io/npm/dm/cropperjs.svg)](https://www.npmjs.com/package/cropperjs) [![Version](https://img.shields.io/npm/v/cropperjs.svg)](https://www.npmjs.com/package/cropperjs)\n\n> JavaScript image cropper.\n\n- [Website](https://fengyuanchen.github.io/cropperjs)\n- [Photo Editor](https://fengyuanchen.github.io/photo-editor) - An advanced example of Cropper.js.\n\n## Table of contents\n\n- [Features](#features)\n- [Main](#main)\n- [Getting started](#getting-started)\n- [Options](#options)\n- [Methods](#methods)\n- [Events](#events)\n- [No conflict](#no-conflict)\n- [Browser support](#browser-support)\n- [Contributing](#contributing)\n- [Versioning](#versioning)\n- [License](#license)\n\n## Features\n\n- Supports 38 [options](#options)\n- Supports 27 [methods](#methods)\n- Supports 6 [events](#events)\n- Supports touch (mobile)\n- Supports zooming\n- Supports rotating\n- Supports scaling (flipping)\n- Supports multiple croppers\n- Supports to crop on a canvas\n- Supports to crop image in the browser-side by canvas\n- Supports to translate Exif Orientation information\n- Cross-browser support\n\n## Main\n\n```text\ndist/\n├── cropper.css\n├── cropper.min.css   (compressed)\n├── cropper.js        (UMD)\n├── cropper.min.js    (UMD, compressed)\n├── cropper.common.js (CommonJS, default)\n└── cropper.esm.js    (ES Module)\n```\n\n## Getting started\n\n### Installation\n\n```shell\nnpm install cropperjs\n```\n\nInclude files:\n\n```html\n<link  href=\"/path/to/cropper.css\" rel=\"stylesheet\">\n<script src=\"/path/to/cropper.js\"></script>\n```\n\nThe [cdnjs](https://github.com/cdnjs/cdnjs) provides CDN support for Cropper.js's CSS and JavaScript. You can find the links [here](https://cdnjs.com/libraries/cropperjs).\n\n### Usage\n\nInitialize with `Cropper` constructor:\n\n- Browser: `window.Cropper`\n- CommonJS: `var Cropper = require('cropperjs')`\n- ES2015: `import Cropper from 'cropperjs'`\n\n```html\n<!-- Wrap the image or canvas element with a block element (container) -->\n<div>\n  <img id=\"image\" src=\"picture.jpg\">\n</div>\n```\n\n```css\n/* Limit image width to avoid overflow the container */\nimg {\n  max-width: 100%; /* This rule is very important, please do not ignore this! */\n}\n```\n\n```js\nvar image = document.getElementById('image');\nvar cropper = new Cropper(image, {\n  aspectRatio: 16 / 9,\n  crop: function(e) {\n    console.log(e.detail.x);\n    console.log(e.detail.y);\n    console.log(e.detail.width);\n    console.log(e.detail.height);\n    console.log(e.detail.rotate);\n    console.log(e.detail.scaleX);\n    console.log(e.detail.scaleY);\n  }\n});\n```\n\n#### FAQ\n\nHow to crop a new area after zoom in or zoom out?\n\n> Just double click your mouse to enter crop mode.\n\nHow to move the image after crop an area?\n\n> Just double click your mouse to enter move mode.\n\nHow to fix aspect ratio in free ratio mode?\n\n> Just hold the `shift` key when you resize the crop box.\n\nHow to crop a square area in free ratio mode?\n\n> Just hold the `shift` key when you crop on the image.\n\n#### Notes\n\n- The size of the cropper inherits from the size of the image's parent element (wrapper), so be sure to wrap the image with a **visible block element**.\n  > If you are using cropper in a modal, you should initialize the cropper after the modal shown completely. Otherwise, you will not get a correct cropper.\n\n- The outputted cropped data bases on the original image size, so you can use them to crop the image directly.\n\n- If you try to start cropper on a cross-origin image, please make sure that your browser supports HTML5 [CORS settings attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes), and your image server supports the `Access-Control-Allow-Origin` option (see the [HTTP access control (CORS)](https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS)).\n\n#### Known issues\n\n- [Known iOS resource limits](https://developer.apple.com/library/mac/documentation/AppleApplications/Reference/SafariWebContent/CreatingContentforSafarioniPhone/CreatingContentforSafarioniPhone.html): As iOS devices limit memory, the browser may crash when you are cropping a large image (iPhone camera resolution). To avoid this, you may resize the image first (preferably below 1024 pixels) before start a cropper.\n\n- Known image size increase: When export the cropped image on browser-side with the `HTMLCanvasElement.toDataURL` method, the size of the exported image may be greater than the original image's. This is because the type of the exported image is not the same as the original image's. So just pass the type the original image's as the first parameter to `toDataURL` to fix this. For example, if the original type is JPEG, then use `cropper.getCroppedCanvas().toDataURL('image/jpeg')` to export image.\n\n[⬆ back to top](#table-of-contents)\n\n## Options\n\nYou may set cropper options with `new Cropper(image, options)`.\nIf you want to change the global default options, You may use `Cropper.setDefaults(options)`.\n\n### viewMode\n\n- Type: `Number`\n- Default: `0`\n- Options:\n  - `0`: no restrictions\n  - `1`: restrict the crop box to not exceed the size of the canvas.\n  - `2`: restrict the minimum canvas size to fit within the container. If the proportions of the the canvas and the container differ, the minimum canvas will be surrounded by extra space in one of the dimensions.\n  - `3`: restrict the minimum canvas size to fill fit the container. If the proportions of the canvas and the container are different, the container will not be able to fit the whole canvas in one of the dimensions.\n\nDefine the view mode of the cropper. If you set `viewMode` to `0`, the crop box can extend outside the canvas, while a value of `1`, `2` or `3` will restrict the crop box to the size of the canvas. A `viewMode` of `2` or `3` will additionally restrict the canvas to the container. Note that if the proportions of the canvas and the container are the same, there is no difference between `2` and `3`.\n\n### dragMode\n\n- Type: `String`\n- Default: `'crop'`\n- Options:\n  - `'crop'`: create a new crop box\n  - `'move'`: move the canvas\n  - `'none'`: do nothing\n\nDefine the dragging mode of the cropper.\n\n### aspectRatio\n\n- Type: `Number`\n- Default: `NaN`\n\nSet the aspect ratio of the crop box. By default, the crop box is free ratio.\n\n### data\n\n- Type: `Object`\n- Default: `null`\n\nThe previous cropped data if you had stored, will be passed to `setData` method automatically when built.\n\n### preview\n\n- Type: `Element` or `String`\n- Default: `''`\n- An element or A valid selector for [Document.querySelectorAll](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll)\n\nAdd extra elements (containers) for previewing.\n\n**Notes:**\n\n- The maximum width is the initial width of preview container.\n- The maximum height is the initial height of preview container.\n- If you set an `aspectRatio` option, be sure to set the same aspect ratio to the preview container.\n- If preview is not getting properly displayed, set `overflow: hidden` style to the preview container.\n\n### responsive\n\n- Type: `Boolean`\n- Default: `true`\n\nRe-render the cropper when resize the window.\n\n### restore\n\n- Type: `Boolean`\n- Default: `true`\n\nRestore the cropped area after resize the window.\n\n### checkCrossOrigin\n\n- Type: `Boolean`\n- Default: `true`\n\nCheck if the current image is a cross-origin image.\n\nIf it is, when clone the image, a `crossOrigin` attribute will be added to the cloned image element and a timestamp will be added to the `src` attribute to reload the source image to avoid browser cache error.\n\nBy adding `crossOrigin` attribute to image will stop adding timestamp to image url, and stop reload of image.\n\nIf the value of the image's `crossOrigin` attribute is `\"use-credentials\"`, then the `withCredentials` attribute will set to `true` when read the image data by XMLHttpRequest.\n\n### checkOrientation\n\n- Type: `Boolean`\n- Default: `true`\n\nCheck the current image's Exif Orientation information.\n\nMore exactly, read the Orientation value for rotating or flipping the image, and then override the Orientation value with `1` (the default value) to avoid some issues ([1](https://github.com/fengyuanchen/cropper/issues/120), [2](https://github.com/fengyuanchen/cropper/issues/509)) on iOS devices.\n\nRequires to set both the `rotatable` and `scalable` options to `true` at the same time.\n\n**Note:** Don't trust this all the time as some JPG images have incorrect (not standard) Orientation values.\n\n> Requires [Typed Arrays](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) support ([IE 10+](http://caniuse.com/typedarrays)).\n\n### modal\n\n- Type: `Boolean`\n- Default: `true`\n\nShow the black modal above the image and under the crop box.\n\n### guides\n\n- Type: `Boolean`\n- Default: `true`\n\nShow the dashed lines above the crop box.\n\n### center\n\n- Type: `Boolean`\n- Default: `true`\n\nShow the center indicator above the crop box.\n\n### highlight\n\n- Type: `Boolean`\n- Default: `true`\n\nShow the white modal above the crop box (highlight the crop box).\n\n### background\n\n- Type: `Boolean`\n- Default: `true`\n\nShow the grid background of the container.\n\n### autoCrop\n\n- Type: `Boolean`\n- Default: `true`\n\nEnable to crop the image automatically when initialize.\n\n### autoCropArea\n\n- Type: `Number`\n- Default: `0.8` (80% of the image)\n\nA number between 0 and 1. Define the automatic cropping area size (percentage).\n\n### movable\n\n- Type: `Boolean`\n- Default: `true`\n\nEnable to move the image.\n\n### rotatable\n\n- Type: `Boolean`\n- Default: `true`\n\nEnable to rotate the image.\n\n### scalable\n\n- Type: `Boolean`\n- Default: `true`\n\nEnable to scale the image.\n\n### zoomable\n\n- Type: `Boolean`\n- Default: `true`\n\nEnable to zoom the image.\n\n### zoomOnTouch\n\n- Type: `Boolean`\n- Default: `true`\n\nEnable to zoom the image by dragging touch.\n\n### zoomOnWheel\n\n- Type: `Boolean`\n- Default: `true`\n\nEnable to zoom the image by wheeling mouse.\n\n### wheelZoomRatio\n\n- Type: `Number`\n- Default: `0.1`\n\nDefine zoom ratio when zoom the image by wheeling mouse.\n\n### cropBoxMovable\n\n- Type: `Boolean`\n- Default: `true`\n\nEnable to move the crop box by dragging.\n\n### cropBoxResizable\n\n- Type: `Boolean`\n- Default: `true`\n\nEnable to resize the crop box by dragging.\n\n### toggleDragModeOnDblclick\n\n- Type: `Boolean`\n- Default: `true`\n\nEnable to toggle drag mode between \"crop\" and \"move\" when click twice on the cropper.\n\n### minContainerWidth\n\n- Type: `Number`\n- Default: `200`\n\nThe minimum width of the container.\n\n### minContainerHeight\n\n- Type: `Number`\n- Default: `100`\n\nThe minimum height of the container.\n\n### minCanvasWidth\n\n- Type: `Number`\n- Default: `0`\n\nThe minimum width of the canvas (image wrapper).\n\n### minCanvasHeight\n\n- Type: `Number`\n- Default: `0`\n\nThe minimum height of the canvas (image wrapper).\n\n### minCropBoxWidth\n\n- Type: `Number`\n- Default: `0`\n\nThe minimum width of the crop box.\n\n**Note:** This size is relative to the page, not the image.\n\n### minCropBoxHeight\n\n- Type: `Number`\n- Default: `0`\n\nThe minimum height of the crop box.\n\n**Note:** This size is relative to the page, not the image.\n\n### ready\n\n- Type: `Function`\n- Default: `null`\n\nA shortcut of the \"ready\" event.\n\n### cropstart\n\n- Type: `Function`\n- Default: `null`\n\nA shortcut of the \"cropstart\" event.\n\n### cropmove\n\n- Type: `Function`\n- Default: `null`\n\nA shortcut of the \"cropmove\" event.\n\n### cropend\n\n- Type: `Function`\n- Default: `null`\n\nA shortcut of the \"cropend\" event.\n\n### crop\n\n- Type: `Function`\n- Default: `null`\n\nA shortcut of the \"crop\" event.\n\n### zoom\n\n- Type: `Function`\n- Default: `null`\n\nA shortcut of the \"zoom\" event.\n\n[⬆ back to top](#table-of-contents)\n\n## Methods\n\nAs there is an **asynchronous** process when load the image, you **should call most of the methods after ready**, except \"setAspectRatio\", \"replace\" and \"destroy\".\n\n> If a method doesn't need to return any value, it will return the cropper instance (`this`) for chain composition.\n\n```js\nnew Cropper(image, {\n  ready: function () {\n    // this.cropper[method](argument1, , argument2, ..., argumentN);\n    this.cropper.move(1, -1);\n\n    // Allows chain composition\n    this.cropper.move(1, -1).rotate(45).scale(1, -1);\n  }\n});\n```\n\n### crop()\n\nShow the crop box manually.\n\n```js\nnew Cropper(image, {\n  autoCrop: false,\n  ready: function () {\n    // Do something here\n    // ...\n\n    // And then\n    this.cropper.crop();\n  }\n});\n```\n\n### reset()\n\nReset the image and crop box to their initial states.\n\n### clear()\n\nClear the crop box.\n\n### replace(url[, onlyColorChanged])\n\n- **url**:\n  - Type: `String`\n  - A new image url.\n\n- **onlyColorChanged** (optional):\n  - Type: `Boolean`\n  - If only change the color, not the size, then the cropper only need to change the srcs of all related images, not need to rebuild the cropper. This can be used for applying filters.\n  - If not present, its default value is `false`.\n\nReplace the image's src and rebuild the cropper.\n\n### enable()\n\nEnable (unfreeze) the cropper.\n\n### disable()\n\nDisable (freeze) the cropper.\n\n### destroy()\n\nDestroy the cropper and remove the instance from the image.\n\n### move(offsetX[, offsetY])\n\n- **offsetX**:\n  - Type: `Number`\n  - Moving size (px) in the horizontal direction.\n\n- **offsetY** (optional):\n  - Type: `Number`\n  - Moving size (px) in the vertical direction.\n  - If not present, its default value is `offsetX`.\n\nMove the canvas (image wrapper) with relative offsets.\n\n```js\ncropper.move(1);\ncropper.move(1, 0);\ncropper.move(0, -1);\n```\n\n### moveTo(x[, y])\n\n- **x**:\n  - Type: `Number`\n  - The `left` value of the canvas\n\n- **y** (optional):\n  - Type: `Number`\n  - The `top` value of the canvas\n  - If not present, its default value is `x`.\n\nMove the canvas (image wrapper) to an absolute point.\n\n### zoom(ratio)\n\n- **ratio**:\n  - Type: `Number`\n  - Zoom in: requires a positive number (ratio > 0)\n  - Zoom out: requires a negative number (ratio < 0)\n\nZoom the canvas (image wrapper) with a relative ratio.\n\n```js\ncropper.zoom(0.1);\ncropper.zoom(-0.1);\n```\n\n### zoomTo(ratio[, pivot])\n\n- **ratio**:\n  - Type: `Number`\n  - Requires a positive number (ratio > 0)\n\n- **pivot** (optional):\n  - Type: `Object`\n  - Schema: `{ x: Number, y: Number }`\n  - The coordinate of the center point for zooming, base on the top left corner of the cropper container.\n\nZoom the canvas (image wrapper) to an absolute ratio.\n\n```js\ncropper.zoomTo(1); // 1:1 (canvasData.width === canvasData.naturalWidth)\n\nconst containerData = cropper.getContainerData();\n\n// Zoom to 50% from the center of the container.\ncropper.zoomTo(.5, {\n  x: containerData.width / 2,\n  y: containerData.height / 2,\n});\n```\n\n### rotate(degree)\n\n- **degree**:\n  - Type: `Number`\n  - Rotate right: requires a positive number (degree > 0)\n  - Rotate left: requires a negative number (degree < 0)\n\nRotate the image with a relative degree.\n\n> Requires [CSS3 2D Transforms](https://developer.mozilla.org/en-US/docs/Web/CSS/transform) support ([IE 9+](http://caniuse.com/transforms2d)).\n\n```js\ncropper.rotate(90);\ncropper.rotate(-90);\n```\n\n### rotateTo(degree)\n\n- **degree**:\n  - Type: `Number`\n\nRotate the image to an absolute degree.\n\n### scale(scaleX[, scaleY])\n\n- **scaleX**:\n  - Type: `Number`\n  - Default: `1`\n  - The scaling factor to apply on the abscissa of the image.\n  - When equal to `1` it does nothing.\n\n- **scaleY** (optional):\n  - Type: `Number`\n  - The scaling factor to apply on the ordinate of the image.\n  - If not present, its default value is `scaleX`.\n\nScale the image.\n\n> Requires [CSS3 2D Transforms](https://developer.mozilla.org/en-US/docs/Web/CSS/transform) support ([IE 9+](http://caniuse.com/transforms2d)).\n\n```js\ncropper.scale(-1); // Flip both horizontal and vertical\ncropper.scale(-1, 1); // Flip horizontal\ncropper.scale(1, -1); // Flip vertical\n```\n\n### scaleX(scaleX)\n\n- **scaleX**:\n  - Type: `Number`\n  - Default: `1`\n  - The scaling factor to apply on the abscissa of the image.\n  - When equal to `1` it does nothing.\n\nScale the abscissa of the image.\n\n### scaleY(scaleY)\n\n- **scaleY**:\n  - Type: `Number`\n  - Default: `1`\n  - The scaling factor to apply on the ordinate of the image.\n  - When equal to `1` it does nothing.\n\nScale the ordinate of the image.\n\n### getData([rounded])\n\n- **rounded** (optional):\n  - Type: `Boolean`\n  - Default: `false`\n  - Set `true` to get rounded values.\n\n- (return value):\n  - Type: `Object`\n  - Properties:\n    - `x`: the offset left of the cropped area\n    - `y`: the offset top of the cropped area\n    - `width`: the width of the cropped area\n    - `height`: the height of the cropped area\n    - `rotate`: the rotated degrees of the image\n    - `scaleX`: the scaling factor to apply on the abscissa of the image\n    - `scaleY`: the scaling factor to apply on the ordinate of the image\n\nOutput the final cropped area position and size data (base on the natural size of the original image).\n\n> You can send the data to server-side to crop the image directly:\n> 1. Rotate the image with the `rotate` property.\n> 1. Scale the image with the `scaleX` and `scaleY` properties.\n> 1. Crop the image with the `x`, `y`, `width` and `height` properties.\n\n![A schematic diagram for data's properties](docs/images/data.jpg)\n\n### setData(data)\n\n- **data**:\n  - Type: `Object`\n  - Properties: See the [`getData`](#getdatarounded) method.\n  - You may need to round the data properties before passing them in.\n\nChange the cropped area position and size with new data (base on the original image).\n\n> **Note:** This method only available when the `viewMode` option great than or equal to `1`.\n\n### getContainerData()\n\n- (return  value):\n  - Type: `Object`\n  - Properties:\n    - `width`: the current width of the container\n    - `height`: the current height of the container\n\nOutput the container size data.\n\n![A schematic diagram for cropper's layers](docs/images/layers.jpg)\n\n### getImageData()\n\n- (return  value):\n  - Type: `Object`\n  - Properties:\n    - `left`: the offset left of the image\n    - `top`: the offset top of the image\n    - `width`: the width of the image\n    - `height`: the height of the image\n    - `naturalWidth`: the natural width of the image\n    - `naturalHeight`: the natural height of the image\n    - `aspectRatio`: the aspect ratio of the image\n    - `rotate`: the rotated degrees of the image if rotated\n    - `scaleX`: the scaling factor to apply on the abscissa of the image if scaled\n    - `scaleY`: the scaling factor to apply on the ordinate of the image if scaled\n\nOutput the image position, size and other related data.\n\n### getCanvasData()\n\n- (return  value):\n  - Type: `Object`\n  - Properties:\n    - `left`: the offset left of the canvas\n    - `top`: the offset top of the canvas\n    - `width`: the width of the canvas\n    - `height`: the height of the canvas\n    - `naturalWidth`: the natural width of the canvas (read only)\n    - `naturalHeight`: the natural height of the canvas (read only)\n\nOutput the canvas (image wrapper) position and size data.\n\n```js\nvar imageData = cropper.getImageData();\nvar canvasData = cropper.getCanvasData();\n\nif (imageData.rotate % 180 === 0) {\n  console.log(canvasData.naturalWidth === imageData.naturalWidth); // true\n}\n```\n\n### setCanvasData(data)\n\n- **data**:\n  - Type: `Object`\n  - Properties:\n    - `left`: the new offset left of the canvas\n    - `top`: the new offset top of the canvas\n    - `width`: the new width of the canvas\n    - `height`: the new height of the canvas\n\nChange the canvas (image wrapper) position and size with new data.\n\n### getCropBoxData()\n\n- (return  value):\n  - Type: `Object`\n  - Properties:\n    - `left`: the offset left of the crop box\n    - `top`: the offset top of the crop box\n    - `width`: the width of the crop box\n    - `height`: the height of the crop box\n\nOutput the crop box position and size data.\n\n### setCropBoxData(data)\n\n- **data**:\n  - Type: `Object`\n  - Properties:\n    - `left`: the new offset left of the crop box\n    - `top`: the new offset top of the crop box\n    - `width`: the new width of the crop box\n    - `height`: the new height of the crop box\n\nChange the crop box position and size with new data.\n\n### getCroppedCanvas([options])\n\n- **options** (optional):\n  - Type: `Object`\n  - Properties:\n    - `width`: the destination width of the output canvas.\n    - `height`: the destination height of the output canvas.\n    - `minWidth`: the minimum destination width of the output canvas, the default value is `0`.\n    - `minHeight`: the minimum destination height of the output canvas, the default value is `0`.\n    - `maxWidth`: the maximum destination width of the output canvas, the default value is `Infinity`.\n    - `maxHeight`: the maximum destination height of the output canvas, the default value is `Infinity`.\n    - `fillColor`: a color to fill any alpha values in the output canvas, the default value is `transparent`.\n    - [`imageSmoothingEnabled`](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/imageSmoothingEnabled): set to change if images are smoothed (`true`, default) or not (`false`).\n    - [`imageSmoothingQuality`](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/imageSmoothingQuality): set the quality of image smoothing, one of \"low\" (default), \"medium\", or \"high\".\n\n- (return  value):\n  - Type: `HTMLCanvasElement`\n  - A canvas drawn the cropped image.\n\n- Notes:\n  - The aspect ratio of the output canvas will be fitted to aspect ratio of the crop box automatically.\n  - If you intend to get a JPEG image from the output canvas, you should set the `fillColor` option first, if not, the transparent part in the JPEG image will become black by default.\n\n- Browser support:\n  - Basic image: requires [Canvas](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement) support ([IE 9+](http://caniuse.com/canvas)).\n  - Rotated image: requires [CSS3 2D Transforms](https://developer.mozilla.org/en-US/docs/Web/CSS/transform) support ([IE 9+](http://caniuse.com/transforms2d)).\n  - Cross-origin image: requires HTML5 [CORS settings attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes) support ([IE 11+](http://caniuse.com/cors)).\n\nGet a canvas drawn the cropped image. If it is not cropped, then returns a canvas drawn the whole image.\n\n> After then, you can display the canvas as an image directly, or use [HTMLCanvasElement.toDataURL](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL) to get a Data URL, or use [HTMLCanvasElement.toBlob](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob) to get a blob and upload it to server with [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData) if the browser supports these APIs.\n\nAvoid to get a blank output image, you might need to set the `maxWidth` and `maxHeight` properties to limited numbers, because of [the size limits of a canvas element](https://stackoverflow.com/questions/6081483/maximum-size-of-a-canvas-element).\n\n```js\ncropper.getCroppedCanvas();\n\ncropper.getCroppedCanvas({\n  width: 160,\n  height: 90,\n  minWidth: 256,\n  minHeight: 256,\n  maxWidth: 4096,\n  maxHeight: 4096,\n  fillColor: '#fff',\n  imageSmoothingEnabled: false,\n  imageSmoothingQuality: 'high',\n});\n\n// Upload cropped image to server if the browser supports `HTMLCanvasElement.toBlob`\ncropper.getCroppedCanvas().toBlob(function (blob) {\n  var formData = new FormData();\n\n  formData.append('croppedImage', blob);\n\n  // Use `jQuery.ajax` method\n  $.ajax('/path/to/upload', {\n    method: \"POST\",\n    data: formData,\n    processData: false,\n    contentType: false,\n    success: function () {\n      console.log('Upload success');\n    },\n    error: function () {\n      console.log('Upload error');\n    }\n  });\n});\n```\n\n### setAspectRatio(aspectRatio)\n\n- **aspectRatio**:\n  - Type: `Number`\n  - Requires a positive number.\n\nChange the aspect ratio of the crop box.\n\n### setDragMode([mode])\n\n- **mode** (optional):\n  - Type: `String`\n  - Default: `'none'`\n  - Options: `'none'`, `'crop'`, `'move'`\n\nChange the drag mode.\n\n**Tips:** You can toggle the \"crop\" and \"move\" mode by double click on the cropper.\n\n[⬆ back to top](#table-of-contents)\n\n## Events\n\n### ready\n\nThis event fires when the target image has been loaded and the cropper instance is ready for cropping.\n\n```js\nvar cropper;\n\nimage.addEventListener('ready', function () {\n  console.log(this.cropper === cropper);\n  // -> true\n});\n\ncropper = new Cropper(image);\n```\n\n### cropstart\n\n- **event.detail.originalEvent**:\n  - Type: `Event`\n  - Options: `mousedown`, `touchstart` and `pointerdown`\n\n- **event.detail.action**:\n  - Type: `String`\n  - Options:\n    - `'crop'`: create a new crop box\n    - `'move'`: move the canvas (image wrapper)\n    - `'zoom'`: zoom in / out the canvas (image wrapper) by touch.\n    - `'e'`: resize the east side of the crop box\n    - `'w'`: resize the west side of the crop box\n    - `'s'`: resize the south side of the crop box\n    - `'n'`: resize the north side of the crop box\n    - `'se'`: resize the southeast side of the crop box\n    - `'sw'`: resize the southwest side of the crop box\n    - `'ne'`: resize the northeast side of the crop box\n    - `'nw'`: resize the northwest side of the crop box\n    - `'all'`: move the crop box (all directions)\n\nThis event fires when the canvas (image wrapper) or the crop box starts to change.\n\n```js\nimage.addEventListener('cropstart', function (e) {\n  console.log(e.detail.originalEvent);\n  console.log(e.detail.action);\n});\n```\n\n### cropmove\n\n- **event.detail.originalEvent**:\n  - Type: `Event`\n  - Options: `mousemove`, `touchmove` and `pointermove`.\n\n- **event.detail.action**: the same as \"cropstart\".\n\nThis event fires when the canvas (image wrapper) or the crop box is changing.\n\n### cropend\n\n- **event.detail.originalEvent**:\n  - Type: `Event`\n  - Options: `mouseup`, `touchend`, `touchcancel`, `pointerup` and `pointercancel`.\n\n- **event.detail.action**: the same as \"cropstart\".\n\nThis event fires when the canvas (image wrapper) or the crop box stops to change.\n\n### crop\n\n- **event.detail.x**\n- **event.detail.y**\n- **event.detail.width**\n- **event.detail.height**\n- **event.detail.rotate**\n- **event.detail.scaleX**\n- **event.detail.scaleY**\n\n> About these properties, see the [`getData`](#getdatarounded) method.\n\nThis event fires when the canvas (image wrapper) or the crop box changed.\n\n### zoom\n\n- **event.detail.originalEvent**:\n  - Type: `Event`\n  - Options: `wheel`, `touchmove`.\n\n- **event.detail.oldRatio**:\n  - Type: `Number`\n  - The old (current) ratio of the canvas\n\n- **event.detail.ratio**:\n  - Type: `Number`\n  - The new (next) ratio of the canvas (`canvasData.width / canvasData.naturalWidth`)\n\nThis event fires when a cropper instance starts to zoom in or zoom out its canvas (image wrapper).\n\n```js\nimage.addEventListener('zoom', function (e) {\n\n  // Zoom in\n  if (e.detail.ratio > e.detail.oldRatio) {\n    e.preventDefault(); // Prevent zoom in\n  }\n\n  // Zoom out\n  // ...\n});\n```\n\n[⬆ back to top](#table-of-contents)\n\n## No conflict\n\nIf you have to use other cropper with the same namespace, just call the `Cropper.noConflict` static method to revert to it.\n\n```html\n<script src=\"other-cropper.js\"></script>\n<script src=\"cropper.js\"></script>\n<script>\n  Cropper.noConflict();\n  // Code that uses other `Cropper` can follow here.\n</script>\n```\n\n## Browser support\n\n- Chrome (latest)\n- Firefox (latest)\n- Safari (latest)\n- Opera (latest)\n- Edge (latest)\n- Internet Explorer 9+\n\n## Contributing\n\nPlease read through our [contributing guidelines](CONTRIBUTING.md).\n\n## Versioning\n\nMaintained under the [Semantic Versioning guidelines](http://semver.org/).\n\n## License\n\n[MIT](http://opensource.org/licenses/MIT) © [Chen Fengyuan](http://chenfengyuan.com)\n\n## Related projects\n\n- [angular-cropperjs](https://github.com/matheusdavidson/angular-cropperjs) by @matheusdavidson\n- [ember-cropperjs](https://github.com/danielthall/ember-cropperjs) by @danielthall\n- [iron-cropper](https://www.webcomponents.org/element/safetychanger/iron-cropper) (web component) by @safetychanger\n- [react-cropper](https://github.com/roadmanfong/react-cropper) by @roadmanfong\n- [vue-cropperjs](https://github.com/Agontuk/vue-cropperjs) by @Agontuk\n\n[⬆ back to top](#table-of-contents)\n","readmeFilename":"README.md"}