How image Base64 encoding works
Base64 is a reversible binary-to-text encoding. For images, the browser reads the selected file as a data URL, splits the MIME prefix from the encoded payload, and lets you choose whether the output should be raw Base64, a full data:image/...;base64, URL, or a CSS url("...") value.
The MIME type matters because the browser needs to know whether the encoded bytes represent PNG, JPEG, WebP, GIF, SVG or another supported image format. The data URL prefix carries that type, while raw Base64 output is only the encoded payload.
Base64 is not encryption, compression or image optimization. It usually makes the text representation larger than the original file, so inline images work best for small assets that benefit from being embedded directly in HTML, CSS, JSON or test data.