PageSourceSearch

https://ninjatransfers.com/cdn/shop/t/1064/assets/nt-measure.js?au…&v=179784408356161663111786494393

js ninjatransfers.com collected 2026-09-24 18:07:48 UTC 3,524 bytes, 2 lines download raw bytes

1(function(){"use strict";if(window.NTMeasure)return;var API_URL="https://hpz51rjda5.execute-api.us-east-1.amazonaws.com/production",PRINT_DPI=300,RENDER_DPI={vector:72,raster:300},VECTOR_EXTS=["eps","ai","svg","pdf"],SERVICE_EXTS=["psd"],ALPHA_THRESHOLD=16,BBOX_RENDER_MAX_W=1600,frameCache={};function loadImage(url,needPixels){return new Promise(function(resolve,reject){var img=new Image;needPixels&&(img.crossOrigin="anonymous"),img.onload=function(){resolve(img)},img.onerror=function(){reject(new Error("nt-measure: image failed to load: "+url))},img.src=url})}function scanAlphaBBox(img){var w=img.naturalWidth,h=img.naturalHeight;if(!w||!h)return null;var canvas=document.createElement("canvas");canvas.width=w,canvas.height=h;var ctx=canvas.getContext("2d");ctx.drawImage(img,0,0);var data;try{data=ctx.getImageData(0,0,w,h).data}catch(e){return null}for(var minX=w,maxX=-1,minY=h,maxY=-1,y=0;y<h;y++)for(var rowStart=y*w*4,x=0;x<w;x++)data[rowStart+x*4+3]>ALPHA_THRESHOLD&&(x<minX&&(minX=x),x>maxX&&(maxX=x),y<minY&&(minY=y),y>maxY&&(maxY=y));return maxX<0?null:{w:maxX-minX+1,h:maxY-minY+1,frameW:w,frameH:h}}function serviceInches(s3Key){return fetch(API_URL+"/calculateInches?s3Key="+encodeURI(s3Key)).then(function(r){return r.json()}).then(function(res){return res&&res.success===!0&&res.data&&res.data.dimensions&&res.data.dimensions.width&&res.data.dimensions.height?{inW:res.data.dimensions.width,inH:res.data.dimensions.height}:null}).catch(function(){return null})}function sourceFrame(imgixUrl){return frameCache[imgixUrl]?Promise.resolve(frameCache[imgixUrl]):loadImage(imgixUrl).then(function(img){var f={w:img.naturalWidth,h:img.naturalHeight};return frameCache[imgixUrl]=f,f})}function fromInches(inW,inH,method){return{pxW:Math.round(inW*PRINT_DPI),pxH:Math.round(inH*PRINT_DPI),inW:inW,inH:inH,method:method}}function trimMeasure(imgixUrl,dpi,method){var params=dpi===RENDER_DPI.vector?"?trim=colorUnlessAlpha&fm=png":"?trim=colorUnlessAlpha";return loadImage(imgixUrl+params).then(function(img){return!img.naturalWidth||!img.naturalHeight?null:fromInches(img.naturalWidth/dpi,img.naturalHeight/dpi,method)})}function bgRemovedMeasure(imgixUrl,modelParam){return sourceFrame(imgixUrl).then(function(frame){if(!frame.w||!frame.h)return null;var renderW=Math.min(BBOX_RENDER_MAX_W,frame.w),url=imgixUrl+"?bg-remove=true"+(modelParam?"&bg-remove-model="+modelParam:"")+"&fm=png&w="+renderW;return loadImage(url,!0).then(function(img){var bbox=scanAlphaBBox(img);if(!bbox)return null;var contentSrcW=bbox.w*(frame.w/bbox.frameW),contentSrcH=bbox.h*(frame.h/bbox.frameH);return fromInches(contentSrcW/RENDER_DPI.raster,contentSrcH/RENDER_DPI.raster,"raster-bgr-bbox")})})}function measure(opts){var ext=String(opts.ext||"").toLowerCase(),run;return SERVICE_EXTS.indexOf(ext)!==-1?run=serviceInches(opts.s3Key).then(function(r){return r?fromInches(r.inW,r.inH,"service-s3key"):null}):VECTOR_EXTS.indexOf(ext)!==-1?run=trimMeasure(opts.imgixUrl,RENDER_DPI.vector,"vector-72"):opts.bgRemove?run=bgRemovedMeasure(opts.imgixUrl,opts.bgRemoveModel).catch(function(){return null}).then(function(r){return r||trimMeasure(opts.imgixUrl,RENDER_DPI.raster,"raster-trim-fallback")}):run=trimMeasure(opts.imgixUrl,RENDER_DPI.raster,"raster-trim"),run.catch(function(err){return console.log("ERROR NTMeasure.measure",err&&err.message),null})}window.NTMeasure=Object.freeze({measure:measure})})();
2//# sourceMappingURL=/cdn/shop/t/1064/assets/nt-measure.js.map?auto=format%2Ccompress&v=179784408356161663111786494393

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.