Do I need to provide images with different sizes if I extract them using Picasso or Glide or Volley?

This is usually better if we provide an image in different densities (sdpi, mdpi, hdpi, xhdpi, etc.). Do I need to provide the same if I get it from the server using some kind of library (Picasso, Glide, Volley, etc.), Or should I just provide the original image and the library will convert it to the appropriate size and density my application?

Note. If I provide images with different sizes or densities, I do not extract them all. I simply extract all the URLs of the images and just download once from them. Is it better, or is it better to provide one original image URL and get it and resize to the appropriate size?

+4
source share
5 answers

It depends on the goals. For example, if you need to show only a small profile picture, for example:

Item from friends list

you only need to have small images on the side of your server, this will reduce memory usage, network usage and time to display the image.

Another situation with large images. For instance:

Album picture

, .

, , , .

hdd, ImageLoaders . .

+2

, , . Google I/O 2014 .

Glide BaseGlideUrlLoader, , .

, Glide FlickrModelLoader Flickr API , , , .

BaseGlideUrlLoader :

public class ExampleUrlLoader extends BaseGlideUrlLoader<YourModel> {
    private static final int ORIGINAL_SIZE = -1;


    @Override
    protected String getUrl(YourModel model, int width, int height) {
       int maxSize = Math.max(width, height);
       final int size;
       if (maxSize > 800) {
           size = ORIGINAL_SIZE;
       } else if (maxSize > 400) {
           size = 800;
       } else if (maxSize > 200) {
           size = 400;
       } else if (maxSize > 50) {
           size = 200;
       } else {
           size = 50;
       }
       return model.getBaseUrl() + "&size=" + size;
    }
}

Glide GiphyModelLoader / Glide wiki .

+1

. , , , , OOM. hdd, , .

0

. ( OOM, Bojan

. , , . , , ( imho ), dpi

0
source

I think the only problem is image loading performance. If you upload an image that is larger than your image, the image will be resized, but you will use more data than is required for a smaller image upload. If you upload a smaller image, you will use less data, but image quality will be poor.

0
source

All Articles