The short answer
Choose your picture in the Image → Base64 text card of DocFila's Convert hub and save. You get a .txt file holding a data: URI, with the correct image type, ready to paste into a CSS background or an HTML image tag. It runs on your device.
Where does it run?
On this device, offline, for pictures up to 20 MB. Nothing is uploaded.
What is kept, and what changes?
Kept
- The picture exactly as it is. The original bytes are encoded without re-compressing or resizing.
- The correct type in the URI, such as image/png or image/jpeg, read from the file's contents instead of trusting its extension.
- Several pictures at once, each into its own text file named with -base64.txt.
- A single line of text you can paste anywhere.
Changed or lost
- Base64 makes data about a third larger than the picture, so the text is bigger than the file.
- An embedded image cannot be cached on its own by the browser and makes the page's code longer, so it suits small icons, not photographs.
- The picture is not optimised. Shrink or compress it first if the text is too long.
- The result is text, not an image; you cannot open the .txt as a picture.
What are the steps?
- Prepare a small picture. Base64 suits icons and small graphics. Compress or resize a large picture first with the compress-image tool.
- Open Image → Base64 text. In Tools choose Convert and open the card, or search the hub for “base64” or “data uri”.
- Choose files to convert. Select Choose files to convert and pick the pictures. PNG, JPG, WebP, BMP, GIF and TIFF are accepted.
- Convert and save. Start the conversion, then use Save converted file… for one picture, or Save into a folder… for several.
- Paste it into your code. Open the .txt, copy the whole line, and use it as src in an img tag or inside url(…) in CSS.
Which options does it offer?
No options. The output is always the data URI for the picture as it is. To change the picture, edit or convert it first, then encode it.
What are the limits?
Up to 20 MB per picture, though a data URI that long is rarely sensible in a page. The file must really be a picture that DocFila reads; a renamed text file is refused. Types outside the list DocFila knows are marked as a generic binary type.
When is another route better?
To make the picture smaller before you encode it, use the Compress to size card, covered on the compress-image tool page. For website icons, the Favicon set card does the whole job. If you need the picture itself rather than text, use PNG to JPG or JPG to PNG.
Compress image tool PNG to ICO favicon set JPG to PNG Convert hub
Questions
What is a data URI?
It is a web address that carries the file itself, written as data:, the type, base64 and the encoded bytes. A browser can show it without fetching a separate file.
Is my picture re-compressed?
No. DocFila encodes the original bytes exactly as they are, without compressing or resizing them again, so the decoded picture is identical to the file you chose at the start.
When should I avoid base64 images?
For anything large. The encoded text is bigger than the file and cannot be cached on its own, so a photograph is better served as a normal image file.
Does it check what type the file is?
Yes. The type is read from the picture's contents, so a PNG renamed to .jpg still gets image/png. A file that is not a picture is refused.
Related DocFila tools
Keep going with the document workflow that matches this page. Open the tool you need, then finish the file in DocFila.