Reputation: 743
I use Jsoup to read the website. But in html not all images have size information. So, if it is not there, I want to find out the image size in some other way, using the image source URL.
Upvotes: 0
Views: 4685
Reputation: 89
/*this library*/
implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
/* this code */
Glide.with(this)
.asFile() // get size image url
.load("link image url")
.into(new SimpleTarget<File>() {
@Override
public void onResourceReady(@NonNull File resource, @Nullable
Transition<? super File> transition) {
fab_full.setLabelText(""+resource.length()); // /1024 kb
}
});
Upvotes: 0
Reputation: 2515
I would suggest use glide
dependencies {
implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
}
and then load your image url using glide
Glide.with(this)
.asBitmap()
.load(path)
.into(new CustomTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
int width = bitmap.getWidth();
int height = bitmap.getHeight()
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
}
});
Upvotes: 3