When adding an image annotation or a stamp, when saving, the stamp shows Draft instead of the image

What is image selection?

stampAnnot.setImageData(imageSelection, keepAsSVG);

And you should uncomment that line?

stampAnnot.ImageData = document.getElementById("myCanvas").toDataURL();