Optimizing app question

Hi everyone,

I have a couple of questions that I am hoping someone can help with.  I am working on my first app and just did a test build.  I see that the file size comes in at over 100MB.  I would clearly like to do whatever I need to do to bring that down.

I am building this as a universal app, so obviously that will factor into the file size.  I am wondering if I really do need to include a 4x file size for retina displays.  That would do a lot to bring the size down some.  

Does anyone have any recommendations on what I can try?  I’ve looked for other articles and posts on this subject but haven’t really found anything.  I appreciate any advice.

Thanks!

Alan

Here are a few things you can do.

  1. Any image that does not need transparency (like backgrounds), save them as JPEG’s not PNG’s.  JPEG’s compress much smaller, but they don’t support transparency.  Since your backgrounds are likely to be your largest images, you can gain much here.

  2. Make sure that you “Save for Web or Devices” from Photoshop and you’re making sure to not save any color profile, EXIF, caption or other meta data.  You can have a 5K image turn into a 35K image quickly.  If you have a lot of these, it adds up.

  3. Use Image sheets where possible.  regardless of removing as much meta data as you can, you still have overhead that an be reduced.  If you use a tool like texture packer, you can get more information by fitting the images into tighter areas.

4.  For images that scale up nicely, skip the @4x versions.  But where quality matters you should keep them.

  1. For your audio, consider 11khz mono sounds over 44khz stereo.

Rob

Great advice.  Thanks!  And some great things to keep in mind in developing my next app.  Unfortunately, a lot my graphics have transparency, but shrinking down those that don’t was a good help.  Every mB counts.

Curious about the recommendation to use PNG over JPG, because from what I have seen in various forum posts, as far as memory goes, Android handles PNG images much better than JPG images.  Is that no longer the case?

Regardless of how you create PNG files, it would definitely be worth getting them shrunk using some of the external compressors (like PNGcrush) or this site: https://tinypng.com/

That can shrink the size of PNG files greatly.  I use all PNG files in my apps and after using the Tiny PNG site, mine got reduced by about 10MB.

One warning though, iOS devices sometimes display a white line at the bottom of compressed images.  Not sure why, and not on all images.  So if you do this, keep a backup of the images and test on iOS to see if you need to revert to the uncompressed versions for any.  Never saw the problem on Android, even with the same images used.

Wow!  That is some great advice!  I will have to try it out. Ten percent savings is significant.  I did compress a few static, non-transparent images as jpg’s and saw a huge difference in file size (from over 3 mB to about 600k) so that was a big help.  I would think that photoshop would do a good job at optimizing the files.  I’ll have to see what the difference is with tiny png.

Thanks for the advice.

One other thing that I noted is that, currently, my graphics are coming in at around 60 mB.  I’m going to go through and compress them, but should there be 40 mB of extra stuff just from the code?  My lua files (and there aren’t that many of them) don’t even come close to that.  What is the normal footprint of what Corona adds in when an app is compiled?

Sorry to add a question on to a thank you.  Just doing my best to understand this.

Thanks again,

Alan

Rob would be better able to explain the program side of things, but as a comparison for you, here is how one of my apps breaks down:

ZIP file created by build: 33.5MB

And then my source files…

Asset files:

Image files: 14MB

Audio files: 17.9MB

XML files and font files: 1MB

Lua files: 0.7MB

So clearly, I am not getting the code being that large in size.

Oh, and yes, Photoshop does do a great job at creating PNG files.  But PNG is a lossless file format; there is no compression.  Hence the large file sizes.

PNGcrush and TinyPNG (and more), do optimized compression on PNG files to reduce the size.  On my particular images, they got shrunk by as little as 12% to one at 67%.  I previewed all of the images side by side and the majority of them looked good.  There were a few that clearly looked worse, so I reverted those.

Wow! That is awesome!  I can’t wait to see what the compression does for me.  And great advice on the backup.  Of course.  I"ll need to give it a shot.

And I need to look at what is being included in my final app file.  I have a feeling that I have some lingering file in there that pushing the file size up.  I just did a build to test on the device and, watching the logs, I see that it is grabbing everything in the directory, as it should and as someone that actually though about (clearly not me) should expect.  

I really do appreciate you taking the time.  Thanks so much.

Alan

When you deliver an app to Apple, PNGcrush is run for you, so your app size delivered to Apple should include PNGcrush.  Now the main reason Apple does that is to make sure the PNG files are aligned right for the fastest loading (and a benefit of making the images smaller), but I don’t think PNGcrush can still get images down to what a JPEG would be at an aggressive compression level. 

Images and Audio will always be the biggest part of your app.

Rob

I just used the tiny png tool and was able to reduce my image footprint from 54 MB to 17 MB.  THAT IS INSANE!  Thank you so much!

Now, Rob, are you saying that Apple will do this so that the file size that is available on the app store is different than the file size that you deliver to them?  If so, that is potentially a huge time saver.

Still, it’s nice to know that I can stay under that 50Mb level.

Thanks again to both of you.  I love these forums!

And Apple’s default use of PNG compression is not as much as what you can do on your own using tools or the TinyPNG web site.

Here are a few things you can do.

  1. Any image that does not need transparency (like backgrounds), save them as JPEG’s not PNG’s.  JPEG’s compress much smaller, but they don’t support transparency.  Since your backgrounds are likely to be your largest images, you can gain much here.

  2. Make sure that you “Save for Web or Devices” from Photoshop and you’re making sure to not save any color profile, EXIF, caption or other meta data.  You can have a 5K image turn into a 35K image quickly.  If you have a lot of these, it adds up.

  3. Use Image sheets where possible.  regardless of removing as much meta data as you can, you still have overhead that an be reduced.  If you use a tool like texture packer, you can get more information by fitting the images into tighter areas.

4.  For images that scale up nicely, skip the @4x versions.  But where quality matters you should keep them.

  1. For your audio, consider 11khz mono sounds over 44khz stereo.

Rob

Great advice.  Thanks!  And some great things to keep in mind in developing my next app.  Unfortunately, a lot my graphics have transparency, but shrinking down those that don’t was a good help.  Every mB counts.

Curious about the recommendation to use PNG over JPG, because from what I have seen in various forum posts, as far as memory goes, Android handles PNG images much better than JPG images.  Is that no longer the case?

Regardless of how you create PNG files, it would definitely be worth getting them shrunk using some of the external compressors (like PNGcrush) or this site: https://tinypng.com/

That can shrink the size of PNG files greatly.  I use all PNG files in my apps and after using the Tiny PNG site, mine got reduced by about 10MB.

One warning though, iOS devices sometimes display a white line at the bottom of compressed images.  Not sure why, and not on all images.  So if you do this, keep a backup of the images and test on iOS to see if you need to revert to the uncompressed versions for any.  Never saw the problem on Android, even with the same images used.

Wow!  That is some great advice!  I will have to try it out. Ten percent savings is significant.  I did compress a few static, non-transparent images as jpg’s and saw a huge difference in file size (from over 3 mB to about 600k) so that was a big help.  I would think that photoshop would do a good job at optimizing the files.  I’ll have to see what the difference is with tiny png.

Thanks for the advice.

One other thing that I noted is that, currently, my graphics are coming in at around 60 mB.  I’m going to go through and compress them, but should there be 40 mB of extra stuff just from the code?  My lua files (and there aren’t that many of them) don’t even come close to that.  What is the normal footprint of what Corona adds in when an app is compiled?

Sorry to add a question on to a thank you.  Just doing my best to understand this.

Thanks again,

Alan

Rob would be better able to explain the program side of things, but as a comparison for you, here is how one of my apps breaks down:

ZIP file created by build: 33.5MB

And then my source files…

Asset files:

Image files: 14MB

Audio files: 17.9MB

XML files and font files: 1MB

Lua files: 0.7MB

So clearly, I am not getting the code being that large in size.

Oh, and yes, Photoshop does do a great job at creating PNG files.  But PNG is a lossless file format; there is no compression.  Hence the large file sizes.

PNGcrush and TinyPNG (and more), do optimized compression on PNG files to reduce the size.  On my particular images, they got shrunk by as little as 12% to one at 67%.  I previewed all of the images side by side and the majority of them looked good.  There were a few that clearly looked worse, so I reverted those.

Wow! That is awesome!  I can’t wait to see what the compression does for me.  And great advice on the backup.  Of course.  I"ll need to give it a shot.

And I need to look at what is being included in my final app file.  I have a feeling that I have some lingering file in there that pushing the file size up.  I just did a build to test on the device and, watching the logs, I see that it is grabbing everything in the directory, as it should and as someone that actually though about (clearly not me) should expect.  

I really do appreciate you taking the time.  Thanks so much.

Alan

When you deliver an app to Apple, PNGcrush is run for you, so your app size delivered to Apple should include PNGcrush.  Now the main reason Apple does that is to make sure the PNG files are aligned right for the fastest loading (and a benefit of making the images smaller), but I don’t think PNGcrush can still get images down to what a JPEG would be at an aggressive compression level. 

Images and Audio will always be the biggest part of your app.

Rob

I just used the tiny png tool and was able to reduce my image footprint from 54 MB to 17 MB.  THAT IS INSANE!  Thank you so much!

Now, Rob, are you saying that Apple will do this so that the file size that is available on the app store is different than the file size that you deliver to them?  If so, that is potentially a huge time saver.

Still, it’s nice to know that I can stay under that 50Mb level.

Thanks again to both of you.  I love these forums!