0

So, i have tableview in my iOS app. i need to fill it with some images from web. At first to get those images from web i use:

NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.somepicture.jpg"]]; NSImage *image = [[UIImage alloc] initWithData:data];

but the problem is that those images are sometimes large, so i need to somehow compress that data before download it. I need images of about 85px x 85px.

So, my question is how to get those images from web by not downloading entire data. I am sure that there is solution, because i already made it in Java for Android. Or are any other ways to approach the problem.

Thanks for suggestions!

Jure Možina
  • 11
  • 1
  • 4

1 Answers1

1

There is no general way to do this. Some web sites may have thumbnails available of their images, but not all will. If thumbnails are available, there is no standard location or format that you will find them in, and there is no way to make an arbitrary web server create thumbnails for you either.

(There is no way to do this on Android either. You were probably just downloading the whole image and downscaling it.)

  • Thank you for you answer, in andorid i use this solution posted by Fedor, see the second answer: http://stackoverflow.com/questions/541966/android-how-do-i-do-a-lazy-load-of-images-in-listview/3068012#3068012 – Jure Možina Sep 20 '12 at 06:07
  • That's just downscaling the image -- see the `decodeFile()` function in `com.fedorvlasov.lazylist.ImageLoader`. It's downloaded at full resolution. –  Sep 20 '12 at 06:11
  • Yeah i know this, but i do not know how is than posible, when i download pic with this solution and i am measuring transfer data on phone is only around 150KB for 20 pic?!...the whole size of pics is around 1MB (sum of those pics on server)... – Jure Možina Sep 20 '12 at 06:34
  • Some of those images must have already been in your phone's cache. –  Sep 20 '12 at 15:38