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
For license info of this project and related components see
<ahref="https://github.com/knicknic/WASM-ImageMagick">https://github.com/knicknic/WASM-ImageMagick</a><BR><p>Source image: </p><imgid="srcImage" src="rotate.png"><BR><br><p>Rotated and enlarged image: </p><imgid="rotatedImage"><scriptsrc="./magick.js"></script><script>letprocessFiles2=function(file,args){if(!Module.moduleLoaded){return}stdout.splice(0,stdout.length)stderr.splice(0,stderr.length)exitCode=undefined;FS.writeFile(file.name,file.content);Module.callMain(args);FS.unlink(file.name);letdir=FS.open('/pictures');letfiles=dir.node.contents;letresponseFiles=[];for(letdestFilenameinfiles){letprocessed={}processed.name=destFilenameletread=FS.readFile(destFilename)// cleanup read fileFS.unlink(destFilename)processed.blob=newBlob([read])responseFiles.push(processed)};returnresponseFiles;};letDoMagickCall=asyncfunction(){leturl="rotate.png";letsourceBytes=newUint8Array(await(awaitfetch(url)).arrayBuffer());letname=url.split('/').pop();constcommand=["convert","-debug","configure",name,"out.webp"];letprocessedFiles=processFiles2({'name': name,'content': sourceBytes},command);letfirstOutputImage=processedFiles[0];rotatedImage.src=URL.createObjectURL(firstOutputImage['blob']);console.log("created image "+firstOutputImage['name'])};Module.onRuntimeInitialized=function(){FS.mkdir('/pictures')FS.currentPath='/pictures'Module.moduleLoaded=trueDoMagickCall()}</script>
The text was updated successfully, but these errors were encountered:
You can convert png to webp directly in your browser thanks to a canvas, for instance:
// Your image is a png (or in another known format by your browser)letimg=document.querySelector('#my_image');letcanvas=document.createElement("canvas");canvas.width=img.width;canvas.height=img.height;letctx=canvas.getContext("2d");ctx.drawImage(img,0,0);img.src=canvas.toDataURL('image/webp');// Now the image is a webp...
I think ImageMagick is not very interesting for such conversion, and in fact this version was not compiled with this option.
The text was updated successfully, but these errors were encountered: