You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.
Loading images on node can be tricky, requiring node-gyp and a couple libraries to help loading. Check out the readpixels.ts file in /spec/helpers for a potential implementation
Browsers
The easiest way to load the images on the browser is to rely on canvas and import them as a buffer something like this:
functionreadpixels(url,limit=0){constimg=newImage()constcanvas=document.createElement('canvas')constctx=canvas.getContext('2d')returnnewPromise((resolve,reject)=>{img.onload=()=>{const{ width, height }=getLimitDimensions(img.width,img.height,limit)if(width===0||height===0){returnreject('Failed to load image')}canvas.width=widthcanvas.height=heightctx.drawImage(img,0,0,img.width,img.height,0,0,width,height)returnresolve(ctx.getImageData(0,0,width,height))}img.onerror=rejectimg.src=url})}