Methods to compress image and audio files' size
Posted: Tue Sep 22, 2015 6:25 am
Since some people may be concerned that the file size of their game is too huge, here are some methods that may help in the compression of image and audio files' size.
(Note: Most of these methods can be pretty time consuming, especially for the one concerning Audacity because only one file can be dealt with at a time.)
(Double Note: I am not an expert when it comes to judging the quality of image and audio files, so I apologise if there are any inaccuracies on that part.)
Images
. Image formats: These are the three common image formats that are used to save VN files.
.jpg:
+ Quality: Lossy (poor quality), although when such images are saved with relatively high quality, they will still look pretty decent. Maximum quality of 10 can be set for a less pixelated image though it seems like quality 12 gives a more vibrantly coloured image.
+ File size: Usually smallest out of the three
+ Works best for: Images that are rich in colours (full colour) as you will get an image with a small file size as well as acceptable quality.
+ Not the best idea for: Images without complex (photo/soft-shaded colours) because compression becomes quite evident then (thus quality will appear poor).
+ Supports: Does not support transparency, translucency and animated images.
Note - For anyone's reference, saving a rocky image like this: http://orig01.deviantart.net/5924/f/201 ... 97pbxk.jpg with quality 12 can take up to 1MB.
.gif:
+ Quality: Lossless (better quality) but quality may be poor if the images have many colours.
+ File size: Usually biggest out of the three (can warrant the smallest file size if the image has limited colours)
+ Works best for: Pixel art/Images with fewer than 256 colours (small file size + pretty good quality)
+ Not the best idea for: Other kinds of art (especially those that require many colours). Linearts are also not a good idea since they can come out as pixelated.
+ Supports: Transparency, animated images. Does not support translucency.
Note: For anyone's reference, saving the rocky image can take up to 601KB.
.png:
+ Quality: Lossless (better quality)
+ File size: Usually in the middle of the three (can warrant the smallest file size for images that contain large amounts of pixels that are of the same colours and contiguous)
+ Works best for: Full colour transparent and translucent images, images that have a lot of pixels that have same colours and are contiguous. This is also the best option if you want genuinely lossless compression.
+ Not the best idea for: It is still an okay image format for other types of images but the file size will usually be bigger.
+ Supports: Transparency, translucency but not animated images
+ P.S.: It can save with .gif-style limited colours or with full colours.
Note: For anyone's reference, saving the rocky image can take up to 1.49MB.
. Separating Layers (in sprites) : The sprites can be separated to several sections to save space (instead of an expression that consists of a mouth, nose, a pair of eyebrows and eyes, they can be split up into different layers [saves more space and can create more variety in expressions]). This will probably require a more advanced level of coding (LiveComposite), but there's always tutorials in the Ren'Py Cookbook that can help.
. Relevant websites:
http://www.clickonf5.org/15311/image-co ... s-plugins/ (List of websites that can compress images)
Audio
. Audio formats: Very much like the image formats, changing the audio format can be an effective way, but it can also compromise quality.
.ogg:
+ Quality: Lossy (less quality) but I don't think the quality loss is noticeable.
+ File size: Small (and I think it saves the smallest filesize out of all audio formats, if I am not wrong)
+ Works best for: Usually the best idea for average VN audio
+ Not the best idea for: This probably isn't a good idea if you want 100% high-quality audio.
.flac:
+ Quality: Lossless
+ File size: Bigger than .ogg
+ Works best for: If you want extreme high-quality audio, then .flac is the way to go.
+ Not the best idea for: If you don't want big file sizes, then .ogg is still the best option.
. Audacity: Editing with Audacity also helps a whole load.
-> Changing Project Rate: There can be a few hundred KB difference if you simply set a file's project rate to 8000. (Additional note: However, plenty of high-frequency information may be lost in the process of decreasing a project rate, so this should probably be used at discretion.)
-> Cutting off Empty Periods: Usually, if there are unnecessary pauses in the audio files, I remove them so that more space can be saved.
-> Amplifying: This doesn't save a lot of space (probably a few KB) but it does help if the volume of the audio is lowered.
-> Changing Tempo: I won't recommend this method since it changes the music itself, but slowing down the speed of the audio still helps, so I'll just add it here.
. Relevant websites:
http://www.videograbber.net/compress-audio-file.html (Audacity)
https://www.youtube.com/watch?v=ACA9dnBLMAg (iTunes)
Reliability
With the use of Kraken.io and Audacity (except Changing Tempo), I manage to shrink a 50+ MB game to a 17~18 MB game so I think these methods are relatively effective. Of course, as mentioned above, they can be pretty time consuming but I do think they can help a bunch. For backgrounds, I save them as .jpg format; for transparent images, I save them as .png format; for audio files, I save them as .ogg format.
Hopefully this may be serve as help to some people.
(Note: Most of these methods can be pretty time consuming, especially for the one concerning Audacity because only one file can be dealt with at a time.)
(Double Note: I am not an expert when it comes to judging the quality of image and audio files, so I apologise if there are any inaccuracies on that part.)
Images
. Image formats: These are the three common image formats that are used to save VN files.
.jpg:
+ Quality: Lossy (poor quality), although when such images are saved with relatively high quality, they will still look pretty decent. Maximum quality of 10 can be set for a less pixelated image though it seems like quality 12 gives a more vibrantly coloured image.
+ File size: Usually smallest out of the three
+ Works best for: Images that are rich in colours (full colour) as you will get an image with a small file size as well as acceptable quality.
+ Not the best idea for: Images without complex (photo/soft-shaded colours) because compression becomes quite evident then (thus quality will appear poor).
+ Supports: Does not support transparency, translucency and animated images.
Note - For anyone's reference, saving a rocky image like this: http://orig01.deviantart.net/5924/f/201 ... 97pbxk.jpg with quality 12 can take up to 1MB.
.gif:
+ Quality: Lossless (better quality) but quality may be poor if the images have many colours.
+ File size: Usually biggest out of the three (can warrant the smallest file size if the image has limited colours)
+ Works best for: Pixel art/Images with fewer than 256 colours (small file size + pretty good quality)
+ Not the best idea for: Other kinds of art (especially those that require many colours). Linearts are also not a good idea since they can come out as pixelated.
+ Supports: Transparency, animated images. Does not support translucency.
Note: For anyone's reference, saving the rocky image can take up to 601KB.
.png:
+ Quality: Lossless (better quality)
+ File size: Usually in the middle of the three (can warrant the smallest file size for images that contain large amounts of pixels that are of the same colours and contiguous)
+ Works best for: Full colour transparent and translucent images, images that have a lot of pixels that have same colours and are contiguous. This is also the best option if you want genuinely lossless compression.
+ Not the best idea for: It is still an okay image format for other types of images but the file size will usually be bigger.
+ Supports: Transparency, translucency but not animated images
+ P.S.: It can save with .gif-style limited colours or with full colours.
Note: For anyone's reference, saving the rocky image can take up to 1.49MB.
. Separating Layers (in sprites) : The sprites can be separated to several sections to save space (instead of an expression that consists of a mouth, nose, a pair of eyebrows and eyes, they can be split up into different layers [saves more space and can create more variety in expressions]). This will probably require a more advanced level of coding (LiveComposite), but there's always tutorials in the Ren'Py Cookbook that can help.
. Relevant websites:
http://www.clickonf5.org/15311/image-co ... s-plugins/ (List of websites that can compress images)
Audio
. Audio formats: Very much like the image formats, changing the audio format can be an effective way, but it can also compromise quality.
.ogg:
+ Quality: Lossy (less quality) but I don't think the quality loss is noticeable.
+ File size: Small (and I think it saves the smallest filesize out of all audio formats, if I am not wrong)
+ Works best for: Usually the best idea for average VN audio
+ Not the best idea for: This probably isn't a good idea if you want 100% high-quality audio.
.flac:
+ Quality: Lossless
+ File size: Bigger than .ogg
+ Works best for: If you want extreme high-quality audio, then .flac is the way to go.
+ Not the best idea for: If you don't want big file sizes, then .ogg is still the best option.
. Audacity: Editing with Audacity also helps a whole load.
-> Changing Project Rate: There can be a few hundred KB difference if you simply set a file's project rate to 8000. (Additional note: However, plenty of high-frequency information may be lost in the process of decreasing a project rate, so this should probably be used at discretion.)
-> Cutting off Empty Periods: Usually, if there are unnecessary pauses in the audio files, I remove them so that more space can be saved.
-> Amplifying: This doesn't save a lot of space (probably a few KB) but it does help if the volume of the audio is lowered.
-> Changing Tempo: I won't recommend this method since it changes the music itself, but slowing down the speed of the audio still helps, so I'll just add it here.
. Relevant websites:
http://www.videograbber.net/compress-audio-file.html (Audacity)
https://www.youtube.com/watch?v=ACA9dnBLMAg (iTunes)
Reliability
With the use of Kraken.io and Audacity (except Changing Tempo), I manage to shrink a 50+ MB game to a 17~18 MB game so I think these methods are relatively effective. Of course, as mentioned above, they can be pretty time consuming but I do think they can help a bunch. For backgrounds, I save them as .jpg format; for transparent images, I save them as .png format; for audio files, I save them as .ogg format.
Hopefully this may be serve as help to some people.