I am trying to save html5 canvas data to server using base64 + phonegap 2.5.
platforms : windows phone 7 and 8 , Android and IOS.
Basic need for image resizing is to optimize data before send over server.
I am having issue with android platform base64 response method which are as follows
Problems :
c.toDataURL("image/jpeg");
but i got this data:image/png;base64
Am I doing anything wrong ?
toDataURL() method returns a data URL containing a representation of the image in the format specified by the type parameter. The desired file format and image quality may be specified. If the file format is not specified, or if the given format is not supported, then the data will be exported as image/png .
If you wish to make the user download the file as it is saved you can do the following: var canvas = document. getElementById("mycanvas"); var image = canvas. toDataURL("image/png").
canvas.toDataURL is not supported in old Android versions.
There's a js fix for that but performance might not be very good: https://code.google.com/p/todataurl-png-js/
Check here for more info: toDataURL not working on android browsers
Android 4.x supports canvas.toDataURL; however, it doesn't support jpeg format (if you ask for a jpeg, it will return a png).
More details: https://github.com/scottjehl/Device-Bugs/issues/33
Only image/png
is supported by old browsers (WebKits) and this is the only codec you can rely to be present. img/jpeg
get added later on and is still not supported by many browsers.
For Android 2.3: try if you can do it in vanilla browser. If it works there then it is a PhoneGap issue and should be reported to the authors.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With