Fresco: First frame of animated GIF as placeholder image?

Created on 22 Jul 2015  路  26Comments  路  Source: facebook/fresco

Is there a way to use the first frame of an animated GIF as the placeholder image for a view? This would ease the visual transition when loading (and reloading) animated GIFs.

If not, I would love to see this added as a feature!

enhancement help wanted

Most helpful comment

In case of showing cached gif, as a temporary workaround you can save first gif frame and then use it as lowresImage while huge gif is loading from disk

@Override
        public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
            if (imageInfo instanceof CloseableAnimatedImage) {
                GifImage gif = (GifImage) imageInfo.getImageResult().getImage();
                if (gif != null) {
                    Bitmap bitmap = Bitmap.createBitmap(imageInfo.getWidth(), imageInfo.getHeight(), Bitmap.Config.ARGB_8888);
                    gif.getFrame(0).renderFrame(imageInfo.getWidth(),  imageInfo.getHeight(), bitmap);
                    //save bitmap in your own cache
                    bitmap.recycle();
                }
            }
}

All 26 comments

I'm afraid this isn't possible at the moment - we'll see if there's a lot of demand for this feature.

Great, thanks!

It would be very nice to have this feature

+1

+1

In case of showing cached gif, as a temporary workaround you can save first gif frame and then use it as lowresImage while huge gif is loading from disk

@Override
        public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
            if (imageInfo instanceof CloseableAnimatedImage) {
                GifImage gif = (GifImage) imageInfo.getImageResult().getImage();
                if (gif != null) {
                    Bitmap bitmap = Bitmap.createBitmap(imageInfo.getWidth(), imageInfo.getHeight(), Bitmap.Config.ARGB_8888);
                    gif.getFrame(0).renderFrame(imageInfo.getWidth(),  imageInfo.getHeight(), bitmap);
                    //save bitmap in your own cache
                    bitmap.recycle();
                }
            }
}

+1

+1

  • 1

+1

+1

+1

+1

+1

+1

Still waiting for this feature!
+1

+1

I'm afraid that I have no update on this. However, we are always welcoming pull-requests that add support for this in a maintainable way :) @oprisnik is working on a new architecture for animations that hopefully make support for this easier

+1

+1

+1

We don't have a use case for this so we're probably not going to work on it internally. However, I think the use case is valid and it would be a good feature to have, so we would still appreciate a PR for this, even though I'm closing the issue now.

+1

Is this problem solved now?

+1

+1

Was this page helpful?
0 / 5 - 0 ratings