--- general_js.org 2015-02-09 20:27:58.000000000 +0900 +++ general.js 2015-02-09 20:29:21.000000000 +0900 @@ -1029,7 +1029,25 @@ zoom_window_io.className = "disp_img_real"; zoom_window_io.onload = function(){ + var orie = flashair.getOrientation(LIST[list_no].href); if( flashair.now_disp_mode == "window_disp" ){ + if ( ! zoom_window_io.style.transform) { + var rot = function(img, deg){ + var w = img.height; + var h = img.width; + img.width = w; + img.height = h; + var wh = w / h; + var hw = h / w; + img.style.transform = "rotate("+deg+"deg)scale("+hw+","+wh+")"; + } + if (orie === 6) { + rot(zoom_window_io, "90"); + } else if (orie === 8) { + rot(zoom_window_io, "270"); + } + } + zoom_flag = "window_zoom"; var dispw, disph; { @@ -1119,7 +1137,25 @@ zoom_actual_io.onload = function() { + var orie = flashair.getOrientation(LIST[list_no].href); if(flashair.now_disp_mode == "actual_disp"){ + if ( ! zoom_actual_io.style.transform) { + var rot = function(img, deg){ + var w = img.height; + var h = img.width; + img.width = w; + img.height = h; + var wh = w / h; + var hw = h / w; + img.style.transform = "rotate("+deg+"deg)scale("+hw+","+wh+")"; + } + if (orie === 6) { + rot(zoom_actual_io, "90"); + } else if (orie === 8) { + rot(zoom_actual_io, "270"); + } + } + zoom_flag = "actual_zoom"; zoom_disp_w = zoom_actual_io.width; @@ -3141,4 +3177,52 @@ httpObj.send(null); return httpObj.responseText; } +,//based-on: http://www.egashira.jp/2013/03/obtain-orientation-from-jpeg-exif + getOrientation : function(url){ + //var byteString = atob(imgDataURL.split(',')[1]); + var req = new XMLHttpRequest(); + req.open("GET", url, false); + req.overrideMimeType('text\/plain; charset=x-user-defined'); + req.send(null); + var byteString = req.responseText; + if (!byteString) { + return; + } + var orientaion = byteStringToOrientation(byteString); + return orientaion; + + function byteStringToOrientation(img){ + var head = 0; + var orientation; + while (1){ + if ((img.charCodeAt(head) & 255) == 255 && (img.charCodeAt(head + 1) & 255) == 218) {break;} + if ((img.charCodeAt(head) & 255) == 255 && (img.charCodeAt(head + 1) & 255) == 216) { + head += 2; + } + else { + var length = (img.charCodeAt(head + 2) & 255) * 256 + (img.charCodeAt(head + 3) & 255); + var endPoint = head + length + 2; + if ((img.charCodeAt(head) & 255) == 255 && (img.charCodeAt(head + 1) & 255) == 225) { + var segment = img.slice(head, endPoint); + var bigEndian = (segment.charCodeAt(10) & 255) == 77; + if (bigEndian) { + var count = (segment.charCodeAt(18) & 255) * 256 + (segment.charCodeAt(19) & 255); + } else { + var count = (segment.charCodeAt(18) & 255) + (segment.charCodeAt(19) & 255) * 256; + } + for (i=0;i img.length){break;} + } + return orientation; + } + } }