Need to reduce app size. Will this work?

Hi everyone,

I’m making an app that has a lot of images in it that are saved in .png format. This has caused my app size to be quite large. This is because I have 2 sets of images (regular and retina) for each image. I’ve tested the following method and it seems to work fine but wanted to know if this should work:

  
local picture = display.newImageRect("images/picture@2x.png", 768, 1024)  
  

So what I did here was remove the regular image and only included the retina image. When I load the image it points directly to the @2x image. Will this cause any issues? [import]uid: 31262 topic_id: 29213 reply_id: 329213[/import]

I believe the image selection will go with the best image for the file name you provide. in my experience, just leaving out the smaller image will cause the larger to be picked up without using @2 in the file name. [import]uid: 8271 topic_id: 29213 reply_id: 117484[/import]

I don’t see why not. Did you try it on an IPad2?

Another way to reduce the size of your PNGs substantially (20-30% for big ones) is to run them through the roptipng.exe that sits under your \Android\Android-SDK\other directory on your Windows PC - if you downloaded Android SDK. Not sure where the equivalent would be on a Mac.

On edit: roptipng.exe treatment of my PNG files caused some of them to show as white rectangles on iPad (while running fine in simulator). So - I guess roptiping.exe is not very useful here. [import]uid: 160496 topic_id: 29213 reply_id: 117475[/import]

I use this method for long time :slight_smile: BTW. Put as much as images you can in ImageSheet. App start a little longer but works faster. [import]uid: 12704 topic_id: 29213 reply_id: 117494[/import]

@gtatarkin, do you mean putting the images in a spritesheet? I believe it’s too late for that. I’m pretty far into the app but I can keep that in mind for the next one.

@horacebury, so if I just remove the regular image and just keep the @2x image, I don’t even need to use the above syntax? Just leave it as picture.png and it should do the same thing? If so that would be much easier. I will definitely test this.

Thanks for your replies guys. [import]uid: 31262 topic_id: 29213 reply_id: 117501[/import]

Yes - the ‘@2’ really is just for the SDK to know which file relates to which size. When you ask it to load an image, if it can’t find one with the appropriate size, it will go looking for the next file with the matching name and next-most appropriate size.

[EDIT] Actually, you can try this by using completely different images. While you should keep the dimensions the same, you can just put some coloured blob or draw text into the images. eg: in the @2 version you could draw ‘@2’ and then mess around deleting different images from your build. Try renaming the @2 to @4, for example, and see what happens when you reload the simulator. [import]uid: 8271 topic_id: 29213 reply_id: 117505[/import]

Just use one set of graphics and scale down your images :slight_smile: Works fine and looks great even on iPhone 3GS:
http://itunes.apple.com/us/app/eggz-saver-free/id504834805
http://itunes.apple.com/us/app/tower-blockz/id527050700?mt=8 [import]uid: 12704 topic_id: 29213 reply_id: 117507[/import]

Here’s an idea…

Put the smallest of your images in the app when you build, then have it give the user the option of downloading high quality images online. Copy the images from the resources directory into the temp directory or documents directory (disabling iCloud backup) and load from there. [import]uid: 8271 topic_id: 29213 reply_id: 117509[/import]

Thanks again guys [import]uid: 31262 topic_id: 29213 reply_id: 117573[/import]