4

I'm having trouble getting my canvas to give me a gif that I can submit to a post.

When I run toDataURL("image/gif") and check the result, it is actually a PNG.

The image drawn was a jpeg originally.

Tested in chrome 58 and firefox 50.

Is there a trick to it? or do I need another library to convert it?

My goal is to try and save as much data as possible. I tested just using MS Paint and GIF over PNG saves about 30% (over the PNG the canvas created), and the images this is for are black and white, so no quality loss at all.

Thanks in advance for the help!

-Edit

That link doesn't explain how to get the canvas to give me a gif instead of a PNG. Only how to read a data URL out of a file.

Trevor
  • 2,792
  • 1
  • 30
  • 43
  • Possible duplicate of [HTML5 Canvas toDataUrl - Upload gif workaround](https://stackoverflow.com/questions/31280897/html5-canvas-todataurl-upload-gif-workaround) – mjw Jun 23 '17 at 21:00
  • 1
    That link doesn't explain how to get the canvas to give me a gif instead of a PNG. Only how to read a data URL out of a file. The original drawn image is a jpeg or png. – Trevor Jun 23 '17 at 21:08
  • 1
    You'll need an other lib, no browser I know do support natively exporting to gif. – Kaiido Jun 24 '17 at 01:33

0 Answers0