Gathering detailed insights and metrics for vue-croppie
Gathering detailed insights and metrics for vue-croppie
Gathering detailed insights and metrics for vue-croppie
Gathering detailed insights and metrics for vue-croppie
npm install vue-croppie
Typescript
Module System
Node Version
NPM Version
HTML (63.83%)
JavaScript (36.17%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
261 Stars
136 Commits
42 Forks
7 Watchers
8 Branches
9 Contributors
Updated on Apr 28, 2025
Latest Version
2.0.3
Package Id
vue-croppie@2.0.3
Unpacked Size
228.54 kB
Size
67.80 kB
File Count
16
NPM Version
9.8.0
Node Version
20.5.1
Published on
May 20, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
VueCroppie is a Vue 2 wrapper for Croppie a beautiful photo cropping tool for Javascript by foliotek.
If you like this project, please give it a star, and consider following the author. :)
1npm install vue-croppie --save
https://unpkg.com/vue-croppie/dist/vue-croppie.js
TO use VueCroppie with Webpack, Parcel or other bundler
1import Vue from 'vue'; 2import VueCroppie from 'vue-croppie'; 3import 'croppie/croppie.css' // import the croppie css manually 4 5Vue.use(VueCroppie);
1<script src="https://unpkg.com/vue-croppie/dist/vue-croppie.js"></script> 2<link rel="stylesheet" href="https://unpkg.com/croppie/croppie.css"> 3<body> 4 ... 5</body> 6<script> 7 const vm = new Vue({...}); 8</script>
This sample below will produce this.
1<template> 2 <div> 3 <!-- Note that 'ref' is important here (value can be anything). read the description about `ref` below. --> 4 <vue-croppie 5 ref="croppieRef" 6 :enableOrientation="true" 7 :boundary="{ width: 300, height: 300}" 8 @result="result" 9 @update="update"> 10 </vue-croppie> 11 12 <!-- the result --> 13 <img v-bind:src="cropped"> 14 15 <button @click="bind()">Bind</button> 16 <!-- Rotate angle is Number --> 17 <button @click="rotate(-90)">Rotate Left</button> 18 <button @click="rotate(90)">Rotate Right</button> 19 <button @click="crop()">Crop Via Callback</button> 20 <button @click="cropViaEvent()">Crop Via Event</button> 21 </div> 22</template> 23 24<script> 25export default { 26 mounted() { 27 // Upon mounting of the component, we accessed the .bind({...}) 28 // function to put an initial image on the canvas. 29 this.$refs.croppieRef.bind({ 30 url: 'http://i.imgur.com/Fq2DMeH.jpg', 31 }) 32 }, 33 data() { 34 return { 35 cropped: null, 36 images: [ 37 'http://i.imgur.com/fHNtPXX.jpg', 38 'http://i.imgur.com/ecMUngU.jpg', 39 'http://i.imgur.com/7oO6zrh.jpg', 40 'http://i.imgur.com/miVkBH2.jpg' 41 ] 42 } 43 }, 44 methods: { 45 bind() { 46 // Randomize cat photos, nothing special here. 47 let url = this.images[Math.floor(Math.random() * 4)] 48 49 // Just like what we did with .bind({...}) on 50 // the mounted() function above. 51 this.$refs.croppieRef.bind({ 52 url: url, 53 }); 54 }, 55 // CALBACK USAGE 56 crop() { 57 // Here we are getting the result via callback function 58 // and set the result to this.cropped which is being 59 // used to display the result above. 60 let options = { 61 format: 'jpeg', 62 circle: true 63 } 64 this.$refs.croppieRef.result(options, (output) => { 65 this.cropped = output; 66 }); 67 }, 68 // EVENT USAGE 69 cropViaEvent() { 70 this.$refs.croppieRef.result(options); 71 }, 72 result(output) { 73 this.cropped = output; 74 }, 75 update(val) { 76 console.log(val); 77 }, 78 rotate(rotationAngle) { 79 // Rotates the image 80 this.$refs.croppieRef.rotate(rotationAngle); 81 } 82 } 83} 84</script>
You can upload file instead of using direct image link.
Usage
In your form add a file input
along with vue-croppie
component.
1<template> 2 <input type="file" @change="croppie"/> 3 <vue-croppie ref="croppieRef" :enableOrientation="true" :boundary="{ width: 450, height: 300}" :viewport="{ width:400, height:250, 'type':'square' }"> 4 </vue-croppie> 5 <!-- the result --> 6 <img :src="cropped"> 7 <button @click="crop">Crop</button> 8</template> 9 10<script> 11export default { 12 data() { 13 return { 14 croppieImage: '', 15 cropped: null 16 }; 17 }, 18 methods: { 19 croppie (e) { 20 var files = e.target.files || e.dataTransfer.files; 21 if (!files.length) return; 22 23 var reader = new FileReader(); 24 reader.onload = e => { 25 this.$refs.croppieRef.bind({ 26 url: e.target.result 27 }); 28 }; 29 30 reader.readAsDataURL(files[0]); 31 }, 32 crop() { 33 // Options can be updated. 34 // Current option will return a base64 version of the uploaded image with a size of 600px X 450px. 35 let options = { 36 type: 'base64', 37 size: { width: 600, height: 450 }, 38 format: 'jpeg' 39 }; 40 this.$refs.croppieRef.result(options, output => { 41 this.cropped = this.croppieImage = output; 42 console.log(this.croppieImage); 43 }); 44 } 45 } 46};
All Croppie options were converted to props to be able use them in the vue-croppie
component.
Usage
1<vue-croppie 2 ref=croppieRef 3 :enableOrientation="true" 4 :mouseWheelZoom="false" 5 :viewport="{ width: 200, height: 200, type: 'circle' }" 6 @result="fn" 7> 8</vue-croppie>
All of the properties and methods are based on Croppie documentation. All property and method names are "==="
the same if you know what I mean.
Except for these few things below.
Option | Type | Default | Description |
---|---|---|---|
ref (required) | Object | none | ref is used to create a reference to the child component, in order to have access to it's methods and properties. Specific example is to access the result() function of vue-croppie from outside the component. |
resultType | String | base64 | The image encoding of the cropped image via result() . Also available in Croppie Documentation. |
customClass | String | none | You can pass a custom class or classes to the props customClass like customClass="class1 class2 class3" |
Option | Type | Usage | Description |
---|---|---|---|
update | function | @update="fn" | Gets triggered when the croppie element has been zoomed, dragged or cropped |
result | function | @result="fn" | Gets triggered when the image has been cropped. Returns the cropped image. |
croppieInitialized | function | @croppieInitialized="fn" | Gets triggered when the croppie gets initialized. |
Note:
@result
event is only available if NO callback function was passed to this.$refs.croppieRef.result({})
. See here
How to clear/destroy coppie?
I added a new method called refresh()
and can be used as this.$refs.croppieRef.refresh()
, but the croppie instance is now being refreshed automatically after every crop()
invocation.
Helpful links #358 - Official croppie page.
1.3.0 - Aug 16, 2017
1.2.5 - Aug 12, 2017
result
event.updated
event.1.2.3
croppie
instance after every crop()
invocation.refresh()
which destroys and re-create the croppie instance.1.2.x
this.$refs.croppieRef.result(options, callback)
.Use and abuse at your own risk.
</p>
with ❤️ by Jofferson Ramirez Tiquez
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
Found 1/17 approved changesets -- score normalized to 0
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
38 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More