Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9ec892b

Browse files
committed
Removed Math.ceil calls to avoid rounding errors.
Let the browser implicitly cast calculated image dimensions from floating point values to integer values.
1 parent 000deb7 commit 9ec892b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

js/load-image.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* JavaScript Load Image 1.9.0
2+
* JavaScript Load Image 1.9.1
33
* https://github.com/blueimp/JavaScript-Load-Image
44
*
55
* Copyright 2011, Sebastian Tschan
@@ -148,8 +148,8 @@
148148
(minHeight || destHeight) / destHeight
149149
);
150150
if (scale > 1) {
151-
destWidth = Math.ceil(destWidth * scale);
152-
destHeight = Math.ceil(destHeight * scale);
151+
destWidth = destWidth * scale;
152+
destHeight = destHeight * scale;
153153
}
154154
},
155155
scaleDown = function () {
@@ -158,8 +158,8 @@
158158
(maxHeight || destHeight) / destHeight
159159
);
160160
if (scale < 1) {
161-
destWidth = Math.ceil(destWidth * scale);
162-
destHeight = Math.ceil(destHeight * scale);
161+
destWidth = destWidth * scale;
162+
destHeight = destHeight * scale;
163163
}
164164
};
165165
if (useCanvas) {

0 commit comments

Comments
 (0)