What is the effect of encoding an image in base64?

后端 未结 6 943
鱼传尺愫
鱼传尺愫 2020-11-22 07:21

If I convert an image (jpg or png) to base64, then will it be bigger, or will it have the same size? How much greater will it be?

Is it recommended to use base64 enc

6条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-22 07:40

    It will be bigger in base64.

    Base64 uses 6 bits per byte to encode data, whereas binary uses 8 bits per byte. Also, there is a little padding overhead with Base64. Not all bits are used with Base64 because it was developed in the first place to encode binary data on systems that can only correctly process non-binary data.

    That means that the encoded image will be around 25% larger, plus constant overhead for the padding.

提交回复
热议问题