canvas.toDataURL does not result in image/jpeg data

后端 未结 2 1254
广开言路
广开言路 2021-01-05 08:33

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

相关标签:
2条回答
  • 2021-01-05 09:04
    • Android 2.3 : I am unable to retrieve base64 data

    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.2 : I wrote this code c.toDataURL("image/jpeg"); but i got this data:image/png;base64

    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

    0 讨论(0)
  • 2021-01-05 09:09

    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.

    0 讨论(0)
提交回复
热议问题