Skip to content

Instantly share code, notes, and snippets.

@fffiloni
Created July 21, 2022 16:38
Show Gist options
  • Save fffiloni/e8ed10bdba4f4063639ba8e42ae4983d to your computer and use it in GitHub Desktop.
Save fffiloni/e8ed10bdba4f4063639ba8e42ae4983d to your computer and use it in GitHub Desktop.
Convert a blob to a p5 js image
let img_result;
let img_to_download;
function blobToGraphics(buffer){
// Create a blob from the buffer response
let myBlob = new Blob([buffer], {type: "image/png"});
console.log(myBlob);
let uri = URL.createObjectURL(myBlob);
img_result = createImg(uri,'','', function(){
img_to_download = loadImage(uri, function(){
console.log('image ready to download: press "S" to download it !"')
})
}).hide();
}
function draw(){
image(img_result, 0, 0, width, height);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment