Library / SDK
xyxiao001/vue-cropper avatar
xyxiao001/vue-cropper

vue-cropper: the props table is the real documentation, and Vue 3 has moved on

A simple picture clipping plugin for vue

4,553 stars705 forksVueMIT

At a glance

What is it?
xyxiao001/vue-cropper is a picture clipping component for Vue with a wide prop surface, imperative methods on a ref, and callbacks for live preview. The README sends Vue 3 users to a separate repository, the root manifest still builds against Vue 2, and the published tags stop at 1.1.1 in November 2023.
Who is it for?
Use vue-cropper when you are on Vue 2 and want cropping without writing the geometry yourself, and read the props table before choosing defaults, since outputType, high, enlarge and maxImgSize change the exported file rather than the interface.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Activity is slowing. The repository last received commits 8 months ago.
What is it written in?
Mainly Vue, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 22, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • xyxiao001/vue-cropper4,553 ★ · -2
Star history
Repository2026-09-232026-11-22
xyxiao001/vue-cropper4.6k4.6k

-2 Stars in the last 60 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

Vue 3 users are sent to a different repository

The first thing the README does is redirect part of its audience. Vue 3 users are recommended to use the new repository cropper-next-vue, described as an independently published Vue 3 image cropping library that supports boundary judgement after rotation, keeps the image inside the crop box or the container, and handles high resolution screen export and live preview. Its documentation and examples live at cropper-next-vue.vercel.app, a different address from this project's own docs. Read that as a capability gap rather than a preference: rotation boundary handling, containment and dpr export are exactly the features people add vue-cropper for, and the successor lists them as its selling points. So a Vue 3 team starting a new feature is being told to pick a different package, while a Vue 2 team with an existing application is the audience this repository is written for. The last push here was on 2026-03-09 and the newest tag is 1.1.1 from 2023-11-08, with an older next tag from 2021-08-30.

The root manifest still builds against Vue 2

The manifest at the repository root is the place where the Vue 2 lineage shows up, and it disagrees with the tags:

json
{
  "name": "vue-cropper",
  "version": "0.6.5",
  "description": "A simple Vue picture clipping plugin",
  "main": "./dist/index.js",
  "license": "ISC",
  "scripts": {
    "build": "rm -rf ./dist && webpack --config webpack.config.js"
  },
  "devDependencies": {
    "vue": "^2.5.17",
    "vue-loader": "^15.4.2",
    "vue-template-compiler": "^2.5.17",
    "webpack": "^5.76.0",
    "webpack-cli": "^5.0.1",
    "css-loader": "^6.8.1",
    "style-loader": "^3.3.3",
    "sass": "^1.37.5"
  }
}

Three things to note. The declared version is 0.6.5 while the release tags include 1.1.1, so the file at the root is not a reliable version indicator. The license field says ISC even though the repository is filed as MIT, which is the kind of drift that matters if you vendor the code. And the Vue 2 toolchain with vue-template-compiler and vue-loader 15 tells you which major the source is written against, while the build is a single webpack run into dist/ that the package's main field points at.

Importing it takes six different routes

Installation is ordinary, with both package managers documented:

bash
# npm 安装
npm install vue-cropper
bash
# yarn 安装
yarn add vue-cropper

The import is where it branches. Vue 3 users install the next tag and import the component plus its stylesheet, then either register it locally with { VueCropper } or globally with app.use(VueCropper). The CDN route pins exact versions, [email protected] for the stylesheet and the UMD build alongside [email protected], and registers the component from the window object as window['vue-cropper'].VueCropper. Vue 2 has the same three shapes, with the CDN example pinned to [email protected] and the global form using Vue.use(VueCropper). Two integration notes are easy to miss: server rendering with nuxt requires ssr: false, either through build.vendor and a plugins entry marked ssr: false or through an if(process.browser) guard before Vue.use. Six routes for one component means the first hour with this package is spent on wiring, not on cropping.

The props table decides the exported file

The widest part of the API is the prop table, and four of its entries change what comes out rather than what you see. outputSize sets the quality of the generated image, defaulting to 1 with a range from 0.1 to 1, and outputType sets the format, defaulting to jpg with jpeg, png and webp as the options, and jpg requires jpeg to be passed in. high controls whether the image is output at the device pixel ratio, on by default. maxImgSize limits the maximum width and height, defaulting to 2000, and enlarge multiplies the output relative to the crop box, defaulting to 1 with a warning not to push it too far or the page will freeze. The rest of the table covers interaction and layout: canScale for wheel zoom, canMove and canMoveBox for dragging, autoCrop with autoCropWidth and autoCropHeight defaulting to 80 percent of the container, fixed with fixedNumber as a width and height pair defaulting to [1, 1], full for original ratio output, fixedBox for a crop box that cannot be resized, centerBox to keep it inside the image, mode with contain or cover among others, limitMinSize defaulting to 10, and fillColor for the exported background.

Two warnings are part of the contract

Before the usage snippet there are two bold notes, and both describe failures rather than preferences. The first says the local mock service has to be turned off, otherwise image conversion throws an error. The props section repeats it more bluntly: it is not yet known why enabling mock in the project makes file fail, and the advice is to disable mock when using it. So this is an unresolved defect that the project has worked around in documentation rather than in code, and any developer whose dev server has a mock layer enabled will hit a file error that looks like their own bug. The second note says the component needs an outer wrapper with a width and height set.

Output comes from ref methods, not from an event

Everything the component can do imperatively sits on the ref, which is why the usage snippet names one:

html
<vueCropper
  ref="cropper"
  :img="option.img"
  :outputSize="option.size"
  :outputType="option.outputType"
></vueCropper>

Two properties read the crop box size, this.$refs.cropper.cropW and cropH, and the methods cover the lifecycle: startCrop(), stopCrop() and clearCrop() for running and resetting the selection, changeScale() where a positive number enlarges and a negative one shrinks, getImgAxis() and getCropAxis() for the image and crop box coordinates relative to the container, goAutoCrop to generate a crop box automatically, and rotateRight() and rotateLeft() which turn the image by 90 degrees. The result arrives through two callbacks, getCropData for base64 and getCropBlob for a blob, each taking a callback that receives the data. Rotation is worth flagging: it is available on every image, while boundary judgement after rotation is listed as a feature of the successor repository rather than of this one.

Live preview is four styles and one truncated snippet

The preview story runs through four callbacks. @realTime is the live preview event, @imgMoving and @cropMoving report the image and the crop box moving with a moving flag and the four axis coordinates x1, x2, y1 and y2 for the corners, and @imgLoad reports image loading with a result of success or error. The @realTime example is where the documentation gets thin. It builds four preview styles from the same data, two fixed zoom values of 0.5 and 0.2 for medium and mini sizes, then two computed from the preview dimensions, one dividing 100 by the width and one dividing 100 by the height:

js
  // 固定为 100 宽度
  this.previewStyle3 = {
    width: previews.w + "px",
    height: previews.h + "px",
    overflow: "hidden",
    margin: "0",
    zoom: 100 / preview.w
  }

The fourth style is cut off mid line in the page, at the point where the height calculation begins. Combined with the fact that the newest tag is from November 2023, the practical reading is that this component is stable but no longer actively documented, and that the Vue 3 answer lives in the other repository.

Editorial conclusion

Use vue-cropper when you are on Vue 2 and want cropping without writing the geometry yourself, and read the props table before choosing defaults, since outputType, high, enlarge and maxImgSize change the exported file rather than the interface. Do not start a Vue 3 project on it, because the project points you to cropper-next-vue, and remember that the two documented warnings are part of the contract: disable the mock service and wrap the component in a container with a real size.

Frequently asked questions

Does vue-cropper work with Vue 3?

There is a Vue 3 path that installs the next tag and imports { VueCropper }, but the README recommends Vue 3 users move to the separately published cropper-next-vue repository instead. That project adds boundary judgement after rotation, keeps the image inside the crop box or container, and handles high resolution export and live preview.

How do I install vue-cropper?

With npm install vue-cropper or yarn add vue-cropper, then import the component and its stylesheet from vue-cropper/dist/index.css. Server rendering with nuxt needs ssr: false, either through a plugins entry or an if(process.browser) guard before Vue.use.

What props control the exported image in vue-cropper?

outputSize sets the quality from 0.1 to 1 and defaults to 1, outputType sets jpeg, png or webp and defaults to jpg, which requires jpeg to be passed in, high controls device pixel ratio output, maxImgSize limits the maximum width and height at 2000 by default, and enlarge multiplies the output relative to the crop box.

How do I get the cropped image out of vue-cropper?

Through the component ref: this.$refs.cropper.getCropData returns base64 data and this.$refs.cropper.getCropBlob returns a blob, each taking a callback. The same ref exposes startCrop(), stopCrop(), clearCrop(), changeScale(), getImgAxis(), getCropAxis(), goAutoCrop, rotateRight() and rotateLeft(), plus the cropW and cropH properties.

Why does vue-cropper fail to convert an image?

The documentation blames the local mock service: the mock has to be turned off or image conversion reports a file error, and the page notes it is not yet known why enabling mock causes that failure. A second requirement is that the component be wrapped in an outer container with a width and height set.

Official sources

  1. License: MIT
  2. Project website
  3. README
  4. Releases
  5. xyxiao001/vue-cropper on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/xyxiao001-vue-cropper.svg)](https://hysenlabs.com/projects/xyxiao001-vue-cropper)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/xyxiao001-vue-cropper.svg)](https://hysenlabs.com/projects/xyxiao001-vue-cropper)

Was this useful?