Create Gif animated. Extension

Hello friends,

with this extension we can create an animated GIF by adding static images.

Blocks:

  • Start: Output file name. Example: /mnt/sdcard/my_gif.gif

  • SetRepeat: Sets the number of times the set of GIF frames should be played. Default is 1; 0 means play indefinitely. Must be invoked before the first image is added.

  • AddFrame: Adds next GIF frame. The frame is not written immediately, but is actually deferred until the next frame is received so that timing data can be inserted. Invoking ‘Finish’ flushes all frames. Example: /mnt/sdcard/animales/gato.png

  • SetDelay: Sets the delay time between each frame, or changes it for subsequent frames, applies to last frame added.

  • Finish: Flushes any pending data and closes output file.

  • CopyAssets: Copy all files .png, .jpg and .gif from asset to dir. Example: /mnt/sdcard/my_directory

  • I have not used the block: SetTransparent.

This extension is an adaptation of:
https://github.com/nbadal/android-gif-encoder/blob/master/GifEncoder.java

p193C_crear_gif_animado.aia (32.5 KB)

You can get com.KIO4_GifEncoder.aix file from:
http://kio4.com/appinventor/293C_extension_crear_gif_animado.htm

More extensions:
http://kio4.com/appinventor/index.htm#extensiones

Regards,
Juan A. Villalpando.

7 Likes

thumbsup2

Here is another example usage:

Using the Component 2 Image extension to collect a set of canvas images, then convert these images to a gif using Juan’s Create Gif extension

AIA

CanvasGiffer.aia (42.6 KB)

Blocks

1 Like

Interesting project. Is it possible to “convertToImage” and immediately AddFrame to gif?

Well it works :slight_smile:

Doing things in sequence,

  • convert component to image
  • after image created add image to frame
  • go again

muy buena!!

Thanks! I was about to make a post about gifs not animating!

you can convert all these gif to jpgs and upload them and make a timer for them and it will work too instead of using extensions.

Yes, that is an old method (2013). Here Scott Ferguson again:

https://groups.google.com/forum/m/#!topic/app-inventor-developers-library/nib7B1J0mhc