2

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!

Community
  • 1
  • 1
cnorth
  • 35
  • 7

4 Answers4

1

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.

  1. Purchase webhosting. For $5 a month you can get unlimited online storage and bandwidth. Godaddy, Bluehost, Hostgator, Dreamhost, etc...

  2. Use one of their online file managers, or download a free FTP (file transfer protocol) client like Filezilla.

  3. Using their online file manager, or connecting with FileZilla, just transfer your images onto the webserver.

  4. 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];

  5. ** 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.

Adama
  • 1,101
  • 8
  • 26
  • Wow okay. I see what you're saying. I'll let you know how it goes! – cnorth Mar 04 '15 at 23:51
  • George Poulos' comment might be of help too. Make sure you're not using images that are larger than they need to be. 300kb does sound a little too large for images on a handheld, but that may be right. – Adama Mar 04 '15 at 23:55
1

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:

#import <AFNetworking/UIImageView+AFNetworking.h>

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 a sqlite to store the paths of the UIImages.

Community
  • 1
  • 1
Alex Cio
  • 6,014
  • 5
  • 44
  • 74
  • Would I need to have my own website server to do this? – cnorth Mar 05 '15 at 00:08
  • Normally it would work the way @Adama described it. You just have to think about the users which will download your app, there must be a server who can handle this. But for the beginning I would recommend you to setup a localhost on your mac and download stuff from a local address. – Alex Cio Mar 05 '15 at 00:14
  • You mean just for testing right? But afterwards I'd need my own website? Would any website url off godaddy work or is their some special kind? – cnorth Mar 05 '15 at 00:21
  • No, we're not talking about a domain here. You need a provider to host you hardware where a server is set up (like apache f. e.) and you have an amount of webspace where you can save the images. You also would need to set up an api, where you send requests from the app and receive the image from. But maybe you have a look at parse.com . You should just know if the amount of request might get bigger, in the end you have to pay a lot of money in addition. – Alex Cio Mar 05 '15 at 00:34
  • I've looked at Parse, it appears to be free to a certain limit, but once you go over that limit it charges $200 a month, which is over my price range. I'd really like to make this app for as cheap as possible. So I'm looking at apache.org, are they the provider? Do I still need a domain name? I'm sorry, all this stuff is brand new to me. – cnorth Mar 05 '15 at 01:02
  • Check my account and send me a message on G+. – Alex Cio Mar 05 '15 at 09:16
0

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.

George Poulos
  • 539
  • 1
  • 6
  • 17
  • Well I want to make this for the iPad Retina as well, which is 2048 x 1536. At 300kb my image dimensions are 942x576. Does this seem right or necessary? (I also have it so you can pinch zoom the images for a better look) – cnorth Mar 05 '15 at 00:04
  • That seems right, assuming your image will take up about 1/3 of the screen. If not, there is room to decrease the dimension size. The only other thing I can recommend is to make sure you're exporting the image from photoshop as small as you can, like by making sure you're exporting the "optimized" png. If all this still leads to too much storage, you may have to take the advice of the other answers. – George Poulos Mar 05 '15 at 00:59
  • Yeah I got you. I'm going to have to use the other answers. It looks like this app just got a whole lot more complicated. – cnorth Mar 05 '15 at 01:11
0

You should probably use System File to store your images and save the path in the Database because:

  1. Database storage is usually more expensive than file system storage

  2. 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.

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
Toumi
  • 2,925
  • 4
  • 37
  • 31