Coder Social home page Coder Social logo

dingdapeng / localresizeimg3 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hho2002/localresizeimg3

0.0 2.0 0.0 1.53 MB

前端本地客户端压缩图片,兼容IOS,Android,PC。

Home Page: http://lrz3.herokuapp.com

JavaScript 97.65% HTML 2.35%

localresizeimg3's Introduction

本库不再维护,已更新更适合的版本。lrz4

介绍一下

  • 基于原生js
  • 提供pc & mobile版本,修复之前各位提到的BUG和疑问。
  • 仔细思考后,再一次重构了代码,移除了UI,仅作为纯粹的工具,方便二次开发。

希望这一版本能够真正帮到大家。 :)

演示

在线演示

基本例子

请先根据情况引入 lrz.mobile.min.jslrz.pc.min.js

var input = document.querySelector('input');

input.onchange = function () {
    // 也可以传入图片路径:lrz('../demo.jpg', ...
    lrz(this.files[0], {
        width:1000,
        height:1000,
        // 压缩开始
        before: function() {
            console.log('压缩开始');
        },
        // 压缩失败
        fail: function(err) {
            console.error(err);
        },
        // 压缩结束(不论成功失败)
        always: function() {
            console.log('压缩结束');
        },
        // 压缩成功
        done: function (results) {
              // 你需要的数据都在这里,可以以字符串的形式传送base64给服务端转存为图片。
              console.log(results);
        }
    });
}

详细API,点我

兼容性

  • IE9 及 以上
  • chrome 什么的都支持。
  • 移动设备几乎都支持,若有问题,请先在 在线演示 测试一下(移动设备请扫描二维码)。

移动设备请扫描

lrz的历史

  • lrz1,基于jquery。
  • lrz2,基于原生js,却是用coffeescript写的 Orz, 有UI,存在已知BUG。

常见问题

有疑问请直接在 issues 中提问👊,说明设备、型号及平台

  • Q:有时拍摄完照片后,页面自动刷新或闪退了。

  • A:内存爆掉了,常见于低配android手机,可以每次上传完毕后设置 results.base64 = null; 来释放内存,改善情况。

  • Q: 直接传入图片路径的无法生成图片

  • A: 可能有跨域的问题,具体请看CORS_enabled_image

  • Q: 想要商用可以吗?

  • A: 没问题,但请留意issue里已知的问题。


时间: 2015年02月
演示: 在线演示
下载: 点此进入

localresizeimg3's People

Contributors

think2011 avatar dwandw avatar wxt2005 avatar yourlin avatar

Watchers

James Cloos avatar 大鹏 avatar

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.