jakubfiala / atrament

A small JS library for beautiful drawing and handwriting on the HTML Canvas.
http://fiala.space/atrament/demo
MIT License
1.56k stars 115 forks source link

saving and opening a drawing #27

Closed ghost closed 7 years ago

ghost commented 7 years ago

Hi,

I am not sure is this is a bug or not, but when I save a drawing, I cannot open it with the default image viewer of windows (Windows 10). However I can open it with MS paint and others. Therefore I wonder if there is something wrong with the generated image.

I get the image using the toimage() method and then I use python to save the generated image as:

with open("imageToSave2.png", "wb") as f:
    f.write(image_string[22:].decode('base64'))

I have followed this method to save the images generated by other JS drawing libraries, and I can open them with the windows image viewer.

jakubfiala commented 7 years ago

hey, so the toImage method simply wraps the toDataURL method of the canvas. Not to say that this is not a valid issue, but I wonder if this has something to do with the browser implementation of the canvas method.

ghost commented 7 years ago

I see, the other library that I tested is https://github.com/Leimi/drawingboard.js. For some reason theirs seem to work with the windows image viewer, but it seems they are just also wrapping toDataURL.