Saving the image

To save the image on the server you have to get the image data from the painter and send it to ther server.

You can get the image data using the painter method getImageData(options).

    var imageData = painter.getImageData();

This method returns the image as JavaScript string having data URI format:

    data:image/png;base64,<...data...>

Example:

    data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAA
    AHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==

Then you can send the obtained string to the server using a hidden field in an HTML form or using AJAX.
Your server-side script will have to decode the data and convert it to binary image file (if necessary) or save it on the server as is.