showing results for - "javascript create gif from images"
Claudio
14 Apr 2019
1
2You cannot create GIFs natively using canvas but you can use a libray called JSGif to do this:
3https://github.com/antimatter15/jsgif
4
5From the read me file:
6
7Now we need to init the GIFEncoder.
8
9var encoder = new GIFEncoder();
10If you are making an animated gif, you need to add the following
11
12encoder.setRepeat(0); //0  -> loop forever
13                      //1+ -> loop n times then stop
14encoder.setDelay(500); //go to next frame every n milliseconds
15Now, you need to tell the magical thing that you're gonna start inserting frames (even if it's only one).
16
17encoder.start();
18And for the part that took the longest to port: adding a real frame.
19
20encoder.addFrame(context);
21For more details check out its documentation