{"id":13717213,"url":"https://github.com/think2011/localResizeIMG","last_synced_at":"2025-05-07T07:30:29.575Z","repository":{"id":36125529,"uuid":"40428586","full_name":"think2011/localResizeIMG","owner":"think2011","description":"🔥 前端本地客户端压缩图片，兼容IOS，Android，PC、自动按需加载文件 ","archived":true,"fork":false,"pushed_at":"2021-04-16T08:09:58.000Z","size":2861,"stargazers_count":3233,"open_issues_count":79,"forks_count":980,"subscribers_count":172,"default_branch":"master","last_synced_at":"2025-04-12T13:05:54.374Z","etag":null,"topics":["canvas","compress-images","compressimage","frontend","image","localresizeimg","lrz","mobile"],"latest_commit_sha":null,"homepage":"http://think2011.github.io/localResizeIMG/test/","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/think2011.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-09T07:10:14.000Z","updated_at":"2025-04-06T06:49:55.000Z","dependencies_parsed_at":"2022-07-26T13:48:03.942Z","dependency_job_id":null,"html_url":"https://github.com/think2011/localResizeIMG","commit_stats":null,"previous_names":["think2011/localresizeimg4"],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/think2011%2FlocalResizeIMG","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/think2011%2FlocalResizeIMG/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/think2011%2FlocalResizeIMG/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/think2011%2FlocalResizeIMG/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/think2011","download_url":"https://codeload.github.com/think2011/localResizeIMG/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252833378,"owners_count":21811173,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["canvas","compress-images","compressimage","frontend","image","localresizeimg","lrz","mobile"],"created_at":"2024-08-03T00:01:19.378Z","updated_at":"2025-05-07T07:30:29.183Z","avatar_url":"https://github.com/think2011.png","language":"JavaScript","readme":"[![Build Status](https://travis-ci.org/think2011/localResizeIMG.svg?branch=master)](https://travis-ci.org/think2011/localResizeIMG)\n[![npm version](https://img.shields.io/npm/v/lrz.svg)](https://www.npmjs.com/package/lrz)\n[![npm](https://img.shields.io/npm/l/express.svg)]()\n\n# 🚨重要!!\n\n很抱歉，这个项目已不再维护了，可能很长一段时间都不会更新了。\n\n# 演示\n\n![](http://think2011.github.io/localResizeIMG/test/demo.gif)\n\n# 试试\n\n![](https://raw.github.com/think2011/localResizeIMG/master/test/qrcode.png)\n\n\n[点我直接进入演示页面](http://think2011.github.io/localResizeIMG/test/)\n\n# 简述\n在客户端压缩好要上传的图片可以节省带宽更快的发送给后端，特别适合在移动设备上使用。\n\n# 为什么需要\n\n1. 已踩过很多坑，经过几个版本迭代，以及很多很多网友的反馈帮助、机型测试\n    * 图片扭曲、某些设备不自动旋转图片方向，没有jpeg压缩算法..\n    * 不支持new Blob,formData构造的文件size为0..\n    * 还有某些机型和浏览器（例如QQX5浏览器）莫名其妙的BUG..\n    \n2. 按需加载（会根据对应设备自动异步载入JS文件，节省不必要带宽）\n\n3. 原生JS编写，不依赖例如`jquery`等第三方库，支持AMD or CMD规范。\n\n\u003e 尽管如此，在某些 `Android` 下依然有莫名其妙的问题，在您使用前，请一定大致浏览下 [issues](https://github.com/think2011/localResizeIMG/issues)\n\n# 如何获取\n\n通过以下方式都可以下载：\n\n1. 执行`npm i lrz`（推荐）\n2. 执行`bower install lrz`\n\n接着在页面中引入\n```html\n\u003cscript src=\"./dist/lrz.bundle.js\"\u003e\u003c/script\u003e\n```\n\n# 如何使用\n\n### 方式1:\n\n如果您的图片来自用户拍摄或者上传的，您需要一个`input file`来获取图片。\n\n```html\n\u003cinput id=\"file\" type=\"file\" accept=\"image/*\" /\u003e\n```\n\n接着通过change事件可以得到用户选择的图片\n```js\ndocument.querySelector('#file').addEventListener('change', function () {\n\tlrz(this.files[0])\n        .then(function (rst) {\n            // 处理成功会执行\n            console.log(rst);\n        })\n        .catch(function (err) {\n            // 处理失败会执行\n        })\n        .always(function () {\n            // 不管是成功失败，都会执行\n        });\n});\n```\n\n### 方式2：\n\n如果您的图片不是来自用户上传的，那么也可以直接传入图片路径。\n\n```js\nlrz('./xxx/xx/x.png')\n        .then(function (rst) {\n            // 处理成功会执行\n        })\n        .catch(function (err){\n            // 处理失败会执行\n        })\n        .always(function () {\n            // 不管是成功失败，都会执行\n        });\n```\n\n# 后端处理\n\n[后端处理请查看WIKI。](https://github.com/think2011/localResizeIMG/wiki)\n\n\n# API\n\n[具体参数说明请查看WIKI。](https://github.com/think2011/localResizeIMG/wiki)\n\n# 兼容性\n\nIE10以上及大部分非IE浏览器（chrome、微信什么的）\n\n# FAQ\n\n[有疑问请直接在 issues 中提问](https://github.com/think2011/localResizeIMG/issues)\n\n```\n请一定记得附上以下内容：💡\n请一定记得附上以下内容：🙈\n请一定记得附上以下内容：💡\n\n平台：微信..\n设备：iPhone5 IOS7..\n问题：问题描述..\n```\n\n* Q：有时拍摄完照片后，页面自动刷新或闪退了。\n* A：虽然已作了优化处理，但内存似乎还是爆掉了，常见于低配android手机，建议每次只处理一张图片。\n\n* Q: 怎么批量上传图片?\n* A: 您可以自己写个循环来传入用户多选的图片，但在移动端上请谨慎处理，原因同上。\n\n* Q: 直接传入图片路径的无法生成图片\n* A: 可能是跨域的问题，具体请看[CORS_enabled_image](https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image)\n\n* Q: 想要商用可以吗？\n* A: 没问题，但请留意issue里已知的问题。\n\n# 感谢\n\n* [dwandw](https://github.com/dwandw)\n* [yourlin](https://github.com/yourlin)\n* [wxt2005](https://github.com/wxt2005)\n* [LingRen](https://github.com/LingRen)\n\n以上在之前的版本帮忙参与维护的朋友，以及提出问题的朋友们，真的真的很感谢你们。：D\n","funding_links":[],"categories":["10. 表单处理","JavaScript"],"sub_categories":["10.4 上传组件 ###","10.5 上传组件"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthink2011%2FlocalResizeIMG","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthink2011%2FlocalResizeIMG","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthink2011%2FlocalResizeIMG/lists"}