Vue-cropperjs is a Vue.js wrapper component for the popular Cropper.js library, enabling image cropping, rotating, and zooming functionalities within Vue 3 applications. The current stable version is 5.0.0, which targets Vue 3.x.x. Previous versions (e.g., 4.2.0) supported Vue 2.x.x, indicating a clear version split for different Vue major versions. The project appears to have an active maintenance cadence, aligning with major Vue releases and dependency updates. Key differentiators include its direct integration with Vue's reactivity system and component model, simplifying the use of Cropper.js without direct DOM manipulation. It primarily acts as a direct passthrough for most Cropper.js options and methods, offering a thin, idiomatic Vue layer over the core JavaScript library.
npm install vue-cropperjsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to integrate `vue-cropperjs` into a Vue 3 application, including importing the component and its CSS, displaying an image for cropping, and using a ref to access the underlying Cropper.js instance to perform actions like getting the cropped image and rotating it.
For Vue 3 projects, ensure `npm install vue-cropperjs@latest`. For Vue 2 projects, `npm install vue-cropperjs@4.2.0`.
Update calls from `this.$refs.cropper.zoom()` to `this.$refs.cropper.relativeZoom()` and `this.$refs.cropper.crop()` to `this.$refs.cropper.initCrop()`.
Add `import 'cropperjs/dist/cropper.css';` to your main entry file or the component where `VueCropper` is used.
Ensure you have `import VueCropper from 'vue-cropperjs';` and `components: { VueCropper }` in your component, or globally register it with `app.component('vue-cropper', VueCropper)` in Vue 3.Check that the component is mounted and `cropperRef.value` (or `this.$refs.cropper`) exists before calling methods. Also, verify method names against documentation, especially for renamed methods like `relativeZoom` (formerly `zoom`) and `initCrop` (formerly `crop`).