--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 two20
4 |
5 | Copyright (c) 2017 islas27
6 |
7 | Copyright (c) 2018 fpluquet
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in all
17 | copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | SOFTWARE.
26 |
--------------------------------------------------------------------------------
/config/index.js:
--------------------------------------------------------------------------------
1 | // see http://vuejs-templates.github.io/webpack for documentation.
2 | var path = require('path')
3 |
4 | module.exports = {
5 | build: {
6 | env: require('./prod.env'),
7 | index: path.resolve(__dirname, '../dist/index.html'),
8 | assetsRoot: path.resolve(__dirname, '../dist'),
9 | assetsSubDirectory: 'static',
10 | assetsPublicPath: '',
11 | productionSourceMap: true,
12 | // Gzip off by default as many popular static hosts such as
13 | // Surge or Netlify already gzip all static assets for you.
14 | // Before setting to `true`, make sure to:
15 | // npm install --save-dev compression-webpack-plugin
16 | productionGzip: false,
17 | productionGzipExtensions: ['js', 'css'],
18 | // Run the build command with an extra argument to
19 | // View the bundle analyzer report after build finishes:
20 | // `npm run build --report`
21 | // Set to `true` or `false` to always turn it on or off
22 | bundleAnalyzerReport: process.env.npm_config_report
23 | },
24 | dev: {
25 | env: require('./dev.env'),
26 | port: 8080,
27 | autoOpenBrowser: true,
28 | assetsSubDirectory: 'static',
29 | assetsPublicPath: '/',
30 | proxyTable: {},
31 | // CSS Sourcemaps off by default because relative paths are "buggy"
32 | // with this option, according to the CSS-Loader README
33 | // (https://github.com/webpack/css-loader#sourcemaps)
34 | // In our experience, they generally work as expected,
35 | // just be aware of this issue when enabling this option.
36 | cssSourceMap: false
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
43 |
44 |
45 |
111 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # vue-avatar-editor
2 |
3 | Facebook like, avatar / profile picture component. This is Vue.js clone of mosch/react-avatar-editor
4 |
5 | Resize, rotate and crop your uploaded image using a clear user interface.
6 |
7 | Demo at https://fpluquet.github.io/vue-avatar-editor/
8 |
9 | # Installation
10 |
11 | This is a [Node.js](https://nodejs.org/en/) module available through the
12 | [npm registry](https://www.npmjs.com/).
13 |
14 | Before installing, [download and install Node.js](https://nodejs.org/en/download/).
15 | Node.js 0.10 or higher is required.
16 |
17 | Installation is done using the
18 | [`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
19 |
20 | ```bash
21 | $ npm install vue-avatar-editor-improved
22 | ```
23 |
24 | # Usage
25 |
26 | ```html
27 |
28 |
36 |
37 |
38 |
45 |
52 |
53 |
54 |
55 |
56 |
57 | ```
58 |
59 | ```javascript
60 | import Vue from 'vue'
61 | import {VueAvatar} from 'vue-avatar-editor-improved'
62 |
63 | let vm = new Vue({
64 | el: '#app',
65 | components: {
66 | VueAvatar,
67 | VueAvatarScale
68 | },
69 | data () {
70 | return {
71 | rotation: 0,
72 | scale: 1
73 | };
74 | },
75 | methods: {
76 | saveClicked () {
77 | var img = this.$refs.vueavatar.getImageScaled()
78 | this.$refs.image.src = img.toDataURL()
79 | },
80 | onImageReady () {
81 | this.scale = 1
82 | this.rotation = 0
83 | }
84 | }
85 | })
86 | ```
87 |
88 | ## Props
89 | | Prop | Type | Description
90 | | ---------------------- | -------- | ---------------
91 | | width | Number | The total width of the editor
92 | | height | Number | The total width of the editor
93 | | border | Number | The cropping border. Image will be visible through the border, but cut off in the resulting image.
94 | | color | Number[] | The color of the cropping border, in the form: [red (0-255), green (0-255), blue (0-255), alpha (0.0-1.0)]
95 | | style | Object | Styles for the canvas element
96 | | scale | Number | The scale of the image. You can use this to add your own resizing slider.
97 | | rotation | Number | The rotation in degrees of the image. You can use this to add your own rotating slider.
98 | | accept | String | Types of accepted files (accept props in file input). Default `image/*`. Exemplary other value `image/png, image/jpeg`.
99 | | placeholderSvg | String | Content of svg file for placeholder image
100 |
101 | ## Accessing the resulting image
102 |
103 | ```javascript
104 | this.$refs.vueavatar.getImage()
105 | ```
106 |
107 |
108 | The resulting image will have the same resolution as the original image, regardless of the editor's size.
109 | If you want the image sized in the dimensions of the canvas you can use `getImageScaled`.
110 |
111 |
112 | ```javascript
113 | this.$refs.vueavatar.getImageScaled()
114 | ```
115 |
116 |
117 | # Contributing
118 |
119 | For development you can use following build tools:
120 |
121 | * `npm run build`: Builds the *minified* dist file: `dist/index.js`
122 | * `npm run dev`: Watches for file changes and builds *unminified* into: `dist/index.js`
123 | localhost:8080)
124 |
--------------------------------------------------------------------------------
/src/components/VueAvatar.vue:
--------------------------------------------------------------------------------
1 |
2 |