Gif Dynamic Resizing (Blurry Gifs)
- Dominant language
- Java
- Stars
- 35k
- Forks
- 6.2k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 8
Description
**Glide Version**: 4.12.0
**Integration libraries**: okhttp3-4.8.1
**Device/Android Version**: Affects all devices/OSs
**Issue details / Repro steps / Use case background**:
Gifs come down from content management system and are loaded into a custom defined component. The gif's width should be set to fill the width of the screen while the height should dynamically adjust to fit the aspect ratio of the image.
Issue is: `Glide.asGif()` call is forcing me to use `override(width, height)` method or else the gif method doesn't work and nothing is displayed. I don't want to force this width and height and need it to be dynamic because all the data can vary in aspect ratio. When I added the override width and height (only way for me to get the feature to work) the gifs ended up coming out blurry because I set them statically to 300 x 300 in the override. How do I have glide just return them based on the size they are already defined?
**Glide load line / `GlideModule` (if any) / list Adapter code (if any)**:
```kotlin
fun ImageView.loadGif(
context: Context,
imageUrl: String,
onResourceReady: () -> Unit,
onLoadFailed: (e: GlideException?) -> Unit
) {
Glide.with(context)
.asGif()
.load(imageUrl)
.override(GIF_WIDTH, GIF_HEIGHT) // 300 x 300
.listener(object : RequestListener {
override fun onResourceReady(
resource: GifDrawable?,
model: Any?,
target: Target?,
dataSource: DataSource?,
isFirstResource: Boolean
): Boolean {
onResourceReady()
return false
}
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: Target?,
isFirstResource: Boolean
): Boolean {
onLoadFailed(e)
return false
}
})
.into(this)
```
**Layout XML**:
```xml
......
```
App:
https://user-images.githubusercontent.com/82335757/138475358-b16affd9-d81a-4e21-99fd-89b7455a05ef.mp4
Original Asset:

Contributor guide
Assessment
This issue has not been assessed yet.