1.0.5 • Published 6 years ago

canvascondense v1.0.5

Weekly downloads
3
License
ISC
Repository
github
Last release
6 years ago

canvascondense

Compress image to DataUrl with canvas for upload

Installation

TypeScript

# Install NPM module.
npm install --save canvascondense

Usage

Demo in VUE


<template>
    <div>
        <input type="file" name="picture" onchange="compress(event)"/>
    </div>
</template>
<script>
    import cvscds from 'canvascondense';
    export default{
        methods:{
            compress(){
                new cvscds(event.target, {
                    maxpix: 1000,
                    qulity: 0.8
                }).compress().then((DataUrl) => {
                    //You can post the DataUrl data to server api and save as image right here
                }).catch((err) => {
                    //err
                });
            }
        }
    }
</script>

#Demo in Browser

#Html
<input type="file" name="picture" onchange="compress(event)"/>

#Javascript
<script src="./js/canvascondense.min.js"></script>
<script type="text/javascript">
    var changecallback = function (event) {
        new canvascondense(event.target, {
            maxpix: 1000,
            qulity: 0.8
        }).compress().then((DataUrl) => {
            //You can post the DataUrl data to server api and save as image right here
        }).catch((err) => {
            //err
        });
    }
</script>
1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago