Yes, it is possible to generate a png
from a div and it is also possible to download an image from your div.
If your image is in PNG, just use this form (with pure js).
// Botãod de Download
var btn = document.querySelector("button");
// Captura o elemento de imagem
var img = document.querySelector(".fundo");
// Adiciona o evento para baixar a imagem.
btn.addEventListener("click", function(){
// Cria um elemento <a> e define o href a ele
var anchor = document.createElement("a");
anchor.setAttribute("href", img.src);
anchor.setAttribute("download", true);
// Adiciona esse <a> no body do documento
document.body.append(anchor);
// Aciona o evento click
anchor.click();
// Remove o <a> do body
document.body.removeChild(anchor);
})
<div>
<img src='http://www.epica.nl/epica_tss_fb_share.png' class='fundo' width="300" />
</div>
<button>Download</button>
Generate png download from a div?
As mentioned above, to generate a png
from a div, use the html2canvas.
that part is hard Emm...
– OptimusDesesperado
Do not change the whole meaning of the question. If you want you can ask another question.
– Sam