The previous post, I described the steps we took to get the size improvements, in this post I will try explain a few steps in a bit more detail.
Converting 24bit PNG's to 8bit PNG's
Of course its possible to update each image manually and save it as 8bit PNG using PhotoShop, but let me put it this way, it wont be convenient, doing it this way. We had like a ton of images to be converted, so best option would have been a command line tool that we could invoke using a shell script.
With that in mind, we used pngquant a command line utility that does lossy compression of PNG files. It conveniently converts 24bit PNG files into 8bit PNG files with a simple command.
This simple shell script will find all the PNG files in a given directory and passes them to pngquant and converts them into 8bit PNG images.
The results are pretty sweet, it save around 70% of the size of the original 24bit PNG image.
Converting 8bit PNG's to WebP
As mentioned in the earlier post, WebP is an image format that provides lossless and lossy compression for images. Using the lossless compression on an 8bit PNG gives a whooping 26% reduction in image size.
To convert PNG images into WebP download and install the utilities provided by Google from here. The simple shell script to convert PNG images to WebP looks like this
This script basically finds all the PNG images in the folder and passes it on to the WebP converter and creates new files with .webp extension.
To render webp images using UIImage use the iOS-WebP library or any other similar library. Our game uses Cocos2d, to add WebP support to Cocos2d just refer this post
These were the two important methods that gave us significant size reductions in the final binary. In the next post, I will talk about how we reduced the size of music and sound files of our game.
Converting 8bit PNG's to WebP
As mentioned in the earlier post, WebP is an image format that provides lossless and lossy compression for images. Using the lossless compression on an 8bit PNG gives a whooping 26% reduction in image size.
To convert PNG images into WebP download and install the utilities provided by Google from here. The simple shell script to convert PNG images to WebP looks like this
This script basically finds all the PNG images in the folder and passes it on to the WebP converter and creates new files with .webp extension.
To render webp images using UIImage use the iOS-WebP library or any other similar library. Our game uses Cocos2d, to add WebP support to Cocos2d just refer this post
These were the two important methods that gave us significant size reductions in the final binary. In the next post, I will talk about how we reduced the size of music and sound files of our game.