Did I not get enough sleep or what? This following code
var frame=document.getElementById(\"viewer\"); frame.width=100; frame.height=100; var ctx=frame.getC
I'm using fabric.js and could resolve this by using toDatalessJSON instead of toDataURL:
canvas.toDatalessJSON({ format: 'jpeg' }).objects[0].src
Edit: Nevermind. This results in just the background image being exported to JPG, without the drawing on top so it was not entirely useful after all.