Picture to SVG Code: Converting an Image into a Favicon-Ready SVG
What turning a picture or PNG into SVG code actually produces, how embedded rasters differ from traced vector paths, and how to prepare the result as a favicon.
Contents
The short answer
Converting a picture to SVG code can mean two very different things. A converter can wrap the original pixels inside an SVG file, which gives you SVG markup that still contains a raster image. Or it can trace the picture's shapes and rebuild them as vector paths, which gives you artwork that scales cleanly and can be edited shape by shape. For a favicon made from a logo, tracing is usually the useful outcome, and it works best when the source is a simple, flat, high-contrast mark rather than a photo.
Embedded raster versus traced vector
The file extension does not tell you which kind of SVG you have. A file named logo.svg may hold true vector paths, an embedded PNG, or both. The difference determines whether the image stays sharp when scaled and whether a designer can recolor or adjust individual shapes.
| Aspect | Embedded raster in SVG | Traced vector SVG |
| What the code contains | An image element holding PNG or JPEG data, often base64-encoded | Path, shape and fill elements describing outlines |
| Scaling | Same pixel limits as the original picture | Resolution-independent |
| Editing | Pixels must be edited in a raster tool | Shapes, colors and nodes can be edited in a vector editor |
| Fidelity to source | Identical to the original pixels | An interpretation; detail may be simplified or lost |
| Typical use | Packaging an existing image in an SVG wrapper | Logos, icons and favicons that need crisp edges |
What each result looks like in code
An SVG that merely embeds a PNG looks roughly like this. The long data string is the original picture, unchanged.
<svg viewBox="0 0 64 64" width="64" height="64">
<image width="64" height="64"
href="data:image/png;base64,iVBORw0KGgo..." />
</svg>
A traced result describes shapes instead. This simplified example draws a filled circle and a square cut-out using path data.
<svg viewBox="0 0 64 64" width="64" height="64">
<path fill="#1a1a1a"
d="M32 4a28 28 0 1 0 0 56a28 28 0 1 0 0-56z
M22 22h20v20h-20z"
fill-rule="evenodd" />
</svg>
Both snippets omit the SVG namespace declaration (the xmlns attribute on the root element) for brevity. A standalone SVG file, including one served as a favicon, needs that declaration; most editors and converters add it automatically.
How to check what a converter gave you
- Open the SVG in a plain text editor and look for an image element or a long data string beginning with data:image; that indicates embedded raster content.
- Look for path, circle, rect or polygon elements with fill colors; those are vector shapes.
- Zoom far in using a browser or vector editor; embedded rasters blur or pixelate, while vector edges stay sharp.
- Open the file in a vector editor and try selecting individual shapes; an embedded raster appears as a single locked image block.
Which pictures trace well
Tracing tools detect edges and color regions, then fit curves to them. That process suits logos with a few solid colors, clear edges and no fine texture. Photographs, soft gradients, drop shadows, thin strokes and small lettering tend to produce either rough approximations or very large files full of tiny paths. Starting from the largest, cleanest version of the image available generally gives the tracer more to work with than a small, compressed PNG.
Text inside a logo is a special case. A tracer converts letters into outlines, so the result is no longer editable as text, and the outlines may not match the original typeface exactly. If the original font and artwork files exist, rebuilding from them is more accurate than tracing a picture.
Preparing the SVG as a favicon
- Use a square viewBox so the icon is not stretched or letterboxed in browser tabs.
- Simplify the mark: a favicon is displayed very small, so a symbol or initial usually reads better than a full logo with a wordmark.
- Clean up the traced paths by removing stray specks, merging overlapping shapes and reducing unnecessary nodes; this keeps the file small and the edges clean.
- Check the icon against both light and dark browser themes; SVG favicons can include a prefers-color-scheme media query in an internal style block to switch colors, in browsers that honor it.
- Keep a raster fallback, such as a PNG or ICO, because SVG favicon support is not universal across browsers and platforms.
A common way to reference both an SVG favicon and a fallback in a page's head looks like this.
<link rel="icon" href="favicon.ico" sizes="any">
<link rel="icon" href="favicon.svg" type="image/svg+xml">
Rights when the picture is someone else's logo
Being able to download a logo image does not grant permission to trace, alter or reuse it. The artwork, any fonts used in it and the trademark itself can each carry separate restrictions. Converting a brand's logo for your own site icon, or modifying an official mark, generally requires permission from the owner or compliance with their published brand guidelines.
What this overview does not cover
No specific conversion tools were evaluated for this article, so it does not compare tracing quality, pricing or features between products, and it gives no browser-by-browser support figures for SVG favicons. Check current browser documentation and test the finished icon in the browsers your audience uses before relying on SVG alone.