Raster vs vector: what is the difference?
A raster image is a grid of coloured pixels: JPG, PNG, WebP, GIF, BMP and phone photos all work this way. Avector image is a list of shapes, such as lines, curves and filled areas, that is drawn fresh at whatever size it is shown; on the web that means SVG.
Use raster for photos and anything with fine texture. Use vector for logos, icons, diagrams and lettering that must stay sharp at every size.
Side by side
| Feature | Raster (JPG, PNG, WebP, GIF) | Vector (SVG) |
|---|---|---|
| Made of | A fixed number of pixels, each with its own colour | Shape and path instructions with fill colours |
| Enlarged | Pixels get bigger: edges go soft or blocky | Redrawn at the new size: edges stay crisp |
| File size depends on | Pixel count, format and quality setting | How many shapes and points the drawing has |
| Good at | Photos, scans, textures, soft shadows | Logos, icons, charts, diagrams, line art |
| Weak at | Being scaled up; one file per size | Photos and gradient-heavy art; very complex drawings get heavy |
| Editing | Paint over pixels in a photo editor | Move, recolour or reshape individual objects |
| Text inside | Turned into pixels | Can stay real, selectable text |
The definitions come from MDN, which says raster images “are defined using a grid of pixels” and lists BMP, PNG, JPEG and GIF as popular raster formats, while a vector file “contains shape and path definitions that the computer can use to work out what the image should look like when rendered on the screen.”
Why size behaves so differently
A raster file grows with its pixel count. Double the width and height and there are four times as many pixels to store. A vector file does not change when you show it bigger, because only the instructions are stored. MDN describes the difference on screen: a zoomed raster image “starts to look blocky”, while the vector one “continues to look nice and crisp”.
The other side of this is that vectors are not small by nature. MDN warns that “SVG can get complicated very quickly, meaning that file sizes can grow; complex SVGs can also take significant processing time in the browser.” A drawing with thousands of tiny shapes can outweigh a compressed raster of the same picture.
When raster is the right choice
Anything captured by a camera or scanner is raster from the start, and it should stay that way. Skin, sky, fabric and shadow are smooth blends of colour with no clean outlines to describe. MDN puts it plainly: raster graphics are “arguably better for complex precision images such as photos”.
For raster images the real choices are format and pixel size. The best image format for the web guide covers JPG, PNG, WebP and AVIF.
When vector is the right choice
Logos, icons, charts, maps, diagrams, signatures and cut designs are made of clear shapes and flat colours. As vectors they print sharply at any size and stay light on a web page. MDN also points out that “text in vector images remains accessible” and that each part of an SVG “can be styled via CSS or scripted via JavaScript”, so a site can recolour an icon without a second file.
If a designer made your logo, ask for the vector original rather than converting a PNG. It will be cleaner than any trace.
Converting between them
Vector to raster is exact and easy. The shapes are simply drawn at the pixel size you choose:
- SVG to PNG keeps empty areas transparent.
- SVG to JPG fills the background with a colour you pick.
Make the raster at the largest size you will need. Scaling that PNG up later brings back all the raster problems.
Raster to vector means tracing: software groups pixels into a few colours, follows the edge of each patch and writes those edges as paths. It is an approximation, not a lossless conversion. It works well on flat artwork with a handful of colours and poorly on photos.
- The SVG converter traces PNG, JPG, WebP, BMP and GIF in colour or black and white.
- The PNG to SVG converter starts with settings for logos on a clear background.
One trap: an .svg file is not automatically a vector. The W3C specification describes SVG as a language for “vector and mixed vector/raster graphics”, so an SVG can simply wrap a photo. The files our tracing tools produce contain only path shapes. For a walk-through of the tracing settings, see how to convert an image to SVG; for the format itself, what an SVG file is.
Questions
Is a PNG with a transparent background a vector?
No. Transparency is just another value stored for each pixel. The PNG is still a fixed grid and will blur or step when enlarged.
Does saving a picture as .svg make it a vector?
Not by itself. SVG may contain embedded raster images, so a photo wrapped in an SVG is still pixels. A true vector SVG contains only shapes, which is what our tracing tools write.