bumptech / bumptech/glide

Request: add callback for when Glide got the metadata of the source image (resolution, mimetype,...)

Open
#5,491 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
35k
Forks
6.2k
Avg merge
1d 11h
Merged PRs (30d)
8

Description

I use Glide this way:

```
Glide.with(applicationContext).asBitmap()
.load(imageResId)
.override(someWidth, someHeight)
.diskCacheStrategy(DiskCacheStrategy.NONE)
.addListener(object : RequestListener {
override fun onLoadFailed(e: GlideException?, model: Any?, target: com.bumptech.glide.request.target.Target, isFirstResource: Boolean): Boolean {
return false
}

@WorkerThread
override fun onResourceReady(bitmap: Bitmap, model: Any, target: Target?, dataSource: DataSource, isFirstResource: Boolean): Boolean {
//do something with the image
return true
}
}).submit()
```

Thing is, I also need to get the original size (AKA resolution, meaning width&height in pixels ) of the image, and maybe even the rest of the metadata (mimetype,...).
I've noticed there are some questions/requests about it (examples [here](https://github.com/bumptech/glide/issues/781) and also on StackOverflow, [here](https://stackoverflow.com/q/47827015/878126)), but I can't find one that actually covers it and "hooks" to what Glide does.
It's important to use what Glide does because:
1. Efficiency. No reason to decode what the image tells about itself twice.
2. Glide supports plugins to handle images that Android doesn't support on various Android OS versions (AVIF, JPEGXL, etc...)

Can you please add a callback (or offer a change to onResourceReady) so that I could get the image original size (and maybe other metadata too) ?
One that won't affect Glide globally, but just here in this call?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.