Skip to content Skip to sidebar Skip to footer

Glide - Download And Resize Gif Into A File

I need to download a GIF and save it to external storage so I can send it via MMS.Messages have a limit 300kb and most of the GIFs are too large so I need to resize them. I am usin

Solution 1:

you can do compress that file also and then store in database this link will help you. in this first convert .gif to .png then use it. Android - Best way to convert .gif to .png

Solution 2:

Asked the same question on Glide Github and got the answer there. Apparently Glide will only resize images that are larger than 500 x 500, unless a fitCenter() (or any other) transformation is used.

So, to resize the .gif file, use this code:

byte[] bytes = Glide.with(context)
                        .load(url)
                        .asGif()
                        .toBytes()
                        .transform(new GifDrawableTransformation(new CenterCrop(context), Glide.get(context).getBitmapPool()))
                        .into(250, 250)
                        .get();

Post a Comment for "Glide - Download And Resize Gif Into A File"