Файловый менеджер - Редактировать - /home/kunzqhe/photostocker/wp-content/themes/themify-ultra/themify/js/modules/image-resize.min.js
Назад
let ThemifyImageResize;((h,o,n)=>{"use strict";!function(t){const _=function(t,e,i){var r,s,a=function(t,e,i){e=new RegExp("\\b"+e+" \\w+ (\\w+)","ig");t.replace(e,function(t,e){return i[e]=0,t})},o=function(t,e,i){i=t.createShader(i);return t.shaderSource(i,e),t.compileShader(i),t.getShaderParameter(i,t.COMPILE_STATUS)?i:(console.log(t.getShaderInfoLog(i)),null)},h=(this.uniform={},this.attribute={},o(t,e,t.VERTEX_SHADER)),o=o(t,i,t.FRAGMENT_SHADER);for(r in this.id=t.createProgram(),t.attachShader(this.id,h),t.attachShader(this.id,o),t.linkProgram(this.id),t.getProgramParameter(this.id,t.LINK_STATUS)||console.log(t.getProgramInfoLog(this.id)),t.useProgram(this.id),a(e,"attribute",this.attribute),this.attribute)this.attribute[r]=t.getAttribLocation(this.id,r);for(s in a(e,"uniform",this.uniform),a(i,"uniform",this.uniform),this.uniform)this.uniform[s]=t.getUniformLocation(this.id,s)};t.WebGLImageFilter=function(t){t=t||{};var s=null,a=0,o=null,h=!1,c=-1,i=[null,null],n=new Map,l=-1,u=-1,r=null,m=null,g=t.canvas||document.createElement("canvas"),v={};if(!(s=g.getContext("webgl")||g.getContext("experimental-webgl")))throw"Couldn't get WebGL context";this.addFilter=function(t,...e){n.set(w[t],e)};var e=!(this.reset=function(){n.clear()}),f=(this.apply=function(t){f(t.width,t.height),a=0;const r=n.size;if(o=o||s.createTexture(),s.bindTexture(s.TEXTURE_2D,o),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.NEAREST),e?s.texSubImage2D(s.TEXTURE_2D,0,0,0,s.RGBA,s.UNSIGNED_BYTE,t):(s.texImage2D(s.TEXTURE_2D,0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,t),e=!0),0===r)d(R.FRAGMENT_IDENTITY),E();else{let i=0;for(let[t,e]of n)h=i===r-1,t.apply(this,e||[]),++i}return g},function(t,e){t===l&&e===u||(g.width=l=t,g.height=u=e,r||(t=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,-1,1,0,0,1,-1,1,1,1,1,1,0]),r=s.createBuffer(),s.bindBuffer(s.ARRAY_BUFFER,r),s.bufferData(s.ARRAY_BUFFER,t,s.STATIC_DRAW),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)),s.viewport(0,0,l,u),i=[null,null])}),x=function(t){return i[t]=i[t]||p(l,u),i[t]},p=function(t,e){var i=s.createFramebuffer(),r=(s.bindFramebuffer(s.FRAMEBUFFER,i),s.createRenderbuffer()),r=(s.bindRenderbuffer(s.RENDERBUFFER,r),s.createTexture());return s.bindTexture(s.TEXTURE_2D,r),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,t,e,0,s.RGBA,s.UNSIGNED_BYTE,null),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,r,0),s.bindTexture(s.TEXTURE_2D,null),s.bindFramebuffer(s.FRAMEBUFFER,null),{fbo:i,texture:r}},E=function(t){var e=null,i=null,r=!1,e=0===a?o:x(c).texture;a++,!h||t&T.INTERMEDIATE?i=x(c=(c+1)%2).fbo:(i=null,r=a%2==0),s.bindTexture(s.TEXTURE_2D,e),s.bindFramebuffer(s.FRAMEBUFFER,i),s.uniform1f(m.uniform.flipY,r?-1:1),s.drawArrays(s.TRIANGLES,0,6)},d=function(t){var e,i;return v[t]?(m=v[t],s.useProgram(m.id)):(m=new _(s,R.VERTEX_IDENTITY,t),i=4*(e=Float32Array.BYTES_PER_ELEMENT),s.enableVertexAttribArray(m.attribute.pos),s.vertexAttribPointer(m.attribute.pos,2,s.FLOAT,!1,i,0*e),s.enableVertexAttribArray(m.attribute.uv),s.vertexAttribPointer(m.attribute.uv,2,s.FLOAT,!1,i,2*e),v[t]=m),m},T={INTERMEDIATE:1},R={},w=(R.VERTEX_IDENTITY=["precision highp float;","attribute vec2 pos;","attribute vec2 uv;","varying vec2 vUv;","uniform float flipY;","void main(void) {","vUv = uv;","gl_Position = vec4(pos.x, pos.y*flipY, 0.0, 1.);","}"].join("\n"),R.FRAGMENT_IDENTITY=["precision highp float;","varying vec2 vUv;","uniform sampler2D texture;","void main(void) {","gl_FragColor = texture2D(texture, vUv);","}"].join("\n"),{});w.colorMatrix=function(t){var t=new Float32Array(t),e=(t[4]/=255,t[9]/=255,t[14]/=255,t[19]/=255,1===t[18]&&0===t[3]&&0===t[8]&&0===t[13]&&0===t[15]&&0===t[16]&&0===t[17]&&0===t[19]?w.colorMatrix.SHADER.WITHOUT_ALPHA:w.colorMatrix.SHADER.WITH_ALPHA);s.uniform1fv(d(e).uniform.m,t),E()},w.colorMatrix.SHADER={},w.colorMatrix.SHADER.WITH_ALPHA=["precision highp float;","varying vec2 vUv;","uniform sampler2D texture;","uniform float m[20];","void main(void) {","vec4 c = texture2D(texture, vUv);","gl_FragColor.r = m[0] * c.r + m[1] * c.g + m[2] * c.b + m[3] * c.a + m[4];","gl_FragColor.g = m[5] * c.r + m[6] * c.g + m[7] * c.b + m[8] * c.a + m[9];","gl_FragColor.b = m[10] * c.r + m[11] * c.g + m[12] * c.b + m[13] * c.a + m[14];","gl_FragColor.a = m[15] * c.r + m[16] * c.g + m[17] * c.b + m[18] * c.a + m[19];","}"].join("\n"),w.colorMatrix.SHADER.WITHOUT_ALPHA=["precision highp float;","varying vec2 vUv;","uniform sampler2D texture;","uniform float m[20];","void main(void) {","vec4 c = texture2D(texture, vUv);","gl_FragColor.r = m[0] * c.r + m[1] * c.g + m[2] * c.b + m[4];","gl_FragColor.g = m[5] * c.r + m[6] * c.g + m[7] * c.b + m[9];","gl_FragColor.b = m[10] * c.r + m[11] * c.g + m[12] * c.b + m[14];","gl_FragColor.a = c.a;","}"].join("\n"),w.brightness=function(t){t=(t||0)+1;w.colorMatrix([t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0])},w.saturation=function(t){var t=2/3*(t||0)+1,e=-.5*(t-1);w.colorMatrix([t,e,e,0,0,e,t,e,0,0,e,e,t,0,0,0,0,0,1,0])},w.desaturate=function(){w.saturation(-1)},w.contrast=function(t){var t=(t||0)+1,e=-128*(t-1);w.colorMatrix([t,0,0,0,e,0,t,0,0,e,0,0,t,0,e,0,0,0,1,0])},w.negative=function(){w.contrast(-2)},w.hue=function(t){t=(t||0)/180*Math.PI;var e=Math.cos(t),t=Math.sin(t),i=.213,r=.715,s=.072;w.colorMatrix([i+.787*e+t*-i,r+e*-r+t*-r,s+e*-s+.928*t,0,0,i+e*-i+.143*t,r+.285*e+.14*t,s+e*-s+-.283*t,0,0,i+e*-i+-.787*t,r+e*-r+t*r,s+.928*e+t*s,0,0,0,0,0,1,0])},w.desaturateLuminance=function(){w.colorMatrix([.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,0,0,0,1,0])},w.sepia=function(t){w.colorMatrix([1-.607*t,.7689999*t,.18899999*t,0,0,.349*t,1-.314*t,.16799999*t,0,0,.272*t,.5339999*t,1-.869*t,0,0,0,0,0,1,0])},w.brownie=function(){w.colorMatrix([.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0])},w.vintagePinhole=function(){w.colorMatrix([.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0])},w.kodachrome=function(){w.colorMatrix([1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0])},w.technicolor=function(){w.colorMatrix([1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0])},w.polaroid=function(){w.colorMatrix([1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0])},w.shiftToBGR=function(){w.colorMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])},w.convolution=function(t){var t=new Float32Array(t),e=1/l,i=1/u,r=d(w.convolution.SHADER);s.uniform1fv(r.uniform.m,t),s.uniform2f(r.uniform.px,e,i),E()},w.convolution.SHADER=["precision highp float;","varying vec2 vUv;","uniform sampler2D texture;","uniform vec2 px;","uniform float m[9];","void main(void) {","vec4 c11 = texture2D(texture, vUv - px);","vec4 c12 = texture2D(texture, vec2(vUv.x, vUv.y - px.y));","vec4 c13 = texture2D(texture, vec2(vUv.x + px.x, vUv.y - px.y));","vec4 c21 = texture2D(texture, vec2(vUv.x - px.x, vUv.y) );","vec4 c22 = texture2D(texture, vUv);","vec4 c23 = texture2D(texture, vec2(vUv.x + px.x, vUv.y) );","vec4 c31 = texture2D(texture, vec2(vUv.x - px.x, vUv.y + px.y) );","vec4 c32 = texture2D(texture, vec2(vUv.x, vUv.y + px.y) );","vec4 c33 = texture2D(texture, vUv + px );","gl_FragColor = ","c11 * m[0] + c12 * m[1] + c22 * m[2] +","c21 * m[3] + c22 * m[4] + c23 * m[5] +","c31 * m[6] + c32 * m[7] + c33 * m[8];","gl_FragColor.a = c22.a;","}"].join("\n"),w.detectEdges=function(){w.convolution.call(this,[0,1,0,1,-4,1,0,1,0])},w.sobelX=function(){w.convolution.call(this,[-1,0,1,-2,0,2,-1,0,1])},w.sobelY=function(){w.convolution.call(this,[-1,-2,-1,0,0,0,1,2,1])},w.sharpen=function(t){t=t||1;w.convolution.call(this,[0,-1*t,0,-1*t,1+4*t,-1*t,0,-1*t,0])},w.emboss=function(t){t=t||1;w.convolution.call(this,[-2*t,-1*t,0,-1*t,1,+t,0,+t,2*t])},w.blur=function(t){var e=t/7/l,t=t/7/u,i=d(w.blur.SHADER);s.uniform2f(i.uniform.px,0,t),E(T.INTERMEDIATE),s.uniform2f(i.uniform.px,e,0),E()},w.blur.SHADER=["precision highp float;","varying vec2 vUv;","uniform sampler2D texture;","uniform vec2 px;","void main(void) {","gl_FragColor = vec4(0.0);","gl_FragColor += texture2D(texture, vUv + vec2(-7.0*px.x, -7.0*px.y))*0.0044299121055113265;","gl_FragColor += texture2D(texture, vUv + vec2(-6.0*px.x, -6.0*px.y))*0.00895781211794;","gl_FragColor += texture2D(texture, vUv + vec2(-5.0*px.x, -5.0*px.y))*0.0215963866053;","gl_FragColor += texture2D(texture, vUv + vec2(-4.0*px.x, -4.0*px.y))*0.0443683338718;","gl_FragColor += texture2D(texture, vUv + vec2(-3.0*px.x, -3.0*px.y))*0.0776744219933;","gl_FragColor += texture2D(texture, vUv + vec2(-2.0*px.x, -2.0*px.y))*0.115876621105;","gl_FragColor += texture2D(texture, vUv + vec2(-1.0*px.x, -1.0*px.y))*0.147308056121;","gl_FragColor += texture2D(texture, vUv )*0.159576912161;","gl_FragColor += texture2D(texture, vUv + vec2( 1.0*px.x, 1.0*px.y))*0.147308056121;","gl_FragColor += texture2D(texture, vUv + vec2( 2.0*px.x, 2.0*px.y))*0.115876621105;","gl_FragColor += texture2D(texture, vUv + vec2( 3.0*px.x, 3.0*px.y))*0.0776744219933;","gl_FragColor += texture2D(texture, vUv + vec2( 4.0*px.x, 4.0*px.y))*0.0443683338718;","gl_FragColor += texture2D(texture, vUv + vec2( 5.0*px.x, 5.0*px.y))*0.0215963866053;","gl_FragColor += texture2D(texture, vUv + vec2( 6.0*px.x, 6.0*px.y))*0.00895781211794;","gl_FragColor += texture2D(texture, vUv + vec2( 7.0*px.x, 7.0*px.y))*0.0044299121055113265;","}"].join("\n"),w.pixelate=function(t){var e=t/l,t=t/u,i=d(w.pixelate.SHADER);s.uniform2f(i.uniform.size,e,t),E()},w.pixelate.SHADER=["precision highp float;","varying vec2 vUv;","uniform vec2 size;","uniform sampler2D texture;","vec2 pixelate(vec2 coord, vec2 size) {","return floor( coord / size ) * size;","}","void main(void) {","gl_FragColor = vec4(0.0);","vec2 coord = pixelate(vUv, size);","gl_FragColor += texture2D(texture, coord);","}"].join("\n")}}(window);const c=o.createElement("canvas").toDataURL("image/webp").includes("data:image/webp"),a=new Map,r=(ThemifyImageResize=class{constructor(t,i,e,r){this.img=t;const s=!e&&t.dataset.orig?t.dataset.orig:t.currentSrc||t.src||"",a=h.upload_url||window.location.protocol+"//"+h.urlHost;this.isLocal=!0===r||(0===s.indexOf(a)||s.includes("blob:")||s.includes("data:"))&&!t.closest("[data-hasEditor]"),!0===this.isLocal?(s.includes("blob:")||s.includes("data:")||(t.dataset.orig=s),t.complete&&(this.w=t.naturalWidth,this.h=t.naturalHeight,2560<this.w||2560<this.h)?(this.url=s,this.isBig=!0,this.prms=Promise.resolve()):(this.ext=s.slice(2+(s.lastIndexOf(".")-1>>>0)),"svg"===this.ext?(this.url=s,this.prms=Promise.resolve()):("jpg"===this.ext&&(this.ext="jpeg"),this.ext="image/"+this.ext,this.webp=!0===c?"image/webp":this.ext,this.prms=new Promise(async(t,e)=>{this.tmpImg=new Image,this.tmpImg.crossOrigin="anonymous",this.tmpImg.decoding="async",this.tmpImg.src=s;try{await this.tmpImg.decode(),this.w=Math.trunc(this.tmpImg.naturalWidth),this.h=Math.trunc(this.tmpImg.naturalHeight),2560<this.w||2560<this.h?(this.url=s,this.isBig=!0,t()):(this.aspectRatio=parseFloat(this.w/this.h),this.canvas=o.createElement("canvas"),this.ctx=this.canvas.getContext("2d",{alpha:!this.ext.includes("jpeg")}),0<i?this.q=i:(this.q=.01,this.w<380&&this.h<380?this.q=1:this.w<400&&this.h<400?this.q=.9:this.w<450&&this.h<450?this.q=.8:this.w<500&&this.h<500?this.q=.7:this.w<550&&this.h<550?this.q=.6:this.w<650&&this.h<650?this.q=.5:this.w<850&&this.h<850?this.q=.4:this.w<1e3&&this.h<1e3?this.q=.3:this.w<1100&&this.h<1100?this.q=.2:this.w<1200&&this.h<1200?this.q=.1:1700<this.w&&1700<this.h&&(this.q=.001)),this.ctx.imageSmoothingEnabled=.7<this.q,this.ctx.imageSmoothingQuality=.7<this.q?"high":.5<this.q?"medium":"low",1!==this.q&&(this.origImg=this.tmpImg.cloneNode(!0)),await this._applyEfects(),t())}catch(t){e(t)}})))):(this.url=s,this.prms=Promise.resolve())}lowQuality(a,o){return new Promise((r,s)=>{this.prms.then(()=>{if(!1===this.isLocal||!0===this.isBig||"svg"===this.ext)r();else{const t=navigator.deviceMemory,e=(a=a||("mobile"===h.device?400:4<t?800:600),o=o||("mobile"===h.device?400:4<t?800:600),a),i=o;if(this.w>e||this.h>i){this.w>this.h?this.w>e&&(this.h*=e/this.w,this.w=e):this.h>i&&(this.w*=i/this.h,this.h=i),this.canvas.width=this.w,this.canvas.height=this.h,this.aspectRatio=parseFloat(this.w/this.h),this.ctx.imageSmoothingEnabled=!1,this.ctx.imageSmoothingQuality="low";(()=>"function"==typeof createImageBitmap?createImageBitmap(this.tmpImg,{resizeQuality:"pixelated",resizeWidth:this.w,resizeHeight:this.h}):Promise.reject())().then(t=>{this.ctx.drawImage(t,0,0)}).catch(()=>{this.ctx.drawImage(this.tmpImg,0,0,this.w,this.h)}).then(()=>{this.canvas.toBlob(t=>{try{const e=URL.createObjectURL(t,this.webp);this.tmpImg.tfOn("load",()=>{URL.revokeObjectURL(e),r()},{passive:!0,once:!0}),this.tmpImg.src=e}catch(t){s(t)}},this.webp,.1)}).catch(s)}else r()}}).catch(s)})}highQuality(r,s,a){return new Promise(async(t,e)=>{try{if(await this.prms,!1===this.isLocal||!0===this.isBig||"svg"===this.ext)t();else{this.origImg&&(await this.origImg.decode(),this.tmpImg=this.origImg,this.w=this.tmpImg.naturalWidth,this.h=this.tmpImg.naturalHeight,this.aspectRatio=parseFloat(this.w/this.h));const i=await this.toBlob(r,s,1,a);t(i)}}catch(t){e(t)}})}resize(s,a,o,h){return new Promise((r,t)=>{this.prms.then(()=>{const t=this.calculate(s,a);let e;if(!0===this.isLocal&&!0!==this.isBig&&"svg"!==this.ext){this.canvas.width=t.w=Math.trunc(t.w),this.canvas.height=t.h=Math.trunc(t.h);const i=this.effects.get("flip");i&&this._setFlip(i.v,i.h,t.w,t.h),this.ctx.drawImage(this.tmpImg,t.x,t.y,t.w,t.h,0,0,t.w,t.h),o===n&&(o=this.q),h=h||this.webp,e=this.canvas.toDataURL(h,o),this.img.setAttribute("src",e)}else e=this.url;s?(s=Math.trunc(s),this.img.setAttribute("width",s),this.img.style.width&&(this.img.style.width=s+"px")):this.img.removeAttribute("width"),a?(a=Math.trunc(a),this.img.setAttribute("height",a),this.img.style.height&&(this.img.style.height=a+"px")):this.img.removeAttribute("height"),r([e,s,a,t.w,t.h])}).catch(t)})}toBlob(r,s,a,o){return new Promise(async(t,e)=>{try{if(await this.prms,!1===this.isLocal||!0===this.isBig||"svg"===this.ext)t();else{a=a||this.q,this.ctx.imageSmoothingEnabled=.7<a,this.ctx.imageSmoothingQuality=.7<a?"high":.5<a?"medium":"low",await this.resize(r,s,a,o);const i=await this.save(a,o);t(i)}}catch(t){e(t)}})}flip(c){return new Promise(async(t,e)=>{try{if(await this.prms,!1===this.isLocal||!0===this.isBig||"svg"===this.ext);else{const i=c?"v":"h",r=this._getEffect("flip")||{},s=!!c&&1,a=!c&&1,o=this.w,h=this.h;this.canvas.width=o,this.canvas.height=h,this.ctx.imageSmoothingEnabled=!0,this.ctx.imageSmoothingQuality="high",this._setFlip(s,a,o,h),this.ctx.drawImage(this.tmpImg,0,0,o,h,0,0,o,h),r[i]!==n?delete r[i]:r[i]=1,this._setEffect("flip",r),console.log(r[i]),await this.save(1,this.ext)}t()}catch(t){console.log(t),e(t)}})}_setFlip(t,e,i,r){this.ctx.setTransform(e?-1:1,0,0,t?-1:1,e?i:0,t?r:0)}filter(a,o){return new Promise(async(t,e)=>{try{if(await this.prms,!1===this.isLocal||!0===this.isBig||"svg"===this.ext);else{const i=this.w,r=this.h,s=(this.filterEff||(this.canvas.width=i,this.canvas.height=r,this.filterEff=new WebGLImageFilter),this.ctx.drawImage(this.tmpImg,0,0,i,r,0,0,i,r),1<o&&(o=parseFloat(o/100)),this.filterEff.addFilter(a,o),this.filterEff.apply(this.canvas));this.ctx.drawImage(s,0,0,i,r,0,0,i,r),this.img.setAttribute("src",this.canvas.toDataURL(this.webp,this.q))}t()}catch(t){e(t)}})}_getEffect(t,e){return this.effects!==n&&!0!==e||(this.effects=this.img.getAttribute("data-tf-effects"),this.effects=this.effects?JSON.parse(this.effects):{},this.effects=new Map(Object.entries(this.effects))),t?this.effects.get(t):this.effects}_setEffect(t,e){this.effects=this._getEffect(!1,!0),e!==n&&!1!==e&&""!==e&&("object"!=typeof e||0<Object.keys(e).length)?this.effects.set(t,e):this.effects.delete(t),0<this.effects.size?this.img.setAttribute("data-tf-effects",JSON.stringify(Object.fromEntries(this.effects))):this.img.removeAttribute("data-tf-effects")}updateEffects(){this._getEffect(!1,!0)}_applyEfects(t){return new Promise(t=>{this.effects=this._getEffect(),t()})}save(t,s){return new Promise((i,r)=>{this.prms.then(()=>{s=s||this.webp,this.canvas.toBlob(t=>{try{const e=URL.createObjectURL(t,s);this.img.tfOn("load",()=>{const t=a.get(this.img);t&&URL.revokeObjectURL(t),a.set(this.img,e),i(e)},{passive:!0,once:!0}),this.img.src=e}catch(t){r(t)}},s,t)}).catch(r)})}calculate(t,e){let i=t=t&&Math.trunc(t),r=e=e&&Math.trunc(e),s,a;i=i||(t=Math.trunc(r*this.aspectRatio)),r=r||(e=Math.trunc(i/this.aspectRatio));const o=i/this.w,h=r/this.h,c=h<o?o:h,n=(s=i/c+.5>>0,a=r/c+.5>>0,(this.w-s)/2>>0),l=(this.h-a)/2>>0;return{x:n,y:l,w:s,h:a}}},(t,e,i,r)=>{if(!e&&!i)return Promise.resolve();let s=new ThemifyImageResize(t,1),a;return!0===s.isLocal&&!0!==s.isBig&&t.isConnected&&((a=o.createElement("span")).className="tf_loader tf_abs_c",t.after(a)),(r?s.toBlob(e,i,1):s.resize(e,i,1)).finally(()=>{a&&(a.remove(),a=null),s.canvas&&(s.ctx.clearRect(0,0,s.canvas.width,s.canvas.height),s.canvas=s.tmpImg=s.origImg=s.ctx=null),s=null})});ThemifyImageResize.toBlob=(t,e,i)=>r(t,e,i,!0),ThemifyImageResize.resize=r,ThemifyImageResize.clear=i=>{for(let[t,e]of a)!0!==i&&t.isConnected||(URL.revokeObjectURL(e),a.delete(t))},setInterval(ThemifyImageResize.clear,18e4)})(Themify,document,void 0);
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка