1 line
30 KiB
JavaScript
1 line
30 KiB
JavaScript
|
|
!function(){"use strict";function e(e){return JSON.parse(JSON.stringify(e))}function t(e){for(var t=y(e);"ÿà"<=t[1].slice(0,2)&&t[1].slice(0,2)<="ÿï";)t=[t[0]].concat(t.slice(2));return t.join("")}function a(e){return s(">"+p("B",e.length),e)}function n(e){return s(">"+p("H",e.length),e)}function i(e){return s(">"+p("L",e.length),e)}function r(e,t,r){var o,l,m,y,S="",f="";if("Byte"==t)o=e.length,4>=o?f=a(e)+p("\x00",4-o):(f=s(">L",[r]),S=a(e));else if("Short"==t)o=e.length,2>=o?f=n(e)+p("\x00\x00",2-o):(f=s(">L",[r]),S=n(e));else if("Long"==t)o=e.length,1>=o?f=i(e):(f=s(">L",[r]),S=i(e));else if("Ascii"==t)l=e+"\x00",o=l.length,o>4?(f=s(">L",[r]),S=l):f=l+p("\x00",4-o);else if("Rational"==t){if("number"==typeof e[0])o=1,m=e[0],y=e[1],l=s(">L",[m])+s(">L",[y]);else{o=e.length,l="";for(var c=0;o>c;c++)m=e[c][0],y=e[c][1],l+=s(">L",[m])+s(">L",[y])}f=s(">L",[r]),S=l}else if("SRational"==t){if("number"==typeof e[0])o=1,m=e[0],y=e[1],l=s(">l",[m])+s(">l",[y]);else{o=e.length,l="";for(var c=0;o>c;c++)m=e[c][0],y=e[c][1],l+=s(">l",[m])+s(">l",[y])}f=s(">L",[r]),S=l}else"Undefined"==t&&(o=e.length,o>4?(f=s(">L",[r]),S=e):f=e+p("\x00",4-o));var h=s(">L",[o]);return[h,f,S]}function o(e,t,a){var n,i=8,o=Object.keys(e).length,l=s(">H",[o]);n=["0th","1st"].indexOf(t)>-1?2+12*o+4:2+12*o;var m,p="",y="";for(var m in e)if("string"==typeof m&&(m=parseInt(m)),!("0th"==t&&[34665,34853].indexOf(m)>-1||"Exif"==t&&40965==m||"1st"==t&&[513,514].indexOf(m)>-1)){var S=e[m],f=s(">H",[m]),c=u[t][m].type,h=s(">H",[g[c]]);"number"==typeof S&&(S=[S]);var d=i+n+a+y.length,P=r(S,c,d),C=P[0],R=P[1],L=P[2];p+=f+h+C+R,y+=L}return[l+p,y]}function l(e){var t,a;if("ÿØ"==e.slice(0,2))t=y(e),a=S(t),a?this.tiftag=a.slice(10):this.tiftag=null;else if(["II","MM"].indexOf(e.slice(0,2))>-1)this.tiftag=e;else{if("Exif"!=e.slice(0,4))throw new Error("Given file is neither JPEG nor TIFF.");this.tiftag=e.slice(6)}}function s(e,t){if(!(t instanceof Array))throw new Error("'pack' error. Got invalid type argument.");if(e.length-1!=t.length)throw new Error("'pack' error. "+(e.length-1)+" marks, "+t.length+" elements.");var a;if("<"==e[0])a=!0;else{if(">"!=e[0])throw new Error("");a=!1}for(var n="",i=1,r=null,o=null,l=null;o=e[i];){if("b"==o.toLowerCase()){if(r=t[i-1],"b"==o&&0>r&&(r+=256),r>255||0>r)throw new Error("'pack' error.");l=String.fromCharCode(r)}else if("H"==o){if(r=t[i-1],r>65535||0>r)throw new Error("'pack' error.");l=String.fromCharCode(Math.floor(r%65536/256))+String.fromCharCode(r%256),a&&(l=l.split("").reverse().join(""))}else{if("l"!=o.toLowerCase())throw new Error("'pack' error.");if(r=t[i-1],"l"==o&&0>r&&(r+=4294967296),r>4294967295||0>r)throw new Error("'pack' error.");l=String.fromCharCode(Math.floor(r/16777216))+String.fromCharCode(Math.floor(r%16777216/65536))+String.fromCharCode(Math.floor(r%65536/256))+String.fromCharCode(r%256),a&&(l=l.split("").reverse().join(""))}n+=l,i+=1}return n}function m(e,t){if("string"!=typeof t)throw new Error("'unpack' error. Got invalid type argument.");for(var a=0,n=1;n<e.length;n++)if("b"==e[n].toLowerCase())a+=1;else if("h"==e[n].toLowerCase())a+=2;else{if("l"!=e[n].toLowerCase())throw new Error("'unpack' error. Got invalid mark.");a+=4}if(a!=t.length)throw new Error("'unpack' error. Mismatch between symbol and string length. "+a+":"+t.length);var i;if("<"==e[0])i=!0;else{if(">"!=e[0])throw new Error("'unpack' error.");i=!1}for(var r=[],o=0,l=1,s=null,m=null,p=null,y="";m=e[l];){if("b"==m.toLowerCase())p=1,y=t.slice(o,o+p),s=y.charCodeAt(0),"b"==m&&s>=128&&(s-=256);else if("H"==m)p=2,y=t.slice(o,o+p),i&&(y=y.split("").reverse().join("")),s=256*y.charCodeAt(0)+y.charCodeAt(1);else{if("l"!=m.toLowerCase())throw new Error("'unpack' error. "+m);p=4,y=t.slice(o,o+p),i&&(y=y.split("").reverse().join("")),s=16777216*y.charCodeAt(0)+65536*y.charCodeAt(1)+256*y.charCodeAt(2)+y.charCodeAt(3),"l"==m&&s>=2147483648&&(s-=4294967296)}r.push(s),o+=p,l+=1}return r}function p(e,t){for(var a="",n=0;t>n;n++)a+=e;return a}function y(e){if("ÿØ"!=e.slice(0,2))throw new Error("Given data isn't JPEG.");for(var t=2,a=["ÿØ"];;){i
|