0

Using this code:

Picasso.with(context).load(url).resize(60, 60)

Does Picasso resize the image before it is downloaded? If the image was 8MB - I wouldn't want it to be downloaded then resized.

I couldnt find the answer anywhere but maybe it is obvious!

user3437721
  • 2,227
  • 4
  • 31
  • 61

1 Answers1

0

No, obviously it doesn't resize it before downloading - it's impossible. Look at the chaining, first - download, second - resizing. If you want to get a smaller images, you should ask for a smaller images if you have such a chance, of course. You can write graceful degradation: if the file size is bigger than limit, then just don't download it and display some placeholder instead. It can be implemented by checking content length at first:

URL url = new URL("http://server.com/file.png");
URLConnection urlConnection = url.openConnection();
urlConnection.connect();
int file_size = urlConnection.getContentLength();

Taken from here How to know the size of a file before downloading it?

Community
  • 1
  • 1
nikis
  • 11,166
  • 2
  • 35
  • 45
  • Thanks I guess I thought you could decode the stream to a certain size on the fly. Do you know if there is a way for Picasso to accept an Array of Bitmaps instead? Rather than URLS? – user3437721 Apr 08 '14 at 09:38
  • @user3437721 afaik you have to load images one by one using the same `load` method, but by providing path to image or it's id http://square.github.io/picasso/javadoc/index.html It can be done via loop – nikis Apr 08 '14 at 09:44