Coder Social home page Coder Social logo

html5imgcompress's People

Contributors

darmody avatar gitfree avatar mhbseal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

html5imgcompress's Issues

Run twice in done callback in Andriod.

下面done回调中的alert会执行2次

new html5ImgCompress(files[i], {
                                before: function(file) {
                                    if(file.type.indexOf('image') == -1){
                                        console.error("请选择图片进行上传");
                                        return false;
                                    }
                                    // 这里一般是对file进行filter,例如用file.type.indexOf('image') > -1来检验是否是图片
                                    // 如果为非图片,则return false放弃压缩(不执行后续done、fail、complete),并相应提示
                                },
                                done: function (base64, file) {

                                    alert(11)

                                    console.log('压缩成功...');
                                },
                                fail: function(file) {
                                    console.log('压缩失败...');
                                },
                                complete: function(file) {
                                    console.log('压缩完成...');
                                },
                                notSupport: function(file) {
                                    console.log('浏览器不支持!');
                                    // 不支持操作,例如PC在这里可以采用swfupload上传
                                }
                            });

commonJS引入报错

代码:

var html5ImgCompress = require('/dist/html5ImgCompress.min.js');

错误信息:

TypeError: Cannot set property 'html5ImgCompress' of undefined
    at index.js:506
    at Module.<anonymous> (index.js:507)
    at Module../assets/js/upload_img/html5ImgCompress.min.js (index.js:666)
    at __webpack_require__ (runtime.js:788)
    at fn (runtime.js:151)

建议搞一个npm安装包来引入,这样方便一些。

png支持问题

请问大大,现在是否是支持 png 图片压缩呢?

和vue一起使用报错

fileChange(el){`
      let that = this
      for(let i = 0; i < el.target.files.length;i++){
        // that.gallery.push(el.target.files[i])
        new html5ImgCompress(el.target.files[i], {
          before: function(file) {
            console.log('压缩前...');
            // console.log(typeof that.gallery)
            // 这里一般是对file进行filter,例如用file.type.indexOf('image') > -1来检验是否是图片
            // 如果为非图片,则return false放弃压缩(不执行后续done、fail、complete),并相应提示
          },
          done: function(file, base64) {
            console.log('压缩成功...');
            console.log(typeof that.gallery);
            // ajax和服务器通信上传base64图片等操作
            that.gallery.push(file)
          },
          fail: function(file) {
            console.log('压缩失败...');
          },
          complete: function(file) {
            console.log('压缩完成...');
          },
          notSupport: function(file) {
            console.log('浏览器不支持!')
            // 不支持操作,例如PC在这里可以采用swfupload上传
          }
        },false)
      }
    }

和vue一起使用,在chrome浏览器环境下。
这是我的监听input的代码,无法进入到done中,也不会跳转到notSupport,只是执行before之后就报错:
Uncaught SyntaxError: Unexpected token <

建议发个npm包

非常有用的工具,期待能以npm包的形式供大家引用。

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.