Coder Social home page Coder Social logo

stq666 / vue-cropper Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xyxiao001/vue-cropper

0.0 2.0 0.0 179 KB

A simple picture clipping plugin for vue

Home Page: https://xyxiao001.github.io/vue-cropper/example/

License: MIT License

CSS 2.90% HTML 1.53% Vue 91.99% JavaScript 3.58%

vue-cropper's Introduction

vue-crpopper

preview
δΈ­ζ–‡

vue-cropper

install

npm install vue-cropper

use

import VueCropper from vue-cropper
<vueCropper
  ref="cropper"
  :img="option.img"
  :outputSize="option.size"
  :outputType="option.outputType"
></vueCropper>
name toDo default optional
img img url null url || base64 || blob
outputSize crop produces quality of pictures 1 0.1 - 1
outputType crop img output type jpg (jpg need jpeg) jpeg || png || webp
info crop box size show true true || false
canScale the scroll to scale true true || false
autoCrop auto create crop box false true || false
autoCropWidth auto crop box width box size 80% 0~max
autoCropHeight auto create crop box height box size 80% 0~max
fixed open crop box width height ratio true true | false
fixedNumber crop box width height ratio [1 : 1] [w : h]

function adopt this.$refs.cropper to use

start cropper
this.$refs.cropper.startCrop()
stop cropper
this.$refs.cropper.stopCrop()
clear cropper
this.$refs.cropper.clearCrop()
get output img base64
this.$refs.cropper.getCropData((data) => {
  // do something
  console.log(data)  
})

get output img blob

this.$refs.cropper.getCropBlob((data) => {
  // do something
  console.log(data)  
})

update log

v0.13 add Real time preview

@realTime="realTime"
// Real time preview function
realTime (data) {
  this.previews = data
}
<div class="show-preview" :style="{'width': previews.w + 'px', 'height': previews.h + 'px',  'overflow': 'hidden',
    'margin': '5px'}">
  <div :style="previews.div">
    <img :src="option.img" :style="previews.img">
  </div>
</div>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.