All Projects β†’ jofftiquez β†’ Vue Croppie

jofftiquez / Vue Croppie

Licence: mit
Vue wrapper for croppie

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Vue Croppie

Nextcloud Vue
🍱 Vue.js components for Nextcloud app development ✌
Stars: ✭ 89 (-60.96%)
Mutual labels:  hacktoberfest, vuejs2
Krop
Small widget for image cropping in Instagram-like style
Stars: ✭ 107 (-53.07%)
Mutual labels:  crop, crop-image
Bimg
Go package for fast high-level image processing powered by libvips C library
Stars: ✭ 1,394 (+511.4%)
Mutual labels:  crop, crop-image
Vee Validate
βœ… Form Validation for Vue.js
Stars: ✭ 8,820 (+3768.42%)
Mutual labels:  hacktoberfest, vuejs2
Vue Materialize Datatable
A fancy Materialize CSS datatable VueJS component.
Stars: ✭ 162 (-28.95%)
Mutual labels:  hacktoberfest, vuejs2
Svelte Easy Crop
A Svelte component to crop images with easy interactions
Stars: ✭ 80 (-64.91%)
Mutual labels:  crop, crop-image
React Cropper
Cropperjs as React component
Stars: ✭ 1,600 (+601.75%)
Mutual labels:  crop, crop-image
Croppy
Image Cropping Library for Android
Stars: ✭ 906 (+297.37%)
Mutual labels:  crop, crop-image
Vue Pure Lightbox
Very simple lightbox plugin (without any dependencies) for Vuejs πŸŒ…
Stars: ✭ 142 (-37.72%)
Mutual labels:  hacktoberfest, vuejs2
Storefront Ui
Customization-first, performance-oriented and elegant UI framework for eCommerce (and not only) based on Vue.js and Google Retail UX Playbook. Made with πŸ’š by Vue Storefront team and contributors.
Stars: ✭ 1,827 (+701.32%)
Mutual labels:  hacktoberfest, vuejs2
React Easy Crop
A React component to crop images/videos with easy interactions
Stars: ✭ 1,093 (+379.39%)
Mutual labels:  crop, crop-image
Cropiwa
πŸ“ Configurable Custom Crop widget for Android
Stars: ✭ 2,185 (+858.33%)
Mutual labels:  crop, crop-image
Vue Social Sharing
A renderless Vue.js component for sharing links to social networks, compatible with SSR
Stars: ✭ 1,071 (+369.74%)
Mutual labels:  hacktoberfest, vuejs2
Svg Autocrop
πŸš—πŸŒ½πŸ”³An NPM module to autocrop and slim down SVGs
Stars: ✭ 80 (-64.91%)
Mutual labels:  crop, crop-image
Smartcircle
βœ‚οΈAutomatically determine where to crop a circular image out of a rectangular.
Stars: ✭ 29 (-87.28%)
Mutual labels:  crop, crop-image
Lichter.io
My own website and CV
Stars: ✭ 105 (-53.95%)
Mutual labels:  hacktoberfest, vuejs2
Vuelayers
Web map Vue components with the power of OpenLayers
Stars: ✭ 532 (+133.33%)
Mutual labels:  hacktoberfest, vuejs2
Flyimg
Dockerized PHP7 application runs as a Microservice to resize and crop images on the fly. Get optimised images with MozJPEG, WebP or PNG using ImageMagick. Includes face detection, cropping, face blurring, image rotation and many other options. Abstract storage based on FlySystem in order to store images on any provider (local, AWS S3...).
Stars: ✭ 762 (+234.21%)
Mutual labels:  crop, crop-image
Vue Gmaps
Search places and address using Google Maps API
Stars: ✭ 108 (-52.63%)
Mutual labels:  hacktoberfest, vuejs2
Vue Morphling
Vue filters and directives collection.
Stars: ✭ 179 (-21.49%)
Mutual labels:  hacktoberfest, vuejs2

Black Lives Matter

#BlackLivesMatter!

https://blacklivesmatter.com/

Black Lives Matter Movement Resources


VueCroppie

Join the chat at https://gitter.im/vue-croppie/Lobby Buy Me A Coffee donate button NPM

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. :)

Installation

NPM

npm install vue-croppie --save

CDN

https://unpkg.com/vue-croppie/dist/vue-croppie.js

Usage with a bundler

TO use VueCroppie with Webpack, Parcel or other bundler

import Vue from 'vue';
import VueCroppie from 'vue-croppie';
import 'croppie/croppie.css' // import the croppie css manually

Vue.use(VueCroppie);

Usage in Browser directly

<script src="https://unpkg.com/vue-croppie/dist/vue-croppie.js"></script>
<link rel="stylesheet" href="https://unpkg.com/croppie/croppie.css">
<body>
  ...
</body>
<script>
  const vm = new Vue({...});
</script>

Sample

This sample below will produce this.

<template>
    <div>
        <!-- Note that 'ref' is important here (value can be anything). read the description about `ref` below. -->
        <vue-croppie 
            ref="croppieRef" 
            :enableOrientation="true"
            :boundary="{ width: 300, height: 300}"
            @result="result"
            @update="update">
        </vue-croppie>

        <!-- the result -->
        <img v-bind:src="cropped">

        <button @click="bind()">Bind</button>
        <!-- Rotate angle is Number -->
        <button @click="rotate(-90)">Rotate Left</button>
        <button @click="rotate(90)">Rotate Right</button>
        <button @click="crop()">Crop Via Callback</button>
        <button @click="cropViaEvent()">Crop Via Event</button>
    </div>
</template>

<script>
export default {
    mounted() {
        // Upon mounting of the component, we accessed the .bind({...})
        // function to put an initial image on the canvas.
        this.$refs.croppieRef.bind({
            url: 'http://i.imgur.com/Fq2DMeH.jpg',
        })
    },
    data() {
        return {
            cropped: null,
            images: [
                'http://i.imgur.com/fHNtPXX.jpg',
                'http://i.imgur.com/ecMUngU.jpg',
                'http://i.imgur.com/7oO6zrh.jpg',
                'http://i.imgur.com/miVkBH2.jpg'
            ]
        }
    },
    methods: {
        bind() {
            // Randomize cat photos, nothing special here.
            let url = this.images[Math.floor(Math.random() * 4)]

            // Just like what we did with .bind({...}) on 
            // the mounted() function above.
            this.$refs.croppieRef.bind({
                url: url,
            });
        },
        // CALBACK USAGE
        crop() {
            // Here we are getting the result via callback function
            // and set the result to this.cropped which is being 
            // used to display the result above.
            let options = {
                format: 'jpeg', 
                circle: true
            }
            this.$refs.croppieRef.result(options, (output) => {
                this.cropped = output;
            });
        },
        // EVENT USAGE
        cropViaEvent() {
            this.$refs.croppieRef.result(options);
        },
        result(output) {
            this.cropped = output;
        },
        update(val) {
            console.log(val);
        },
        rotate(rotationAngle) {
            // Rotates the image
            this.$refs.croppieRef.rotate(rotationAngle);
        }
    }
}
</script>

File Upload Sample

You can upload file instead of using direct image link. Usage In your form add a file input along with vue-croppie component.

<template>
  <input type="file" @change="croppie"/>
  <vue-croppie ref="croppieRef" :enableOrientation="true" :boundary="{ width: 450, height: 300}" :viewport="{ width:400, height:250, 'type':'square' }">
  </vue-croppie>
  <!-- the result -->
  <img :src="cropped">
  <button @click="crop">Crop</button>
</template>

<script>
export default {
  data() {
    return {
      croppieImage: '',
      cropped: null
    };
  },
  methods: {
    croppie (e) {
      var files = e.target.files || e.dataTransfer.files;
      if (!files.length) return;

      var reader = new FileReader();
      reader.onload = e => {
        this.$refs.croppieRef.bind({
          url: e.target.result
        });
      };

    reader.readAsDataURL(files[0]);
    },
    crop() {
      // Options can be updated.
      // Current option will return a base64 version of the uploaded image with a size of 600px X 450px.
      let options = {
        type: 'base64',
        size: { width: 600, height: 450 },
        format: 'jpeg'
      };
      this.$refs.croppieRef.result(options, output => {
        this.cropped = this.croppieImage = output;
          console.log(this.croppieImage);
        });
      }
  }
};

Using Options

All Croppie options were converted to props to be able use them in the vue-croppie component.

Usage

<vue-croppie
    ref=croppieRef
    :enableOrientation="true"
    :mouseWheelZoom="false"
    :viewport="{ width: 200, height: 200, type: 'circle' }"
    @result="fn"
>
</vue-croppie>

API

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"

Events

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

FAQ

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.

Updates

1.3.0 - Aug 16, 2017

  • Added webpack build
  • Fixes #5
  • Fixes #14

1.2.5 - Aug 12, 2017

  • Cropped image output can now be retrieve via vue event.
  • Added result event.
  • Added updated event.

1.2.3

  • Added automatic refreshing of croppie instance after every crop() invocation.
  • New method refresh() which destroys and re-create the croppie instance.

1.2.x

  • Result options are now being passed through the this.$refs.croppieRef.result(options, callback).

License

MIT

Use and abuse at your own risk.

</p> with ❀️ by Jofferson Ramirez Tiquez

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].