All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.resources.bower_components.blueimp-load-image.js.load-image-scale.min.js Maven / Gradle / Ivy

Go to download

File Upload widget with multiple file selection, drag and drop support, progress bar, validation and preview images, audio and video for jQuery. Supports cross-domain, chunked and resumable file uploads. Works with any server-side platform (Google App Engine, PHP, Python, Ruby on Rails, Java, etc.) that supports standard HTML form file uploads.

There is a newer version: 1.2.2.1-jre17
Show newest version
(function(a){if(typeof define==="function"&&define.amd){define(["./load-image"],a)}else{if(typeof module==="object"&&module.exports){a(require("./load-image"))}else{a(window.loadImage)}}})(function(b){var a=b.transform;b.transform=function(c,d,g,e,f){a.call(b,b.scale(c,d,f),d,g,e,f)};b.transformCoordinates=function(){};b.getTransformedOptions=function(d,e){var h=e.aspectRatio;var j;var f;var g;var c;if(!h){return e}j={};for(f in e){if(e.hasOwnProperty(f)){j[f]=e[f]}}j.crop=true;g=d.naturalWidth||d.width;c=d.naturalHeight||d.height;if(g/c>h){j.maxWidth=c*h;j.maxHeight=c}else{j.maxWidth=g;j.maxHeight=g/h}return j};b.renderImageToCanvas=function(e,i,g,d,c,h,k,j,l,f){e.getContext("2d").drawImage(i,g,d,c,h,k,j,l,f);return e};b.hasCanvasOption=function(c){return c.canvas||c.crop||!!c.aspectRatio};b.scale=function(x,g,w){g=g||{};var f=document.createElement("canvas");var i=x.getContext||(b.hasCanvasOption(g)&&f.getContext);var s=x.naturalWidth||x.width;var o=x.naturalHeight||x.height;var h=s;var k=o;var u;var r;var n;var j;var l;var e;var q;var p;var d;var c;var v;function m(){var y=Math.max((n||h)/h,(j||k)/k);if(y>1){h*=y;k*=y}}function t(){var y=Math.min((u||h)/h,(r||k)/k);if(y<1){h*=y;k*=y}}if(i){g=b.getTransformedOptions(x,g,w);q=g.left||0;p=g.top||0;if(g.sourceWidth){l=g.sourceWidth;if(g.right!==undefined&&g.left===undefined){q=s-l-g.right}}else{l=s-q-(g.right||0)}if(g.sourceHeight){e=g.sourceHeight;if(g.bottom!==undefined&&g.top===undefined){p=o-e-g.bottom}}else{e=o-p-(g.bottom||0)}h=l;k=e}u=g.maxWidth;r=g.maxHeight;n=g.minWidth;j=g.minHeight;if(i&&u&&r&&g.crop){h=u;k=r;v=l/e-u/r;if(v<0){e=r*l/u;if(g.top===undefined&&g.bottom===undefined){p=(o-e)/2}}else{if(v>0){l=u*e/r;if(g.left===undefined&&g.right===undefined){q=(s-l)/2}}}}else{if(g.contain||g.cover){n=u=u||n;j=r=r||j}if(g.cover){t();m()}else{m();t()}}if(i){d=g.pixelRatio;if(d>1){f.style.width=h+"px";f.style.height=k+"px";h*=d;k*=d;f.getContext("2d").scale(d,d)}c=g.downsamplingRatio;if(c>0&&c<1&&hh){f.width=l*c;f.height=e*c;b.renderImageToCanvas(f,x,q,p,l,e,0,0,f.width,f.height);q=0;p=0;l=f.width;e=f.height;x=document.createElement("canvas");x.width=l;x.height=e;b.renderImageToCanvas(x,f,0,0,l,e,0,0,l,e)}}f.width=h;f.height=k;b.transformCoordinates(f,g);return b.renderImageToCanvas(f,x,q,p,l,e,0,0,h,k)}x.width=h;x.height=k;return x}});




© 2015 - 2025 Weber Informatics LLC | Privacy Policy