kviksilver
kviksilver

Reputation: 3854

Downloading large amount of images, making it faster

I need help with downloading from webserver... What i currently do is get XML file from web servers that contains image locations, parse XML, download each image, store image on iphone, and store image name to sql database. This takes lots of time because there is large amount of images to be downloaded and i am downloading one by one.

My app update just got rejected because reviewer decieded that downloading is too long... What is funny, last two updates passed without problems..

I was thinking about zipping those images on server and sending zip file to iphone, unzipping it there, or packing images together with binary and sending it to apple.

Any advice on how to make download faster, would be appreciated. Thanks.

Upvotes: 1

Views: 1436

Answers (5)

1) I would use something like an NSOperationQueue to download around three images at a time in the background. Much more than that and the UI starts getting choppy.

2) Also display some kind of loading indicator while this is going on.

3) What format are your images in? If you are transferring over the network you should use JPG, and consider setting the quality level to something smaller (say 6 even 5). To offset the loss of quality you could send down larger images, even with the larger number of pixels you can easily be better off with a lower quality compression.

4) If you have to use PNG to preserve transparency, consider using PNGCrush on the images before sending. As noted, zip will do pretty much nothing.

Upvotes: 1

David Liu
David Liu

Reputation: 9601

Likely, your images are just way too large. You said you're worried about the 20MB app limit, but I think at that point, your images are just way too large for the phone.

Rather than zipping the files, I'm pretty sure you need to downsample the size of the images. Not only that, but you should only download the ones that you need, when you need them.

If you still want to have bulk downloads, why not have it as a side option rather than the default implementation?

Upvotes: 0

joelm
joelm

Reputation: 8771

BTW, zip won't help with images. They are already compressed, so it will just add overhead. Make sure your images are not any larger than you need for display and I'd do what Mario suggested above and download them in multiple async calls (at least make the one big call asynchronous.)

A key principle of UI design is to display partial results (unless they are invalid or misleading) so that the user understands that progress is being made.

If you really need all the images to make it valid, you can download a few and display them grayed out (alpha = 0.4) or something so that it's clear that this is a partial result, but that progress is being made. The reviewer probably felt that it was taking too long to startup.

Upvotes: 3

Chris Henry
Chris Henry

Reputation: 12010

One way to speed up download of those images is to put them on a CDN. Some CDNs, like Limelight have special network optimizations for sending data to mobile devices. They also just do a better job of routing content, and have higher capacity for transmitting content. What's nice about this approach is that you might not have to change your app. However CDNs can be pricy.

Upvotes: 0

Mario
Mario

Reputation: 36477

Do you change those images often? Or only once per release if at all? If they change with each release only I'd package them. If they're almost never changed, go with the one huge download (so people don't have to redownload when updating) and if they're change often, download them file by file but try to do 2-3 files at once using asynchronous download (if supported).

Upvotes: 1

Related Questions