<script>
	window.getEllipseImage = (sourceCanvas) => {
		const createdCanvas = document.createElement('canvas');
		const contextCanvas = createdCanvas.getContext('2d');
		const widthCanvas = sourceCanvas.width,
			heightCanvas = sourceCanvas.height;

		createdCanvas.width = widthCanvas;
		createdCanvas.height = heightCanvas;
		contextCanvas.imageSmoothingEnabled = true;

		contextCanvas.drawImage(sourceCanvas, 0, 0, widthCanvas, heightCanvas);
		contextCanvas.globalCompositeOperation = 'destination-in';
		contextCanvas.beginPath();
		contextCanvas.ellipse(widthCanvas / 2, heightCanvas / 2, widthCanvas / 2, heightCanvas / 2, 0 * Math.PI, 0, 180 * Math.PI, true);
		contextCanvas.fill();

		return createdCanvas.toDataURL("image/png", 1);
	}
</script >