PageSourceSearch

https://s.imgflip.com/v1553/ImageCropper.js

js imgflip.com collected 2026-10-01 06:49:03 UTC 4,343 bytes, 9 lines download raw bytes

1(function(Q){Q.ImageCropper=function(E,R,J){function F(a){K();x.show();x.addClass("notransition");l.addClass("notransition");x[0].offsetHeight;l[0].offsetHeight;x.removeClass("notransition");l.removeClass("notransition");x.addClass("icrop-transition");l.addClass("icrop-transition");a?C.setVals(a.x,a.y,a.w,a.h):C.setVals(0,0,l.width(),l.height());clearTimeout(L);L=setTimeout(function(){x.removeClass("icrop-transition");l.removeClass("icrop-transition")},1E3)}function G(){var a=Math.min(R,B.width());
2if(t/u>a/J)var b=a/t*u;else b=J,a=b/u*t;v.css({width:a,height:b});l.css({width:a,height:b});v[0].width=t;v[0].height=u;l[0].width=t;l[0].height=u;M(v[0],N,k,m);M(l[0],S,k,m);K()}function M(a,b,c,d){b.clearRect(0,0,a.width,a.height);b.translate(a.width/2,a.height/2);var e=90===d||270===d;b.scale(y&&!e||z&&e?-1:1,z&&!e||y&&e?-1:1);0<d?(b.rotate(d/180*Math.PI),180===d?(b.translate(-a.width/2,-a.height/2),b.drawImage(c,0,0,a.width,a.height),b.translate(a.width/2,a.height/2)):(b.translate(-a.height/2,
3-a.width/2),b.drawImage(c,0,0,a.height,a.width),b.translate(a.height/2,a.width/2)),b.rotate(-d/180*Math.PI)):b.drawImage(c,-a.width/2,-a.height/2,a.width,a.height);b.scale(1,1);b.translate(-a.width/2,-a.height/2)}function K(){T.height(v.height()).width(v.width())}function w(a,b,c,d){b=b*d+c;return{r:a[4*b],g:a[4*b+1],b:a[4*b+2],a:a[4*b+3]}}function D(a,b){return(a.r-b.r)*(a.r-b.r)+(a.g-b.g)*(a.g-b.g)+(a.b-b.b)*(a.b-b.b)+(a.a-b.a)*(a.a-b.a)}E=$(E);var B=$('<div class="icrop-wrap"><canvas class="icrop-preview-canv"></canvas><div class="icrop-bg"></div><div class="icrop-box"><div class="icrop-clip-wrap"><canvas class="icrop-clip-canv"></canvas></div></div></div>'),
4x=B.find(".icrop-box"),T=B.find(".icrop-bg"),v=B.find(".icrop-preview-canv"),l=B.find(".icrop-clip-canv");E.html(B);var H,h=this,t,u,m=0,z=!1,y=!1,k=new Image,O="",I=0,P="",C=new Dragger(x,l,function(a,b,c,d){a=parseInt(a);b=parseInt(b);l.css({left:-a,top:-b});H&&H()}),N=v[0].getContext("2d"),S=l[0].getContext("2d");h.getFilename=function(){return O};h.getTemplateId=function(){return I};h.setTemplateId=function(a){I=~~a};h.getOriginalImg=function(){return k};h.getOriginalUrl=function(){return P};
5h.setMoveCallback=function(a){H=a};h.setSrc=function(a,b,c,d){m=0;y=z=!1;$(k).off("load").on("load",function(){t=k.naturalWidth;u=k.naturalHeight;G();F()});k.src=a;O=b;I=~~c;P=d||""};h.getFinalDataUrl=function(a,b,c,d){var e=h.getVals();e=0!==e.x||0!==e.y||e.w!==k.naturalWidth||e.h!==k.naturalHeight||0!==m||z||y?!0:!1;if(!e&&"data:"===k.src.substr(0,5)&&!c)return k.src;c=h.getVals();e=d?c.w*d:c.w;d=d?c.h*d:c.h;var g=$("<canvas>").attr({width:e,height:d});g[0].getContext("2d").drawImage(v[0],c.x,c.y,
6c.w,c.h,0,0,e,d);return b?g[0].toDataURL(a,b):g[0].toDataURL(a)};h.setVals=function(a){var b=l.width()/(90===m||270===m?k.naturalHeight:k.naturalWidth),c=l.height()/(90===m||270===m?k.naturalWidth:k.naturalHeight);F({x:a.x*b,y:a.y*c,w:a.w*b,h:a.h*c})};h.getVals=function(){var a=(90===m||270===m?k.naturalHeight:k.naturalWidth)/l.width(),b=(90===m||270===m?k.naturalWidth:k.naturalHeight)/l.height(),c=C.getVals();return{x:Math.round(c.x*a),y:Math.round(c.y*b),w:Math.round(c.w*a),h:Math.round(c.h*b)}};
7h.constrainVals=function(){C.constrainVals()};h.getRotation=function(){return m};h.autoCrop=function(a){var b=h.setVals;var c=t,d=u,e=N.getImageData(0,0,c,d).data,g=[w(e,c,0,0),w(e,c,c-1,0),w(e,c,c-1,e.length/4/c-1),w(e,c,0,e.length/4/c-1)];var q={};for(var f=0;f<g.length;f++){var r=g[f].r+","+g[f].b+","+g[f].g+","+g[f].a;q[r]=q[r]?q[r]+1:1}g=0;f="";for(var p in q)q.hasOwnProperty(p)&&q[p]>g&&(g=q[p],f=p);f=f.split(",");q=f={r:f[0],g:f[1],b:f[2],a:f[3]};g=0;f=c;r=d;p=0;b:for(;p<c;p++){for(var n=g;n<
8d;n++){var A=D(q,w(e,c,p,n));if(1024<A)break b}f--}g=0;b:for(;g<d;g++){for(n=p;n<c;n++)if(A=D(q,w(e,c,n,g)),1024<A)break b;r--}f;b:for(;0<f;f--)for(n=g;n<g+r;n++)if(A=D(q,w(e,c,p+f,n)),1024<A)break b;r;b:for(;0<r;r--)for(n=p;n<p+f;n++)if(A=D(q,w(e,c,n,g+r)),1024<A)break b;a=0===f||0===r?{x:0,y:0,w:c,h:d}:{x:Math.max(0,p-a),y:Math.max(0,g-a),w:Math.max(0,Math.min(c,f+2*a)),h:Math.max(0,Math.min(d,r+2*a))};b.call(h,a)};h.rotateClockwise=function(){m=270===m?0:m+90;var a=t;t=u;u=a;G();F()};h.flipHorizontal=
9function(){90===m||270===m?z=!z:y=!y;G()};h.getFlipHorizontal=function(){return y};h.getFlipVertical=function(){return z};var L}})(window);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.