Sub topic 10
Strengths and limitations side by side
This chapter assumes you know how a raster image stores a grid of pixels and how a vector image stores paths, points and styles. It also assumes you have read the earlier chapters on resolution and scaling, and that you know common extensions such as .jpg, .png and .svg. Here the two models are compared on the same criteria, so you can predict how each will behave before you pick one.
The core trade-off
A raster image records the result: the color of every pixel. A vector image records the recipe: the shapes that produce the picture when a renderer draws them.
Each choice follows from that difference.
- A raster file holds all the visual information it will ever have. Nothing is computed at display time, so any picture can be stored, including one with no clean shapes in it.
- A vector file holds instructions. It scales and edits well, but only if the picture can be described by a manageable number of shapes.
Almost every row in the comparison below is a consequence of this one split.
Scaling
Raster images have a fixed pixel grid. Enlarging one means the software must invent pixels by interpolation, which produces blur or visible blocks. Shrinking is safer, because it throws information away, but it can soften fine lines and text.
Vector images have no grid. The renderer recalculates every curve at the target size, so a 16-pixel icon and a billboard come from the same file. The two SVG examples earlier in this tutorial show this. Changing width and height changes the output size, and the viewBox keeps the coordinates the same.
One caveat is that vector scaling stays sharp but is not always visually correct. A line with stroke-width="4" grows with the drawing, so a thin hairline at small sizes becomes a heavy line at large sizes. Designers often make separate versions of a logo for tiny sizes, with fewer details and thicker strokes. The goal is legibility, not geometric accuracy.
Detail and realism
A photograph contains millions of subtle color transitions: skin, fog, grass, a lens blur. Describing these as shapes would need so many that the file would be larger and slower than the pixel version. Raster is the natural model for continuous-tone images.
Flat, bounded shapes are the reverse. A logo with three colors and clean edges needs a few paths in vector form. As a raster it needs a whole grid, and the edges are only as sharp as that grid allows.
Vector tools can imitate realism with gradients, meshes and filters, but it takes skill and the files grow quickly. If your picture started as a photo, keep it raster.
File size
The two models grow in different ways.
- Raster size depends on pixel count and color depth. Uncompressed, width × height × bytes per pixel. Compression reduces this, but the pixel count still sets the baseline.
- Vector size depends on the number of shapes and the points in each. Output dimensions do not matter.
The script below shows the difference. It builds an SVG with a chosen number of random circles and compares its size to the uncompressed raster size at two output resolutions.
import random
def make_svg(n_shapes: int) -> str:
random.seed(1)
parts = ['<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000">']
for _ in range(n_shapes):
cx = random.randint(0, 1000)
cy = random.randint(0, 1000)
r = random.randint(5, 60)
color = "#{:06x}".format(random.randint(0, 0xFFFFFF))
parts.append(f'<circle cx="{cx}" cy="{cy}" r="{r}" fill="{color}"/>')
parts.append("</svg>")
return "\n".join(parts)
def raw_raster_bytes(width: int, height: int, bytes_per_pixel: int = 3) -> int:
return width * height * bytes_per_pixel
for n in (10, 1000, 100000):
size = len(make_svg(n).encode("utf-8"))
print(f"SVG with {n:>6} circles: {size:>9} bytes")
print("Raw raster 1000x1000:", raw_raster_bytes(1000, 1000), "bytes")
print("Raw raster 4000x4000:", raw_raster_bytes(4000, 4000), "bytes")The raster figures are 3,000,000 and 48,000,000 bytes however simple the picture is. The SVG size tracks the shape count and stays the same whether you display it at 100 pixels or 10,000. With 10 circles the vector is tiny. With 100,000 circles it is no longer small, and rendering it will also take noticeable time. Real raster files are compressed, so the practical gap is smaller than these raw numbers suggest, but the trend is the same.
Editing
Vector editing is non-destructive by nature. You can select a shape, move one anchor point, change a fill, or reorder layers, and nothing else is affected. Text can remain live text, and you can reuse shapes across a design.
Raster editing changes pixels. Retouching, painting, masking and color correction work well, but every edit is baked into the grid. Repeated edits to a lossy file such as a JPEG compound the quality loss, because each save re-compresses the image. Working in layers, or keeping an original, preserves flexibility.
A related point is that raster tools can do things vector tools cannot, such as healing a blemish, cloning texture or removing noise. Vector tools can do things raster tools cannot, such as changing the radius of a corner after the fact or applying exact boolean operations to shapes.
Rendering cost
Raster images are cheap to display. The viewer decodes pixels and copies them to the screen. Large images still cost memory, because a decoded image takes width × height × bytes per pixel in RAM, whatever its compressed file size. A 6000 × 4000 JPEG of 3 MB on disk becomes about 72 MB in memory when decoded as RGB, or 96 MB with an alpha channel.
Vector images must be rasterized at display time. The renderer computes the geometry, fills the shapes and applies effects such as blur or masks. For simple icons this is trivial. For complex maps, illustrations with thousands of paths or heavy filters, it can slow a page or an app. Complexity matters more than file size here.
Side-by-side summary
| Criterion | Raster | Vector |
|---|---|---|
| Stored as | Grid of pixel colors | Paths, points, styles |
| Scaling up | Blurs or blocks | Stays sharp |
| Scaling down | Safe, may soften detail | Safe, thin strokes may need adjustment |
| Photographs | Natural fit | Impractical |
| Flat logos and icons | Works at fixed sizes only | Natural fit |
| File size driver | Pixel count and compression | Number of shapes and points |
| Editing unit | Pixel regions | Individual objects |
| Display cost | Memory by pixel count | CPU by shape complexity |
| Typical formats | JPEG, PNG, GIF, WebP | SVG, PDF, EPS, AI |
Choosing by weakness
A useful habit is to ask which weakness of each model would hurt your task, rather than only asking which strength you want.
This flow is a starting point. A real project often combines both. A poster might use a raster photo under vector type and shapes. A web page might use an SVG logo next to a JPEG hero image, as in the HTML example from earlier in the tutorial.
Common errors
These mistakes come from misreading what each model does.
- Assuming vector means high quality. A vector file can hold an embedded raster image. An SVG or PDF that contains a low-resolution photo is still low resolution. The file extension tells you the container, not the content.
- Enlarging a raster and expecting sharpness. Setting a 200-pixel-wide PNG to 2000 pixels in a layout tool does not add detail. Start from a larger source, or recreate the artwork as vector.
- Raising the DPI value to fix a small image. Changing the metadata only changes how large the image is printed. The pixel dimensions, and so the detail, stay the same unless the image is resampled, and resampling cannot add real detail.
- Using vector for a photo "so it scales". Auto-tracing a photo gives a posterized, banded look and often a larger file than the original.
- Saving repeated edits as JPEG. Each save loses a little more quality. Keep a lossless master, such as a layered file or PNG, and export JPEG once at the end.
- Ignoring small-size rendering of vector icons. A detailed icon can turn muddy at 16 pixels, because curves land between pixel boundaries. Check icons at their real display size.
- Overlooking fonts in vector files. A PDF or EPS may depend on fonts. Embed them or convert text to outlines before sharing, and keep a live-text copy for later edits.
- Forgetting memory cost. A small compressed file can still be a large decoded image. This matters on mobile devices and pages with many images.
Limits that don't go away
Some limitations cannot be engineered around, so plan for them.
- Raster: There is no recovery of detail that was never captured. AI upscalers can generate plausible detail, but it is invented and should not be used where accuracy matters, such as for evidence or technical drawings.
- Vector: Some content has no useful shape description. Fine noise, film grain and soft depth of field are examples. You can only approximate them.
- Both: Output devices are pixel grids. Even a vector image is rasterized before you see it, so the final look depends on the target resolution and the renderer's anti-aliasing.
The last point is why the two models are less opposed than they first appear. A vector image is a raster image that has not yet been produced.
Summary
Raster stores outcomes and is the right model for photographs and any image with continuous tone, at the cost of fixed resolution. Vector stores instructions and is the right model for logos, icons and diagrams that must scale and stay editable, at the cost of poor fit for realistic imagery. Check the content of a file, not its extension, before you rely on either property.
Exercise
A designer sends you "logo.svg". You open it in a text editor and find a single <image> element that contains a base64-encoded PNG, 300 pixels wide. You scale it to 1200 pixels wide and it looks blurry. Why, and what should you ask for?
Show answer
The SVG is only a container around a raster image. The renderer scales the 300-pixel PNG, so it interpolates pixels and blurs. The file has the .svg extension but none of vector's resolution independence. Ask for a true vector version with <path>, <rect> or <circle> elements, or for a raster export at least 1200 pixels wide made from the original artwork.
Exercise
A 4000 × 3000 photo is saved as a 2 MB JPEG. Roughly how much memory does it take once decoded as 8-bit RGB, and why does that matter even though the file is only 2 MB?
Show answer
4000 × 3000 × 3 = 36,000,000 bytes, about 34 MiB. Decoding expands the compressed data into one value per channel per pixel, so memory use depends on pixel dimensions, not file size. A page with many such images can use a lot of memory, so resize images to the size they will be displayed at.