GithubHelp home page GithubHelp logo

inputimage's Introduction

inputImage

为Mobile端JS上传照片或拍照提供接口:

  • 自动创建input file并在使用后销毁
  • 用户可以选择使用拍照或相册里的照片,接口可选择返回File、Image、Base64格式图片
  • 解决手机拍照后在canvas中绘制会被旋转的问题(使用了EXIF信息插件)
  • 可自定义尺寸等比例缩放图片,用于缩略图或者压缩上传图片

Quick Start

<button id="upload">Upload Image</button>
<img id="original_image">
<img id="resize_image">
<img id="adjust_image">
<script src='exif.js'></script>
<script src='inputImage.js'></script>
<script>
upload.addEventListener('click', function () {
    inputImage.input({
        camera: true, // use camera
        multiple: false, // take only one photo
        format: 'image',
        success: function (files) {
            original_image.src = files[0].src;
            // 尺寸不变的图片,可以用来绘制
            inputImage.adjust({
                image: files[0],
                success: function (base64) {
                    adjust_image.src = base64;
                }
            });
            // 尺寸变小的图片,可以用来做缩略图或压缩图片
            inputImage.resize({
                image: files[0],
                max: 120,
                success: function (base64) {
                    resize_image.src = base64;
                }
            });
        }
    });
});
</script>

Examples


https://vmllab-js.github.io/inputImage

inputimage's People

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.