MCPcopy Index your code
hub / github.com/hoothin/UserScripts / dataURLToCanvas

Function dataURLToCanvas

Picviewer CE+/dist.user.js:12384–12400  ·  view source on GitHub ↗
(dataurl, cb)

Source from the content-addressed store, hash-verified

12382 })
12383 };
12384 function dataURLToCanvas(dataurl, cb){
12385 if(!dataurl)return cb(null);
12386 var ctx = canvas.getContext('2d');
12387 var img = new Image();
12388 img.setAttribute("crossOrigin","anonymous");
12389 img.onload = function(){
12390 canvas.width = img.width;
12391 canvas.height = img.height;
12392 ctx.clearRect(0, 0, canvas.width, canvas.height);
12393 ctx.drawImage(img, 0, 0);
12394 cb(canvas);
12395 };
12396 img.onerror = function(){
12397 cb(null);
12398 };
12399 img.src = dataurl;
12400 }
12401 function urlToBlobWithFetch(urlString, cb){
12402 fetch(urlString).then(response => response.blob()).then(blob => {
12403 let ext = extFromMimeAndUrl(blob.type, urlString);

Callers 2

urlToBlobWithFetchFunction · 0.70
urlToBlobFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected