Skip to content
프로젝트

소개

간단하고 직관적이며 사용자 지정이 가능한 모바일 친화적 Vue용 이미지 크롭퍼입니다.

웹 및 앱 개발

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

Vue Croppa logo

Vue Croppa

A simple, customizable, mobile-friendly image cropper for Vue.

Documentation · Live examples · Issues

Version status

v2 supports Vue 3. Vue 2 applications can stay on vue-croppa@1 (latest 1.x release: 1.3.8). See the Vue 3 guide, API, and migration guide.

Install for Vue 3

npm install vue-croppa@2
<script setup lang="ts">
import { ref } from 'vue'
import { Croppa } from 'vue-croppa'
import 'vue-croppa/style.css'

const cropper = ref<InstanceType<typeof Croppa> | null>(null)

async function save() {
  const blob = await cropper.value?.promisedBlob('image/png')
  // Upload or download the Blob.
}
</script>

<template>
  <Croppa ref="cropper" :width="320" :height="240" />
  <button @click="save">Save crop</button>
</template>

The live Vue 3 preview uses the real v2 component.

Vue 2 / v1 archive

Install v1 explicitly:

npm install vue-croppa@1
import Vue from 'vue'
import Croppa from 'vue-croppa'
import 'vue-croppa/dist/vue-croppa.css'

Vue.use(Croppa)

For script tags, pin v1 in CDN URLs: https://unpkg.com/vue-croppa@1/dist/vue-croppa.min.js and https://unpkg.com/vue-croppa@1/dist/vue-croppa.min.css. Unversioned unpkg.com/vue-croppa/dist/... URLs now resolve to v2 and return 404.

Basic v1 usage

<croppa
  v-model="croppa"
  :width="400"
  :height="300"
  prevent-white-space
></croppa>
export default {
  data() {
    return {
      croppa: null,
    }
  },

  methods: {
    async getCroppedImage() {
      return this.croppa.promisedBlob('image/jpeg', 0.9)
    },
  },
}

For the smallest possible setup:

<croppa v-model="croppa"></croppa>

The v1 model resolves to the Croppa component instance, which exposes movement, zoom, rotation, metadata, and output methods.

What v1 supports

  • Drag to reposition the image
  • Wheel and pinch zoom
  • Rotation and horizontal / vertical flip
  • File chooser and drag & drop
  • File type and file size validation
  • Local-file EXIF orientation handling
  • Initial images
  • Blob and data URL output
  • Canvas access and draw hooks
  • Save / restore transform metadata
  • Passive synchronized previews
  • Responsive auto-sizing
  • Rounded and custom clipped output

Live v1 demos

The documentation examples are part of this repository—there are no CodePen embeds in the new docs.

The demo suite includes:

Those pages execute the actual repository bundle and are exercised in Chromium by Playwright. The original docs/simple-test.html harness is also adapted to deterministic local assets and kept as an additional compatibility check.

v1 documentation

The full v1 reference is organized by task rather than duplicated into this README:

A note about v1 sizing

In v1, the visible cropper dimensions and output resolution are coupled:

output width  = width × quality
output height = height × quality

In v2, the visible canvas and export use the same pixels at quality scale. Use autoSizing to follow a responsive container.

Development

v1 component

npm install
npm run dev

The historical v1 docs/build files remain under docs/ because they contain the current built bundle and broad simple-test.html compatibility harness.

Modern docs

cd site
npm install
npm run dev

Run the first-party browser verification:

cd site
npm run test:e2e

The docs build copies the local Vue 2 + vue-croppa bundle, adapts docs/simple-test.html to local deterministic assets, builds VitePress, and runs the demo suite in Chromium.

v2

The Vue 3 / TypeScript package source is under v2/. Run npm run check there for typecheck, unit tests, and a library build.

License

ISC

관련 프로젝트 살펴보기

불러오는 중…