I’ve already checked out this question (App size is too big because of too many images)
I used tinypng.com like it suggested for my images, and yet my files are still way too big, and with so many of them, my app is looking at possible gigs in size.
Essentially my plan is to have a car quiz type game, where simply I have an image of just about every car ever made(gotten through public domain off wikicommons), photoshop all the badges off(which I’ve already done over a thousand of), and you try and see if you can still guess the car.
Accounting for iPad Retina resolution, I’m seeing that this app will be huge in terms of memory space.
The average photo reduced is about 300kb. Does that seem high?
How can I make an ios app that has thousands of decent quality images?
Would I have to create some over the air database or something? I don’t know anything about that.
Also I’ve only been coding for about a year, so if there’s anything code related that might help, let me know.
Any tips or tricks would be greatly appreciated. Thank you!
4
Answers
You probably don’t need a database or some robust online system for organizing and retrieving your photos, though it’s obvious that storing all these files on the device is not going to work.
Purchase webhosting. For $5 a month you can get unlimited online storage and bandwidth. Godaddy, Bluehost, Hostgator, Dreamhost, etc…
Use one of their online file managers, or download a free FTP (file transfer protocol) client like Filezilla.
Using their online file manager, or connecting with FileZilla, just transfer your images onto the webserver.
Then, with a list of URLs in hand linking you to your car images, use the code below to load an image from a URL:
NSURL *url = [NSURL URLWithString:path];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[UIImage alloc] initWithData:data cache:NO];
** When you’re displaying an interface that relies on downloading information or photos, you should be showing some placeholder (“Loading…,” a box, or a “loading spinner”) where the content will go that stays until the image is downloaded.
I had a very similar issue. You may not be making the same mistake, but I will share anyway.
I was making images in Photoshop with very large dimensions, and I would just scale them down to the necessary size in Xcode’s storyboard.
This was causing each image to be unnecessarily large in file size.
Therefore, the solution was to shrink each image to the precise dimensions needed for the application before uploading to Xcode.
This reduced the memory usage by images a whole lot.
have a look at this link, should provide the information how to download the images inside the app.
I already used
AFNetworking
which is really easy to handle. If you want to use it, have a look at the class:and check the method
setImageWithURLRequest:placeholderImage:success:failure:
For saving the
UIImage
after downloading, you could use this method and safe them local inside the apps directory. I think it would be the simplest way. If it will get bigger you could try to use asqlite
to store the paths of theUIImages
.You should probably use System File to store your images and save the path in the Database because:
Database storage is usually more expensive than file system storage
Difference of size of your photos can dramatically increase row sizes.
The best practise is then to name your images as the according primary key.