Libraries like html2canvas
take HTML and convert it to a canvas
element. Then toDataURL()
can be used to get a URL (data:image/png...
). So, is there a way to convert HTML to an actual PNG Image in the browser (not the data
url)? I don't want the user to download it, just get a PNG (so that if I save that to a file, I can open the image directly). PNG or JPEG or any small image storing format can be used. My target is modern browsers (not IE).
EDIT
I want to take images of the HTML, convert them to PNG and then combine them client-side (using ffmpeg.wasm), not just display the images. Most of the answers and suggestions on StackOverflow tell you how to display the images using the image.src
attribute. It doesn't have to be a PNG, just any format that ffmpeg.wasm
can support (though PNG is preferred)