vue-cropper vs vue-advanced-cropper vs vue-cropperjs
Image Cropping Solutions for Vue.js Applications
vue-croppervue-advanced-croppervue-cropperjsSimilar Packages:

Image Cropping Solutions for Vue.js Applications

vue-advanced-cropper, vue-cropper, and vue-cropperjs are Vue.js wrapper libraries that provide image cropping functionality in web applications. All three enable users to select, resize, and extract a portion of an image, but they differ significantly in architecture, feature depth, and integration approach. vue-advanced-cropper offers a highly customizable, component-based API built from the ground up for Vue. vue-cropper is a Vue wrapper around the native HTML5 canvas-based cropper logic. vue-cropperjs wraps the popular Cropper.js library, exposing its imperative API through a Vue component.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
vue-cropper28,1324,575457 kB1882 years agoISC
vue-advanced-cropper01,166380 kB372 years agoMIT
vue-cropperjs0968-375 years agoMIT

Image Cropping in Vue: vue-advanced-cropper vs vue-cropper vs vue-cropperjs

When building Vue applications that require image editing—like profile picture uploads, content management tools, or design apps—you’ll likely need a cropping solution. The three main Vue-focused options are vue-advanced-cropper, vue-cropper, and vue-cropperjs. While they all let users select a region of an image, their internal designs, APIs, and trade-offs vary widely. Let’s break them down.

🧱 Core Architecture: Native Vue vs Canvas vs Wrapper

vue-advanced-cropper is built entirely as a Vue component with no external dependencies. It uses SVG overlays and reactive props to manage the crop area, making it feel like a natural part of the Vue ecosystem.

<!-- vue-advanced-cropper: Declarative and reactive -->
<template>
  <AdvancedCropper 
    :src="imageSrc" 
    :stencil-props="{ aspectRatio: 1 }"
    @change="handleCropChange" 
  />
</template>

<script setup>
import { AdvancedCropper } from 'vue-advanced-cropper';

function handleCropChange({ coordinates }) {
  console.log('Crop area:', coordinates);
}
</script>

vue-cropper implements cropping logic directly using the HTML5 <canvas> element. It draws both the original image and the selection mask onto a single canvas, which gives you pixel-level control but limits flexibility for UI customization.

<!-- vue-cropper: Canvas-based -->
<template>
  <vue-cropper
    ref="cropperRef"
    :img="imageSrc"
    :auto-crop="true"
    @real-time="handleRealTime"
  />
</template>

<script setup>
import { VueCropper } from 'vue-cropper';

const cropperRef = ref(null);

function handleRealTime(data) {
  // data contains current crop box info
}

// To get the cropped image:
// cropperRef.value.getCropData()
</script>

vue-cropperjs is a thin Vue wrapper around the standalone Cropper.js library. It renders an <img> tag and lets Cropper.js manipulate it via JavaScript, meaning much of the logic lives outside Vue’s reactivity system.

<!-- vue-cropperjs: Imperative wrapper -->
<template>
  <vue-cropper
    ref="cropperRef"
    :src="imageSrc"
    :aspect-ratio="1"
    @ready="onReady"
  />
</template>

<script setup>
import VueCropper from 'vue-cropperjs';

const cropperRef = ref(null);

function onReady() {
  // Access Cropper.js instance directly
  const canvas = cropperRef.value.getCroppedCanvas();
}
</script>

⚙️ Feature Depth and Customization

Aspect Ratio & Stencils

  • vue-advanced-cropper supports dynamic stencils (crop area shapes) including rectangles, circles, and custom components. You can switch aspect ratios at runtime by updating a prop.
// Change aspect ratio reactively
const stencilProps = computed(() => ({
  aspectRatio: props.isSquare ? 1 : 16 / 9
}));
  • vue-cropper allows setting fixed aspect ratios via props like :fixed="true" and :fixed-number="[16, 9]", but changing them after mount requires calling instance methods.

  • vue-cropperjs inherits Cropper.js’s aspectRatio option, which can be updated via cropper.setAspectRatio(1) on the instance — not reactive.

Rotation and Zoom

  • vue-advanced-cropper does not support image rotation or zoom natively. These would need to be implemented separately.

  • vue-cropper includes basic rotation (rotateLeft, rotateRight methods) and zoom via mouse wheel or buttons, but relies on canvas transforms.

  • vue-cropperjs fully supports rotation (rotate(90)), zoom (zoom(0.1)), and scaling via Cropper.js’s mature API.

🔄 Data Flow and Output Handling

vue-advanced-cropper emits a change event with normalized coordinates (x, y, width, height) relative to the original image. You then use these values with a separate canvas utility (like canvas.getContext('2d').drawImage()) to generate the final image.

function handleCropChange({ coordinates }) {
  const { x, y, width, height } = coordinates;
  // Use these to draw on a hidden canvas
}

vue-cropper provides methods like getCropData() and getCropBlob() that return ready-to-use image data, handling the canvas drawing internally.

const cropData = cropperRef.value.getCropData(); // { x, y, w, h }
const blob = await cropperRef.value.getCropBlob(); // Promise<Blob>

vue-cropperjs exposes getCroppedCanvas() from Cropper.js, which returns an actual <canvas> element you can convert to Blob or data URL.

const canvas = cropperRef.value.getCroppedCanvas();
canvas.toBlob(blob => upload(blob));

🛠️ Maintenance and Long-Term Viability

As of the latest package metadata:

  • vue-advanced-cropper is actively maintained with recent releases supporting Vue 3 and TypeScript.
  • vue-cropper shows signs of abandonment: its GitHub repository has unresolved issues, and the last npm publish was years ago. Avoid for new projects.
  • vue-cropperjs is stable but depends on Cropper.js, which is in maintenance mode (no major new features). Still safe for production if you don’t need cutting-edge capabilities.

🆚 Summary: Key Differences

Featurevue-advanced-croppervue-croppervue-cropperjs
Core TechPure Vue + SVGHTML5 CanvasWrapper for Cropper.js
Reactivity✅ Fully reactive props/events❌ Mostly imperative❌ Instance-based
Rotation/Zoom❌ Not supported✅ Basic support✅ Full support
Custom UI✅ Highly customizable❌ Limited (canvas-only)⚠️ Possible via Cropper.js CSS
Maintenance Status✅ Active❌ Likely abandoned⚠️ Stable but legacy-bound
Vue 3 Support✅ Yes❌ Unclear / Unlikely✅ Via community forks

💡 When to Use Which

  • Need a modern, maintainable solution with clean Vue integration? → Go with vue-advanced-cropper. You’ll write less glue code and benefit from Vue’s reactivity.

  • Building a simple uploader and okay with canvas internals? → Only consider vue-cropper if you’ve verified it works with your Vue version — but prefer alternatives due to maintenance risks.

  • Require rotation, zoom, or are migrating from plain Cropper.js?vue-cropperjs gets you there fastest, but expect to manage the cropper instance manually.

In most new Vue 3 projects, vue-advanced-cropper strikes the best balance between capability, maintainability, and developer experience — unless you specifically need Cropper.js’s advanced image manipulation features.

How to Choose: vue-cropper vs vue-advanced-cropper vs vue-cropperjs

  • vue-cropper:

    Choose vue-cropper if you prefer a lightweight, canvas-based solution that doesn’t depend on third-party libraries like Cropper.js. It works well for basic to intermediate cropping needs where you want direct access to canvas operations and don’t require advanced features like rotation or zoom. However, note that its maintenance status appears inactive, making it risky for long-term projects.

  • vue-advanced-cropper:

    Choose vue-advanced-cropper if you need fine-grained control over the cropping UI and behavior using a declarative, Vue-native component model. It’s ideal for complex interfaces requiring custom handles, aspect ratio presets, or dynamic interaction logic without relying on external DOM manipulation. Its event-driven output integrates cleanly with modern Vue composition APIs.

  • vue-cropperjs:

    Choose vue-cropperjs if you’re already familiar with Cropper.js or need battle-tested features like image rotation, zoom, and cross-browser compatibility out of the box. It’s best suited for projects that prioritize rapid implementation of standard cropping workflows over deep Vue integration, since it exposes an imperative API that requires manual instance management.

README for vue-cropper

vue-cropper

一个优雅的图片裁剪插件

[ 查看演示 Demo ]
[ README_english ]
[ 更新日志 ]

一、安装使用

1. 安装

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

如果你没有使用 npm

在线例子vue-cropper + vue.2x

在线例子vue-cropper@next + vue.3x

服务器渲染 nuxt 解决方案 设置为 ssr: false

module.exports = {
  ...
  build: {
    vendor: [
      'vue-cropper
    ...
    plugins: [
      { src: '~/plugins/vue-cropper', ssr: false }
    ]
  }
}

2. 引入 Vue Cropper

Vue 3 组件内引入

npm install vue-cropper@next
import 'vue-cropper/dist/index.css'
import { VueCropper }  from "vue-cropper";

Vue3 全局引入

import VueCropper from 'vue-cropper'; 
import 'vue-cropper/dist/index.css'

const app = createApp(App)
app.use(VueCropper)
app.mount('#app')

Vue3 CDN 方式引入

<style type="text/css" src="https://cdn.jsdelivr.net/npm/vue-cropper@1.0.2/dist/index.css"></style> 
<script src="https://cdn.jsdelivr.net/npm/vue@3.2.1/dist/vue.global.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue-cropper@1.0.2/dist/vue-cropper.umd.js"></script>
const app = Vue.createApp({...});
app.component('vue-cropper', window['vue-cropper'].VueCropper);

Vue2 组件内引入

import { VueCropper }  from 'vue-cropper' 
components: {
  VueCropper
}

Vue2 全局引入

import VueCropper from 'vue-cropper'
Vue.use(VueCropper)

Vue2 CDN 方式引入

<script src="//cdn.jsdelivr.net/npm/vue-cropper@0.4.9/dist/index.js"></script>
Vue.use(window['vue-cropper'].default)

nuxt 引入方式

if(process.browser) {
  vueCropper = require('vue-cropper')
  Vue.use(vueCropper.default)
}

3. 代码中使用

重要! 需要关掉本地的 mock 服务, 不然图片转化会报错 重要! 需要使用外层容器包裹并设置宽高

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

二、文档

1. props

目前还不知道什么原因项目里面开启 mock 会导致 file 报错,建议使用时关掉 mock

名称功能默认值可选值
img裁剪图片的地址url 地址, base64, blob
outputSize裁剪生成图片的质量10.1 ~ 1
outputType裁剪生成图片的格式jpg (jpg 需要传入jpeg)jpeg, png, webp
info裁剪框的大小信息truetrue, false
canScale图片是否允许滚轮缩放truetrue, false
autoCrop是否默认生成截图框falsetrue, false
autoCropWidth默认生成截图框宽度容器的 80%0 ~ max
autoCropHeight默认生成截图框高度容器的 80%0 ~ max
fixed是否开启截图框宽高固定比例falsetrue, false
fixedNumber截图框的宽高比例, 开启fixed生效[1, 1][ 宽度 , 高度 ]
full是否输出原图比例的截图falsetrue, false
fixedBox固定截图框大小不允许改变false
canMove上传图片是否可以移动truetrue, false
canMoveBox截图框能否拖动truetrue, false
original上传图片按照原始比例渲染falsetrue, false
centerBox截图框是否被限制在图片里面falsetrue, false
high是否按照设备的dpr 输出等比例图片truetrue, false
infoTruetrue 为展示真实输出图片宽高 false 展示看到的截图框宽高falsetrue, false
maxImgSize限制图片最大宽度和高度20000 ~ max
enlarge图片根据截图框输出比例倍数10 ~ max(建议不要太大不然会卡死的呢)
mode图片默认渲染方式containcontain , cover, 100px, 100% auto
limitMinSize裁剪框限制最小区域10Number, Array, String
fillColor导出时背景颜色填充#ffffff, white

2. 可用回调方法

  • @realTime 实时预览事件
  • @imgMoving 图片移动回调函数
  • @cropMoving 截图框移动回调函数
  • @imgLoad 图片加载的回调, 返回结果 success, error

@realTime 实时预览事件

realTime(data) {
  var previews = data
  var h = 0.5
  var w = 0.2

  this.previewStyle1 = {
    width: previews.w + "px",
    height: previews.h + "px",
    overflow: "hidden",
    margin: "0",
    zoom: h
  }

  this.previewStyle2 = {
    width: previews.w + "px",
    height: previews.h + "px",
    overflow: "hidden",
    margin: "0",
    zoom: w
  }

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

  // 固定为 100 高度
  this.previewStyle4 = {
    width: previews.w + "px",
    height: previews.h + "px",
    overflow: "hidden",
    margin: "0",
    zoom: 100 / preview.h
  }
  this.previews = data
}
<div class="show-preview" :style="{'width': previews.w + 'px', 'height': previews.h + 'px',  'overflow': 'hidden',
    'margin': '5px'}">
  <div :style="previews.div">
    <img :src="https://raw.githubusercontent.com/xyxiao001/vue-cropper/HEAD/option.img" :style="previews.img">
  </div>
</div>
<p>中等大小</p>
<div :style="previewStyle1"> 
  <div :style="previews.div">
    <img :src="https://raw.githubusercontent.com/xyxiao001/vue-cropper/HEAD/previews.url" :style="previews.img">
  </div>
</div>

<p>迷你大小</p>
<div :style="previewStyle2"> 
  <div :style="previews.div">
    <img :src="https://raw.githubusercontent.com/xyxiao001/vue-cropper/HEAD/previews.url" :style="previews.img">
  </div>
</div>

@imgMoving 图片移动回调函数

返回的参数内容

{
   moving: true, // moving 是否在移动
   axis: {
     x1: 1, // 左上角
     x2: 1,// 右上角
     y1: 1,// 左下角
     y2: 1 // 右下角
   }
 }

@cropMoving 截图框移动回调函数

返回的参数内容

{
   moving: true, // moving 是否在移动
   axis: {
     x1: 1, // 左上角
     x2: 1,// 右上角
     y1: 1,// 左下角
     y2: 1 // 右下角
   }
 }

2. 内置方法 和 属性

通过 this.$refs.cropper 调用

属性

属性说明
this.$refs.cropper.cropW截图框宽度
this.$refs.cropper.cropH截图框高度

方法

方法说明
this.$refs.cropper.startCrop()开始截图
this.$refs.cropper.stopCrop()停止截图
this.$refs.cropper.clearCrop()清除截图
this.$refs.cropper.changeScale()修改图片大小 正数为变大 负数变小
this.$refs.cropper.getImgAxis()获取图片基于容器的坐标点
this.$refs.cropper.getCropAxis()获取截图框基于容器的坐标点
this.$refs.cropper.goAutoCrop自动生成截图框函数
this.$refs.cropper.rotateRight()向右边旋转90度
this.$refs.cropper.rotateLeft()向左边旋转90度

获取截图内容

获取截图的 base64 数据

this.$refs.cropper.getCropData(data => {
  // do something
  console.log(data)  
})

获取截图的 blob 数据

this.$refs.cropper.getCropBlob(data => {
  // do something
  console.log(data)  
})

三、相关文章参考

四、交流

有什么意见,或者 bug,或者想一起开发 vue-cropper, 或者想一起开发其他插件 image