aboutsummaryrefslogtreecommitdiffstats
path: root/web/js/dropzone.js.patch
blob: 030b56a6a5346eeff8409b8b11f8e1f996fe297f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
--- web/js/src/dropzone.orig.js	2016-06-17 21:29:47.000000000 +0100
+++ web/js/src/dropzone.js	2016-06-20 11:40:55.000000000 +0100
@@ -1469,7 +1469,7 @@
     return _results;
   };
 
-  Dropzone.blacklistedBrowsers = [/opera.*Macintosh.*version\/12/i];
+  Dropzone.blacklistedBrowsers = [/opera.*(Windows Phone|Macintosh).*version\/12/i];
 
   Dropzone.isBrowserSupported = function() {
     var capableBrowser, regex, _i, _len, _ref;
@@ -1679,7 +1679,23 @@
   drawImageIOSFix = function(ctx, img, sx, sy, sw, sh, dx, dy, dw, dh) {
     var vertSquashRatio;
     vertSquashRatio = detectVerticalSquash(img);
-    return ctx.drawImage(img, sx, sy, sw, sh, dx, dy, dw, dh / vertSquashRatio);
+    dh = dh / vertSquashRatio;
+
+    /* An improved version of http://stackoverflow.com/a/28356942/669631 */
+    var orientation = 0;
+    switch (EXIF.getData(img)) {
+        case 3: orientation = 2; break;
+        case 6: orientation = 1; break;
+        case 8: orientation = -1; break;
+    }
+    if (orientation) {
+        ctx.translate(dx + dw/2, dy + dh/2);
+        ctx.rotate(orientation * Math.PI / 2);
+        dx = -dw/2;
+        dy = -dh/2;
+    }
+
+    return ctx.drawImage(img, sx, sy, sw, sh, dx, dy, dw, dh);
   };