Gathering detailed insights and metrics for vue-anka-cropper
Gathering detailed insights and metrics for vue-anka-cropper
Gathering detailed insights and metrics for vue-anka-cropper
Gathering detailed insights and metrics for vue-anka-cropper
npm install vue-anka-cropper
Typescript
Module System
Node Version
NPM Version
Vue (97.97%)
HTML (1.09%)
JavaScript (0.83%)
PHP (0.1%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
20 Stars
44 Commits
7 Forks
27 Branches
1 Contributors
Updated on Jun 25, 2024
Latest Version
1.1.0
Package Id
vue-anka-cropper@1.1.0
Unpacked Size
716.71 kB
Size
179.35 kB
File Count
10
NPM Version
6.12.1
Node Version
10.16.0
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
An easy image cropper and (optionally) uploader component for vue.js
1npm install vue-anka-cropper
and then in your app:
1import vueAnkaCropper from 'vue-anka-cropper' 2... 3components: {vueAnkaCropper} 4... 5<style> 6@import '../node_modules/vue-anka-cropper/dist/VueAnkaCropper.css'; 7...
1<link rel="stylesheet" href="https://unpkg.com/vue-anka-cropper@0.1.0/dist/VueAnkaCropper.css"> 2<script src="https://unpkg.com/vue/dist/vue.min.js"></script> 3<script src="https://unpkg.com/vue-anka-cropper/dist/VueAnkaCropper.umd.min.js"></script>
Most basic example. This is going to insert the cropper with default options:
1<template> 2 <div> 3 <h1>Vue Anka Cropper Example</h1> 4 <vue-anka-cropper></vue-anka-cropper> 5 </div> 6</template> 7<script> 8import vueAnkaCropper from 'vue-anka-cropper' 9export default { 10 name: 'cropperDemo', 11 components: {vueAnkaCropper} 12} 13</script>
Example with all the options and events:
1<template> 2 <div> 3 <h1>Vue Anka Cropper Example</h1> 4 <vue-anka-cropper 5 :options="{ 6 aspectRatio: 1, 7 closeOnSave: true, 8 cropArea: 'box', 9 croppedHeight: 400, 10 croppedWidth: 400, 11 cropperHeight: false, 12 dropareaMessage: 'Drop file here or use the button below.', 13 frameLineDash: [5,3], 14 frameStrokeColor: 'rgba(255, 255, 255, 0.8)', 15 handleFillColor: 'rgba(255, 255, 255, 0.2)', 16 handleHoverFillColor: 'rgba(255, 255, 255, 0.4)', 17 handleHoverStrokeColor: 'rgba(255, 255, 255, 1)', 18 handleSize: 10, 19 handleStrokeColor: 'rgba(255, 255, 255, 0.8)', 20 layoutBreakpoint: 850, 21 maxCropperHeight: 768, 22 maxFileSize: 8000000, 23 overlayFill: 'rgba(0, 0, 0, 0.5)', 24 previewOnDrag: true, 25 previewQuality: 0.65, 26 resultQuality: 0.8, 27 resultMimeType: 'image/jpeg', 28 selectButtonLabel: 'Select Files', 29 showPreview: true, 30 skin: 'light', 31 uploadData: {}, 32 uploadTo: false}" 33 @cropper-error="someAction(errorMessage)" 34 @cropper-file-selected="someAction(file)" 35 @cropper-preview="someAction(imageSource)" 36 @cropper-saved="someAction(cropData)" 37 @cropper-cancelled="someAction()" 38 @cropper-uploaded="someAction(serverResponse)"></vue-anka-cropper> 39 </div> 40</template> 41<script> 42import vueAnkaCropper from 'vue-anka-cropper' 43export default { 44 name: 'cropperDemo', 45 components: {vueAnkaCropper} 46} 47</script>
Option | Default Value | Allowed Values | Description |
---|---|---|---|
aspectRatio | 1 | false or number | if not false, it will lock the aspect ratio of cropped area. Aspect ratio everywhere in anka-cropper is width/ height |
closeOnSave | true | boolean | whether to close the cropper after saving the result (hide the image, clear the data), not allowing further cropping |
cropArea | 'box' | 'box' or 'circle' | Use 'circle' for round crop area (useful for avatars). If this is 'circle', aspectRatio will be locked to 1 |
croppedHeight | 400 | false or integer | Desired height of the cropped image, in pixels |
croppedWidth | 400 | false or integer | Desired width of the cropped image, in pixels |
cropperHeight | false | false or integer | Fixed height of the cropper if needed. It will probably be removed in future versions, because this can be done much easier with css |
dropareaMessage | 'Drop file here or use the button below' | string | Any message to appear in file drop area. |
frameLineDash | [5,3] | array of intergers | A pattern of line dashes and spaces lengths. Main cropping frame will use this. Follow this specs: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash. Use [] (empty array} for continuos line |
frameStrokeColor | 'rgba(255, 255, 255, 0.8)' | string | Color of the main cropping frame. |
handleFillColor | 'rgba(255, 255, 255, 0.2)' | string | Color of the fill of cropping handles. |
handleHoverFillColor | 'rgba(255, 255, 255, 0.4)' | string | Color of the fill of hovered cropping handles. |
handleHoverStrokeColor | 'rgba(255, 255, 255, 1)' | string | Color of the stroke of hovered cropping handles. |
handleSize | 10 | integer | Size of cropping handles, in pixels. Please note the size will be doubled, so 10 means they will be 20 x 20 pixels |
handleStrokeColor | 'rgba(255, 255, 255, 0.8)' | string | Color of the stroke of cropping handles. |
layoutBreakpoint | 850 | integer | If showPreview is true, this is the breakpoint at which the layout changes from vertical (preview at the bottom) to horizontal (preview on right) If showPreview is false this setting has no effect. This setting will probably be removed in future versions, because this should be handled with css. |
maxCropperHeight | 768 | integer | Maximum height of the cropping area, in pixels |
maxFileSize | 8000000 | false or integer | Maximum size of the file, in bytes. Set to false to allow files of any size |
overlayFill | 'rgba(0, 0, 0, 0.5)' | string | color of the overlay outside of cropped image. |
previewOnDrag | true | boolean | If true, the preview will be updated while user is dragging. It looks better, but may cause performance issues (especially with large files). If see such issues, change to false. |
previewQuality | 0.65 | float | Quality of the preview image, 0 - 1. |
resultQuality | 0.8 | float | Quality of the cropped image, 0 - 1 (if applicable, i.e. resultMimeType is a lossy type), lacking support in some browsers |
resultMimeType | 'image/jpeg' | string | Mime type of the cropped image, any value supported by HTMLCanvasElement.toBlob() (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob) |
selectButtonLabel | 'Select Files' | string | Upload button label |
showPreview | true | boolean | Whether to show the preview |
skin | 'light' | string | Currently 'light' or 'dark' are available, you can also use any other name to create your own skin. |
uploadData | {} | object | any additional data that should be uploaded with cropped image. |
uploadTo | false | false or string | Path where to upload the cropped file. Right now, only relative path, in the same domain will work (CORS issues) |
Event | Payload | Description |
---|---|---|
cropper-mounted | - | Fires when cropper is mounted |
cropper-error | string | Fires on any file reading error, returns an error message. |
cropper-file-selected | file | Emitted after user selected a file and it has been recognized as a valid image file. |
cropper-preview | dataURI | Fires when user stops dragging the cropping handle and returns image src as DataURI string. |
cropper-saved | object | Fires when user clicked save button, returns an object described below. |
cropper-cancelled | - | Fires when user cancels cropping. |
cropper-uploaded | object | Fires after cropped image has been uploaded, and returns the response from server. |
cropper-before-destroy | - | Fires before destroying cropper |
After cropping is done (user clicks on Save button) two things happen: cropper-saved event fires, and if uploadTo is not false, cropped image gets uploaded (firing cropper-uploaded event). Cropper-saved payload is an object, containing following fields:
Options allow adding fixed ratio as well as width and height of the image. This might lead to distorted image, in case if requested width and height don't match aspect ratio. In such case, width and height will be treated as maximum allowed width and maximum allowed height, resulting in image with the requested aspect ratio, and fitting inside the box of requested dimensions. In case only one size is provided (width or height) and the other one set to false, the missing one will be calculated using either aspectRatio (if not false) or the aspect ratio of cropped area.
Right now only two skins exist, light and dark. However, if you will use any other string as skin name, it will be added to the cropper outer element as a class. Then you can edit the css adding your skin rules.Please find the css of the dark skin below, use it as a skeleton for your skin (change "dark" to your skin name)
1.ankaCropper.dark { 2 background: #0f1114; 3 color: #eee 4} 5 6.ankaCropper.dark .ankaCropper__droparea { 7 border: 2px dashed #3e424b 8} 9 10.ankaCropper.dark .ankaCropper__saveButton, 11.ankaCropper.dark .ankaCropper__selectButton { 12 background: #334f90; 13 color: #fff 14} 15 16.ankaCropper.dark .ankaCropper__saveButton:hover, 17.ankaCropper.dark .ankaCropper__selectButton:hover { 18 background: #335dbe 19} 20 21.ankaCropper.dark .ankaCropper__navigation { 22 background: #1d2227 23} 24 25.ankaCropper.dark .ankaCropper__navButton { 26 background: #272c31 27} 28 29.ankaCropper.dark .ankaCropper__navButton svg { 30 stroke: #eee 31} 32 33.ankaCropper.dark .ankaCropper__navButton:hover { 34 background: #000 35} 36
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/24 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
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
124 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-14
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