Skip to content
This repository has been archived by the owner on May 8, 2021. It is now read-only.

Commit

Permalink
Fixed #42 某些设备旋转时会被拉伸 感谢@richard-chen-1985
Browse files Browse the repository at this point in the history
  • Loading branch information
think2011 committed Nov 4, 2015
1 parent d5581c9 commit c082d2d
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lrz",
"version": "4.5.20",
"version": "4.5.21",
"homepage": "https://github.com/think2011/localResizeIMG",
"authors": [
"think2011 <452125301@qq.com>"
Expand Down
2 changes: 1 addition & 1 deletion dist/2.chunk.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/lrz.all.bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/lrz.all.bundle.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/lrz.bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/lrz.bundle.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lrz",
"version": "4.5.20",
"version": "4.5.21",
"description": "前端本地客户端压缩图片,兼容IOS,Android,PC、自动按需加载文件",
"scripts": {
"test": "node ./node_modules/karma/bin/karma start"
Expand Down
5 changes: 5 additions & 0 deletions src/lrz.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ Lrz.prototype._getResize = function () {
height: img.height
};

if ("5678".indexOf(orientation) > -1) {
ret.width = img.height;
ret.height = img.width;
}

// 如果原图小于设定,采用原图
if (ret.width < width || ret.height < height) {
return ret;
Expand Down
6 changes: 3 additions & 3 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<div class="row">
<div class="col-xs-12 text-center">
<h3 style="margin-top: 0;">上传图片测试</h3>
<small class="text-muted">配置:宽度不超过1024,高度适应,70%压缩率</small>
<small class="text-muted">配置:宽度不超过800,高度适应,70%压缩率</small>
<br/>
<small class="text-muted UA">UA</small>
<hr/>
Expand Down Expand Up @@ -89,7 +89,7 @@ <h3>旋转方向测试</h3>
</footer>


<script src="../dist/lrz.bundle.js?v=6c25fbe"></script>
<script src="./index.js?v=46a6cff"></script>
<script src="../dist/lrz.bundle.js?v=4531b70"></script>
<script src="./index.js?v=8ef8f4f"></script>
</body>
</html>
10 changes: 5 additions & 5 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ document.querySelector('input').addEventListener('change', function () {
var that = this;

lrz(that.files[0], {
width: 1024
width: 800
})
.then(function (rst) {
var img = new Image(),
div = document.createElement('div'),
p = document.createElement('p'),
var img = new Image(),
div = document.createElement('div'),
p = document.createElement('p'),
sourceSize = toFixed2(that.files[0].size / 1024),
resultSize = toFixed2(rst.fileLen / 1024),
scale = parseInt(100 - (resultSize / sourceSize * 100));
scale = parseInt(100 - (resultSize / sourceSize * 100));

/* ==================================================== */
// 原生ajax上传代码,所以看起来特别多 ╮(╯_╰)╭,但绝对能用
Expand Down

0 comments on commit c082d2d

Please sign in to comment.