Illustrator and Pixels

This will start out somewhat broad, but my main focus here is on those who are having trouble getting the pixel images they want out of Illustrator. There are many examples I’ve come across over the years of people having difficulty getting images out of Illustrator at the ‘correct’ size, especially in relation to PPI. It’s a common problem not because the users are at fault, but because Illustrator hides a key factor from them.

I’ll try and start at the beginning.

Vector and raster

These are the two primary ways of defining visual information using computer software. Basically for our purposes, “vector” means something is defined by coordinates, and lines or curves joining those coordinates. The coordinates are called anchor points, and the curves are called beziers. The curves are defined by control handles extending from the anchor points (longer handles mean more extreme curves).

An image of a bezier curve featuring anchor points and control handles in Illustrator, with annotations

“Raster” means something is defined by a grid. Within the grid, each square (or pixel) is assigned a colour value, and an image emerges from the arrangement of squares. This is the same curve as above, but the grid of pixels is much larger to make the construction more obvious:

A raster image of a curve, scaled up so that pixels are visible

In this case, the colour of each pixel varies from black to grey to white to give the illusion of a curve. There are roughly 50 pixels in each dimension, enough to describe basic shapes, but not much use for anything more detailed.

The point of this distinction between images defined by vectors and images defined by a grid is that you can make the vector image much larger and it’ll look just as detailed. If you make the grid image much larger, you’ll end up with larger grid squares. Here’s the same curve, the vector version on the left and the raster on the right:

Output

This isn’t really a fair distinction, but it is the impression many people have when comparing the two image types. It’s not entirely fair because virtually everything you produce in software ends up as raster of some sort. Vector software is really just another way of producing raster images.

Think of the end products of your work: if you are designing something for print, your vector image will be translated by the printer software into a grid that the printer itself represents in tiny ink dots. If you’re exporting a PNG or a JPEG, your vector image becomes raster at that point. Even if your image will always be viewed on screen as a PDF or an SVG or some other format, your computer monitor is a grid of pixels performing rasterisation. Vector and raster are most often two different points in the same process, rather than different processes entirely.

So why might you start the process with one over the other if both usually end up at the same point? For raster, there are many image types that are just more efficiently represented as pixels than vectors. You might think of a set of vector shapes as paper cutouts placed on top of one another. To create a really detailed image, you might need many thousands of complex paper cutouts, to the point where the image is much more mathematically complex than a grid of pixels, even millions of pixels. Thus, realistic photos are almost always easier to represent with pixels than vectors.

The main point of vector files is that they can be the source of many different sizes of raster output. From a single vector drawing, you could output a 16×16 pixel favicon, a 500×500 company logo for a website, and a 2 metre wide banner.

Illustrator’s Units

I mentioned earlier that every anchor point in Illustrator is defined by coordinates. Those coordinates are based on a unit of real-world size: the point. This is the same point you use to define the size of type, and as far as modern software is concerned, a point is 1/72 of an inch. The actual unit Illustrator uses is vastly smaller than that (I don’t actually know the accuracy limit, but there is one), but it is some tiny fraction of a point. If you set the units in Illustrator to something else like centimetres, it’s still converting those from fractions of a point behind the scenes.

This is still the case if you tell Illustrator to use pixels as your unit.

This is a crucial point to remember. If you’re following this, you might be aware that a pixel is not a unit with a definite size. Your monitor might have 1080 rows of pixels from top to bottom, but it could also be a 13-inch laptop screen or a 60-inch TV with the same amount. If you have a pixel image, you can still scale if as we did above, so each pixel is much larger or smaller than it was originally defined.

Illustrator does not care about any of this. When working within Illustrator, a pixel is exactly the same thing as a point — 1/72 of an inch.

The reasons for this are historical, and outside my scope. But this is what we have to work with.

Pixels Per Inch and Dots Per Inch (PPI and DPI)

You may have heard one or both of these terms used in reference to pixel images, because they’re used almost synonymously, but Pixels Per Inch is what we are concerned with. It means, perhaps obviously, the number of pixels in each row of an inch. DPI is primarily a printing term, referring to printer dots per inch, and strictly speaking is irrelevant here, but people do use it to refer to the same thing as PPI on occasion. In the below example, 1 inch is 10 pixels across, resulting in a resolution of 10 PPI:

A representation of 10 pixels per inch

Of course, it’ll only be actually one inch across if you have a particularly small monitor, but I’m not in control of that.

Illustrator, therefore, uses a resolution of 72 PPI if you work in pixels. This doesn’t mean that your work is 72 PPI within Illustrator – as vectors, your work is independent of resolution – but that if you were to export a file one inch square at 100% size, that image would be made up of 72×72 pixels.

Pixels and Physical Sizes

In the requirements for image sizes for either print or screen use, you might see three variables used: the pixel-by-pixel size (“500 x 300”), the resolution (“300 PPI”), or the physical size (“4.23 x 2.54 cm”).

All of these are interdependent:

  1. If you know the pixel size and the resolution, you know the physical size (if an image is 300 pixels tall and 300 PPI, it can only be one inch tall).
  2. If you know the resolution and the physical size, you know the pixel size (a one-inch tall image at 300 PPI is 300 pixels high)
  3. If you know the physical size and the pixel size, you know the resolution (a one-inch tall image that is 300 pixels high has 300 PPI).

Generally speaking, if you’re making something for on-screen use, you don’t need a physical size. Only the pixel dimensions are important, because they’re the only things relevant to a screen (because an inch might be made up of any number of pixels on different screens). This means PPI isn’t necessary either, because without a physical size, there is no way to define it.

If you’re going to be printing something, you need the physical size and the resolution. We’ll go through scenarios for both of these.

A Raster Image for Print

Usually if you’re printing, you’ll want to supply a PDF or the AI file itself to the printer, so that the printer itself can perform the rasterisation at its native resolution. But occasionally, you may need to produce a raster file at a specific physical size (for example, to supply a rather inflexible online service). Sometimes, these requirements can seem at odds with what Illustrator can produce — if, for instance, you’re asked for a 5000 x 3000 JPEG file at 300 PPI.

Logically, you might then create a new file, select pixels as your unit, and enter 5000 and 3000 for the height and width.

Illustrator new document settings for a 5000 x 3000 pixel image
‘Raster Effects’ refers to the resolution of effects such as drop shadows — it has no effect on any overall ‘document resolution’

Then, you might go to Export As… and select 300 PPI.

Illustrator export settings for a 300 PPI JPEG

But if you check the resulting file in Bridge or Photoshop, you’ve created something vast!

Image Size infornmation in Photoshop

20834 x 12500 pixels! That’s a huge image, and far larger than you intended. What has happened here?

Remember the relationship between physical size, pixel size, and resolution. We can work out that a 5000 x 3000 pixel image at 300 PPI must be 16.666 x 10 inches. But that’s not what we’ve ended up with — that image is 69.44 inches wide. What’s happened is this:

Because of the relationship between points and pixels, Illustrator has already defined a physical size.

When you create a document 5000 pixels wide in Illustrator, you’ve created one 69.44 inches wide. This is because Illustrator assumes there are 72 pixels to an inch. There’s nothing you can do to change this inner working; you just need to be aware of it if you’re producing anything in pixels.

When you export that document at 300 PPI, Illustrator isn’t exporting a 5000 pixel image, it’s exporting a 69.44 inch one. 69.44 inches at 300 PPI is 20834 pixels — the number we see in the resulting image above. We could even go so far as to state the following:

Illustrator has no concept of pixels. A ‘pixel’ in Illustrator is just a point in disguise.

What do we need to do, then, to create an image of 5000 x 3000 pixels at 300 PPI? We need to apply what we know:

  1. There are only physical units in Illustrator
  2. If we know the pixel size and the resolution, we know the physical size

All we need to do is divide the pixel dimensions by 300 to get the dimensions we need in inches. This means we want a document of 16.666 x 10 inches. This, therefore, should be the starting point, not the pixel dimensions.

If you create a document of those dimensions and then export using 300 PPI, you should end up with a 5000 x 3000 pixel size.

A Raster Image for Screen

So what about a situation where you simply want a pixel dimension? Should you use pixels as a unit in Illustrator then?

The answer is yes — as long as you export at 72 PPI.

This means that the dimensions you use as your Illustrator document will be the same as those that export. The PPI itself is irrelevant — all you want are those pixel dimensions to be correct.