Display Animated Gif

Display Animated GIF

Android actually can decode and display animated GIFs, using android.graphics.Movie class.

This is not too much documented, but is in SDK Reference. Moreover, it is used in Samples in ApiDemos in BitmapDecode example with some animated flag.

How to animate GIFs in HTML document?

By default browser always plays animated gifs, and you can't change that behavior. If the gif image does not animate there can be 2 ways to look: something wrong with the browser, something wrong with the image. Then to exclude the first variant just check trusted image in your browser (run snippet below, this gif definitely animated and works in all browsers).

Your code looks OK.
Can you check if this snippet is animated for you?

If YES, then something is bad with your gif, if NO something is wrong with your browser.

<img src="http://i.stack.imgur.com/SBv4T.gif" alt="this slowpoke moves"  width="250" />

Is it possible to display animated gif in jetpack?

Apparently Compose is not supporting gif out of the box, I could not find any reference to gif files in the docs. However, one of the popular library out there to deal with gifs is Coil.

-> Here is coil for Compose:
https://coil-kt.github.io/coil/compose/

-> Make sure to add the gif extension:
https://coil-kt.github.io/coil/gifs/

-> You will have to override the ImageLoader and add the gif extension:
https://coil-kt.github.io/coil/compose/#localimageloader

Is it possible to embed animated GIFs in PDFs?

I haven't tested it but apparently you can add quicktime animations to a pdf (no idea why). So the solution would be to export the animated gif to quicktime and add it to the pdf.

Here the solution that apparently works:

  1. Open the GIF in Quicktime and save as MOV (Apparently it works with other formats too, you'll have to try it out).
  2. Insert the MOV into the PDF (with Adobe InDesign (make sure to set Object> Interactive> film options > Embed in PDF) - It should work with Adobe Acrobat Pro DC too: see link
  3. Save the PDF.

See this link (German)

ImageMagick Animated GIF not working correctly

You need to coalesce your frames in Imagemagick before resizing in your command. So try

convert elephant.gif -strip -coalesce -resize 600x600 -layers optimize x.gif

Sample Image

How do I display an animated gif in React Native?

For RN < 0.60

By default the Gif images are not supported in android react native app.
You need to set use Fresco to display the gif images.
The code:

Edit your android/app/build.gradle file and add the following code:

dependencies: { 

...

compile 'com.facebook.fresco:fresco:1.+'

// For animated GIF support
compile 'com.facebook.fresco:animated-gif:1.+'

// For WebP support, including animated WebP
compile 'com.facebook.fresco:animated-webp:1.+'
compile 'com.facebook.fresco:webpsupport:1.+'
}

then you need to bundle the app again, You can display the gif images in two ways like this.

1-> <Image 
source={require('./../images/load.gif')}
style={{width: 100, height: 100 }}
/>

2-> <Image
source={{uri: 'http://www.clicktorelease.com/code/gif/1.gif'}}
style={{width: 100, height:100 }}
/>

For RN >= 0.60

implementation 'com.facebook.fresco:animated-gif:1.12.0' //instead of

implementation 'com.facebook.fresco:animated-gif:2.0.0' //use

I hope it is helpful to others,



Related Topics



Leave a reply



Submit