base64 格式

base64格式 是一种图片格式,它为较长的一串字符,它本身就是图片,通过<img src="base64格式...">浏览器能解析并显示图片


<!-- 这是通过【url路径的形式】,展示了一张图片 -->
<img src="./logo.png" alt="" />

<!-- 还可以通过【base64字符串】的形式,展示一张图片 -->
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAjCAIAAABzZz93AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAFB0lEQVR42qVX+0/bVRQ/POxWjMxtzKAMaOljpdAHDwus0ekY4gYYXEi2qXs6wUXkIYVtUB5jMhhsc2ZxJpqxF4IPHNDCpoBxi8qyGMuAaaK/7FcTf3Bt/QO839x6enoKP5l88u29t/ecc8/jnnMuZJqt5izbJlO2KdMiBnIqkGWxC4ip+Iqp+DfbmiMXxVisU1BCCkmLALYb6cU+cYJl2cmBPArlJQ8hNwha3IP7ge5gh6W75Rnll25ALdEYyBCBG0CeQk7EPjQmVYvSUxvSdWFkxjraVCB/qL6SoxwIkWh3diD0qJzi+kqeU4QhdykSpVJTsKOwcEAzSHKmEz0B4IRaH30QvY7HREKFY2FxesvVpy/4Mi7Om147anqujIZJRIAgGdqdmQ7dg5aM0O+FysTaS9A+E9v1vdH7j2Hcbxz8w9ByOdP5MlVR0QyJWTTK0Gci0eC4x7S1SuUaA/cMuL8TMHqDEoaJv/VDDzPLDqIxFc2ENtTP9CDoeRr9GB0Cuher1A0j0DaLMHqCFPprD6UkKUUxI7WsZB1tRpZNxDe9rFrVdANaZygM40EGjA4hD+j9ZSGEMmhYKqfJsqe92hDf7IHj0wyGsSBDhM+QHct42tJ9q3p/gg9/W9c0ZBKu/u/amcy2jeVH4l2TcOxbipiWW6vrh6OFUZ5AFaIGTGzzwAe/Kji3pO6Y1uxsUCTlOjfs7opv8kLLNxSxzVNP7em2bqnQfx1k4ImYCkM/JR73wLkHiNj++eTD55/c3x/bNAnNtxhSdrWabQU5uQ79aICBXqRwIkZ7Sqn6LZXqjhkYWISzD0I4swTdd+HYNDTfDME1qa4Z1JXulyS5+QXRwjCthHLj8kkoy6Z1lq9tHIGBpQj0+sB9G1w3oWlq/Rt9Bsc2c3YoUO05+bovAww0pIGlV8wjct1oeXaNaxT6lyLQtwDuO8k7j5os+UglhNns+bovAgw07QErB6zcGR3Fj9dcgu570LcIpyOQVH3R4CgWaiG51Zan+zzAQH3EzUjumX3jS4dWV1+BBg+8NwXtP0DvIkOCy6sp2SvkybMLYRkjAYYIM9Jeg5ZEzeYK1ZFhqPeE0OCF1tvw/jycWgijZ/6xzh9TKxtliVGEDQcYqFNCmoklmSsxdzxx8COom0Coaq4nl9cl7RuIO3EPehYYkg5d2FRYbLHmZnzmZ6CFEGjKp5Vzzd6z8O64gndurN3doyvYrtQBS75m+2GV+w6cvE8Rc9KXUD+qLT2gHfIz0JwXSlfRJVTrKFn15iDUjq2r6jDnFmGUmszW1JIDce1zTB50++I672qv+xlo1xXOjSznsixMPSqub8qOt1Uts9A9z6C95megrIAyCpdEUpeXbUDFSoazIqFxArp8FJqrfgbeytF7x7jTNpl1leIvQ2Gpum4MOn0IzRU/Rdr532nKBZooseTTwk2TGxUsS67O+Yq69qsY9y/Q4RPQXH4kkfbJn9qeOcPWXUgeUTxZY0vjhTajYkCvjpLS8p5fv+d0TNvPsZ330wcfpX36V2r7rGFHtdFehPVWfoHWMBqZqIG8giyCcDH0LsnZ/MxbH284tZByYk6/7XVzXhGNACkprBn1B23CqUeZDejVZBHL+vPwpaat5/9RjsURFYzKKa0c61tXyimonxjQBlCOaS9LH1HL1DO6m72CmKLRT7zolol2afKZGWp4KAsMs2UvOL1h7A2xUtfEnnr/Asbvt92ZUS6sAAAAAElFTkSuQmCC" alt="" />

base格式的优缺点:

  • 优点:它本身就是图片,客户端不需要发起图片请求
  • 缺点:它的体积比原图片文件大 30%,它适合用于小图片

文件转base64的网址

上一篇:Base64加密解密,银行软件开发面试题


下一篇:手把手教你如何上传代码到gitee服务器