_.Module.define({path:"common/component/image_exif",requires:[],sub:{initial:function(){},getOrientation:function(a){if(a==null){return 0}var e=0;var d=0;while(e+3<a.length&&(a[e++]&255)==255){var f=a[e]&255;if(f==255){continue}e++;if(f==216||f==1){continue}if(f==217||f==218){break}d=this.pack(a,e,2,false);if(d<2||e+d>a.length){return 0}if(f==225&&d>=8&&this.pack(a,e+2,4,false)==1165519206&&this.pack(a,e+6,2,false)==0){e+=8;d-=8;break}e+=d;d=0}if(d>8){var j=this.pack(a,e,4,false);if(j!=1229531648&&j!=1296891946){return 0}var h=(j==1229531648);var g=this.pack(a,e+4,4,h)+2;if(g<10||g>d){return 0}e+=g;d-=g;var i=this.pack(a,e-2,2,h);while(i-->0&&d>=12){j=this.pack(a,e,2,h);if(j==274){var c=this.pack(a,e+4,4,h);var b=this.pack(a,e+8,c,h);switch(b){case 1:return 0;case 3:return 180;case 6:return 90;case 8:return 270}return 0}e+=12;d-=12}}return 0},pack:function(a,f,c,e){var b=1;if(e){f+=c-1;b=-1}var d=0;while(c-->0){d=(d<<8)|(a[f]&255);f+=b}return d},rotateByorientation:function(d,c){var a=new FileReader(),b=this;if(!d.size){this.trigger("success",d)}a.onload=function(){var e=this.result,f=new Uint8Array(e),g=b.getOrientation(f);b.trigger("degreeloaded",g);if(!c){b.rotateFile(d,g)}};a.readAsArrayBuffer(d)},rotateFile:function(c,d){if(d!=90&&d!=180&&d!=270){this.trigger("success",c);return}var a=new FileReader(),b=this;a.onload=function(){var f=this.result,e=new Image();e.onload=function(){b.rotateImage(e,d)};e.src=f};a.readAsDataURL(c)},rotateImage:function(b,f){var c=document.createElement("canvas"),d=c.getContext("2d"),e=b.width,a=b.height;d.save();if(f==90||f==270){c.width=a;c.height=e;if(f==90){d.translate(c.width,0)}else{d.translate(0,c.height)}}else{c.width=e;c.height=a;d.translate(c.width,c.height)}d.rotate(f*Math.PI/180);d.drawImage(b,0,0,e,a);d.restore();this.trigger("success",c)}}});