4 ms·
Yes, that's true. I think, generally speaking, base64 encoded images will result in more bytes than the original. I guess it's probably around 10%-20%. I think
by milestinsley 17y ago
Yes, that's true. I think, generally speaking, base64 encoded images will result in more bytes than the original. I guess it's probably around 10%-20%.
I think, in the case of spriting, it would be fair to say that the overhead of loading many images/http requests (and their individual headers) pretty much nullifies the effects of bloating from the encoding.
- tolmasky 17y agoDon't forget that since the resultant file is sent over the wire gzipped, a lot of that is undone by the fact that you are gzipping all the images together instead of separately.
- Nycto 17y agoBase64 will inflate a list of bytes by 33%. For every three bytes that go in, 4 bytes are returned. Wikipedia has a very good explanation of why this is: http://en.wikipedia.org/wiki/Base64 http://en.wikipedia.org/wiki/Base64 While we're on the subject, Ascii85 is kind of a cool alternative. By increasing the number of characters used for the encoded string and breaking a 32 bit integer apart in an interesting way, it is able to reduce the expansion down to 25%. For every 4 characters in, 5 come out. Again, more info is available on Wikipedia: http://en.wikipedia.org/wiki/Ascii85 http://en.wikipedia.org/wiki/Ascii85
- jacobolus 17y agoIncidentally, here's some javascript codecs I wrote for both base64 and ascii85, if anyone wants to play with using them on their sites: http://pastie.textmate.org/695197 http://pastie.textmate.org/695197 My base64 codec turns out to be quite similar to the Cappucino one; oddly, most of the javascript base64 codecs with decent google juice are actually horrible implementations.