Sub topic 1
Raster Images and Pixels
Prerequisites
This chapter assumes you can open, save, and export files in Photoshop, and that you have used the Layers panel. You should know that a pixel is one dot of color on a screen. You do not need to know anything about resolution or print size yet. Later chapters build on this one.
What a raster image is
A raster image is a grid of pixels. Each pixel is a single square sample that holds one color value. The grid has a fixed number of columns and rows, and the image is whatever colors those cells contain.
Photoshop is built around raster images. Photographs, scans, screenshots, and paintings made with brushes are all raster data. A vector image is different. It stores shapes as math, such as a curve with a start point, an end point, and a fill. A vector can be scaled to any size without losing detail, because the shapes are redrawn each time. A raster image cannot, because it holds only the pixels it was given.
This difference explains most of what Photoshop does when you resize something. When you make a raster image larger, Photoshop has no extra detail to show. It can only invent new pixels from the old ones. When you make it smaller, Photoshop must throw pixels away. The rest of this tutorial is about controlling that choice.
| Property | Raster image | Vector image |
|---|---|---|
| Stored as | A grid of colored pixels | Mathematical shapes |
| Typical sources | Photos, scans, painted artwork | Logos, icons, illustrations |
| Scaling up | Loses sharpness | Stays sharp |
| File size depends on | Number of pixels and bit depth | Number and complexity of shapes |
| Main Photoshop use | Pixel layers and the background | Shape layers and Smart Objects from vector files |
What a pixel holds
A pixel does not have a physical size. It is a stored number, or a few numbers, that say what color to show at one grid position. How big that pixel looks depends on the screen or paper it is shown on. This point matters a great deal later, when we separate pixel dimensions from print size.
In an RGB document, each pixel stores three values, one each for red, green, and blue. These are called channels. At 8 bits per channel, each channel can hold 256 levels, from 0 to 255. Three channels give 256 × 256 × 256, about 16.7 million possible colors per pixel. A pixel with values 255, 0, 0 is pure red. A pixel with 0, 0, 0 is black, and 255, 255, 255 is white.
Other modes store different channels. CMYK uses four, Grayscale uses one, and an image with transparency adds an alpha channel, which stores how opaque each pixel is. Bit depth is the number of bits each channel uses. Photoshop supports 8, 16, and 32 bits per channel. Higher bit depth keeps smoother gradients and gives more room for editing, but it makes the file larger.
How pixels add up to file size
The number of pixels is the main driver of how much memory an image needs. You can estimate the uncompressed size of a flat RGB image like this:
width_px = 3000
height_px = 2000
channels = 3 # red, green, blue
bytes_per_channel = 1 # 8 bits per channel
total_pixels = width_px * height_px
size_bytes = total_pixels * channels * bytes_per_channel
print(f"{total_pixels:,} pixels")
print(f"{size_bytes / (1024 * 1024):.1f} MB uncompressed")This prints 6,000,000 pixels and about 17.2 MB. Saved files are usually smaller because formats such as JPEG, PNG, and compressed PSD reduce the data. Photoshop's working memory, however, holds roughly the uncompressed amount for each layer. A document with many full-size layers uses memory in proportion to the pixel count of each one.
Doubling both the width and the height does not double the pixel count. It quadruples it, because the grid grows in both directions. A 3000 × 2000 image has 6 million pixels. A 6000 × 4000 image has 24 million.
Seeing pixels directly
You can see the grid yourself. Open any image and zoom in with the Zoom tool or by pressing Ctrl and + (Cmd and + on macOS). At 100% zoom, one image pixel matches one screen pixel on a standard display. Above 100%, Photoshop shows each image pixel as a larger block. Past about 800%, you see the individual squares. Turn on View > Show > Pixel Grid to draw lines between them.
The Info panel (Window > Info) shows the exact position and color values under the pointer. This is a quick way to confirm that an image really is a grid of numbers.
Zoom level changes only the view. It does not change the file. A common early mistake is to treat "I zoomed in" as "I made it bigger". The pixel data stays the same.
Why raster images lose quality when scaled
Consider a 4 × 4 image, which has 16 pixels. If you scale it to 8 × 8, you need 64 pixels. Photoshop has 16 known values and must fill in 48 new ones. It does this by calculating each new pixel from nearby original pixels. The result looks smooth or blurry, depending on the method, but no new detail appears.
Now scale a 3000-pixel-wide photo down to 300 pixels. Ten original pixels in each row become one. Fine detail is averaged away. If you then scale it back up to 3000 pixels, Photoshop cannot recover what was lost. The image will be soft.
The following diagram shows both paths.
This is why careful workflows avoid resizing the same pixels repeatedly. Each resample is a calculation that cannot be undone from the pixels alone. A later chapter shows how Smart Objects keep the original data so you can scale as often as you like.
Edge cases and common errors
Several situations trip up intermediate users. Knowing them early saves effort.
- Pixels are not inches. An image has a pixel count whether or not you ever print it. A 1200 × 800 image is 1200 × 800 on a web page. Print size only appears once you attach a resolution value, which the next chapters cover.
- A large file is not always a detailed one. An image can be enlarged to a high pixel count with no added detail. Its pixel dimensions are big, but it still looks soft. Pixel count measures size, not sharpness.
- Non-square pixels exist. Some video formats use pixels that are wider or taller than they are square. Photoshop can display a pixel aspect ratio correction for these. Most photo and web work uses square pixels, and this tutorial assumes them.
- Layers can extend past the canvas. A layer may hold pixels that lie outside the visible document area. They still exist and still use memory, but they do not show or export. This will matter when we discuss Canvas Size.
- Compression is not the same as resizing. Saving a JPEG at lower quality changes how the data is stored. It does not change the pixel dimensions. Check Image > Image Size to see the pixel count.
- Vector content becomes raster when it is rasterized. A shape layer stays sharp at any size. Once you rasterize it, it turns into pixels and behaves like any raster layer.
Checking pixel data in Photoshop
You can read the pixel count of any open document in two quick ways.
- Choose Image > Image Size. The dialog lists Image Size in megabytes, and the Dimensions field shows width and height in pixels. Use the unit menu beside the dimensions if it is set to something other than pixels.
- Turn on the document information readout at the bottom of the window and choose Document Dimensions or Document Sizes from its menu.
Always check pixels first when you receive an unfamiliar file. It tells you how much room you have to resize without a visible loss of quality.
The same information can be read by a script. This ExtendScript snippet prints the active document's pixel dimensions and the pixel count:
// Photoshop ExtendScript (.jsx)
app.preferences.rulerUnits = Units.PIXELS;
var doc = app.activeDocument;
var w = doc.width.value;
var h = doc.height.value;
alert(w + " x " + h + " px = " + (w * h) + " pixels");Setting the ruler units to pixels first makes doc.width.value return a pixel count. Without it, the value uses whichever unit the preference is set to, such as inches.
Key points to carry forward
- A raster image is a grid of pixels, and each pixel stores color values.
- Pixel count is width times height, and it grows with the square of any uniform scale factor.
- Pixels have no physical size until a resolution is assigned.
- Enlarging invents data, and reducing discards data. Neither returns the original detail.
- Zoom and compression do not change pixel dimensions.
Exercise
A document is 2400 × 1600 pixels, RGB, 8 bits per channel, one flat layer. How many pixels does it have, and about how many megabytes does it need uncompressed? Then, if you scale it to 4800 × 3200 pixels, by what factor does the pixel count change?
Show answer
The pixel count is 2400 × 1600 = 3,840,000 pixels. Uncompressed size is 3,840,000 × 3 bytes = 11,520,000 bytes, which is about 11.0 MB (11,520,000 / 1,048,576). Doubling both width and height makes the pixel count 4 times larger, 15,360,000 pixels, because the grid grows in both directions.
Exercise
A colleague says, "I zoomed the photo to 400% and saved it, so now it is four times bigger." Is this correct? Explain using pixels.
Show answer
No. Zoom changes only how the image is displayed. The file still has the same pixel dimensions and the same pixel data. To change the pixel count, you must resample with Image > Image Size or change the canvas with Image > Canvas Size.
Exercise
You scale a 3000 px wide photo down to 600 px, then back up to 3000 px. Will the result match the original? Why or why not?
Show answer
No. Scaling down discards detail by averaging groups of pixels together. Scaling back up creates new pixels calculated from the remaining ones, so it cannot restore the lost detail. The result has the original dimensions but looks softer.