- Home /
PNG Build size is 40 times bigger than the Image file size
The following image is a png of 1250*750 pixels and have size 70.9 kB
When I build my game for android, the Editor Log shows that the file does size 2.8 mb!!
Why is that size soo big? Is there a way to prevent it? Thanks
Answer by Eno-Khaon · Sep 23, 2021 at 07:00 PM
The simple reason that there's such a large difference is that a PNG file isn't in a video card-ready state.
At a glance, the 2.8mb file size is based on an uncompressed (which makes sense for non-power-of-2 image dimensions) 24-bit texture (no alpha channel).
1250 * 750 = 937500 pixels
937500 * 3 (colors per pixel) = 2812500 bytes
~2.8125 megabytes
There's not really a lot you can do about that image file size, since an image needs to be uncompressed to be drawn to the screen (not counting DXT compression and similar... but... bleh) and an already-ready image is much *FASTER* to prepare and draw, which is useful when you are drawing a large quantity of them in a hurry (open-world 3D game is a prime example of this).
In the grand scheme of things, that image size really isn't terrible, though, if you consider what this means for other common image dimensions:
1024x1024, 4bpp = ~4mb -- DXT: ~0.7mb (~700kb)
2048x2048, 4bpp = ~16mb -- DXT: ~2.8mb
4096x4096, 4bpp = ~64mb -- DXT: ~11.2mb
8192x8192, 4bpp = ~256mb -- DXT: ~44.7mb
Yes, I'm well aware that my views of DXT compression are biased against it, but I've never personally encountered a case where the compression was handled well enough that a power-of-2 size reduction doesn't look better (2-color image? That *should* be lossless under DXT compression rules, right? Good luck getting them to look good with any common compressor).
All things considered, this doesn't mean there aren't exceptions, either. With clever use of data importing/reading, it wouldn't be impossible to import compressed files, then decompress them into RAM for use, but that definitely falls outside the scope of the Unity Editor itself (rather, it becomes a matter of scripting).
Furthermore, you would generally want to do something like this with a "loading screen" or similar, in order to allow more time to prepare the textures for display.