Sub topic 4
Raster formats at a glance: lossy vs lossless, layers vs flat
This chapter assumes you know the Photoshop workspace, understand pixels and image dimensions, and have a basic idea of what layers are. It gives you the working model for comparing formats. Later chapters cover PSD, JPEG, and PNG in detail.
Why formats differ
A raster image is a grid of pixels, and each pixel holds color values. A file format is a set of rules for writing that grid, and anything else Photoshop knows about the document, to disk. Formats differ on two independent questions:
- Does the format throw away pixel information to make the file smaller? This is the lossy versus lossless question.
- Does the format keep the document's structure, such as layers, masks, and text? This is the layered versus flat question.
These two questions are separate. A format can be lossless and flat (PNG). It can be lossy and flat (JPEG). It can be lossless and layered (PSD). Treat them as two axes, not one scale from "good" to "bad".
Lossy versus lossless storage
Lossless
Lossless compression shrinks a file in a way that can be exactly reversed. When you reopen the file, every pixel has the same value it had when you saved. PNG and PSD both use lossless compression for pixel data. TIFF can too.
You can save a lossless file a hundred times and the pixels will not change. The cost is size. Photographs, which have noisy, varied pixels, compress poorly this way, so lossless photo files are large.
Lossy
Lossy compression discards information the encoder judges to be least noticeable. JPEG divides the image into 8 by 8 pixel blocks and stores an approximation of each block. Smooth gradients and soft detail survive well. Sharp edges, fine text, and flat color next to detail do not.
The discarded data is gone for good. Each time you open a JPEG, edit it, and save it as JPEG again, the encoder approximates an approximation. This is called generation loss, and it accumulates.
Typical damage, called artifacts, looks like this:
- Blocky squares in smooth areas such as sky.
- Ringing, a halo of noise around high-contrast edges and text.
- Color bleeding, where saturated colors smear into neighboring pixels.
A rule that saves trouble
Lossy is acceptable as the last step. It is a poor choice as a working format. Keep a lossless master and create the lossy copy from it.
Layered versus flat
A flat file stores one grid of pixels. A layered file stores the grid in pieces plus the instructions that combine them.
A layered document such as a PSD can hold:
- Pixel layers
- Layer masks and clipping relationships
- Adjustment layers
- Text layers that stay editable
- Smart objects
- Layer styles and blend modes
- Paths, channels, and guides
Flattening merges all visible layers into a single image. The result looks the same on screen at that moment, but you can no longer move the text, change an adjustment, or repaint a masked region. That information is not hidden in the file. It is gone.
The next chapter covers flattening in more detail. For now, remember the practical consequence: saving to a flat format from a layered document either flattens the output or, in some cases, flattens a copy while leaving your open document alone.
Comparing the three core formats
| Property | PSD | JPEG | PNG |
|---|---|---|---|
| Compression | Lossless | Lossy | Lossless |
| Layers kept | Yes | No | No |
| Editable text and smart objects | Yes | No | No |
| Transparency | Yes | No | Yes |
| Typical use | Editing master | Photos for web and sharing | Graphics, logos, screenshots, transparent images |
| Relative size for a photo | Large | Small | Medium to large |
| Embedded color profile | Yes | Yes | Yes, but see below |
Some points about the table need qualifying:
- PSD stores layers and other data. Because PSD can hold a lot, files are often much larger than the visible image suggests.
- JPEG has no transparency channel. Transparent areas in your document are filled with a color when you save, usually white or a matte color you choose.
- PNG stores a single flat image. It can include an alpha channel, which records per-pixel opacity, so edges can be partly see-through. Photoshop writes PNG as flat, so the layers are merged in the output.
- PNG color profile handling is more varied across browsers and apps than JPEG handling. Check the result in the place where it will be viewed.
A decision diagram
The questions below come in the order you would ask them when picking a format.
This is a first pass. The decision-guide chapter adds delivery requirements, such as file size limits and color accuracy.
Other formats you will meet
Photoshop opens and saves many formats. A short orientation helps you recognize them.
- TIFF is a flexible, widely supported format. It can be lossless and can keep layers, though layered TIFFs are larger and less portable than PSD. Print workflows often use it.
- GIF is limited to 256 colors per image. It supports simple on/off transparency and animation. PNG replaces it for most still images.
- WebP is a web format that supports both lossy and lossless modes and transparency. It is smaller than JPEG or PNG at similar visual quality in many cases.
- HEIC is common on phones. It is lossy, efficient, and can hold high bit depth.
- Camera Raw files hold sensor data from a camera. They open through Camera Raw first, and they are not the same thing as the document you save afterward.
- PSB is a large document format for files that exceed the PSD limits of 2 GB for some contents and 30,000 pixels on a side.
Treat these as context. This tutorial focuses on PSD, JPEG, and PNG because they cover the common editing and delivery cases.
What changes when you save
Here is a worked case. You have a layered banner with a text layer, a photo layer with a mask, and a transparent area around a logo.
- Saved as PSD, everything stays. You can reopen it and change the text.
- Saved as JPEG, the layers are merged, the transparent area is filled with a matte color, and the pixels are compressed with loss.
- Saved as PNG, the layers are merged, the transparent area stays transparent, and the pixels are stored without loss.
Now suppose you reopen the JPEG and the PNG. In both, the text is pixels, not editable text. Neither file can recover the mask. This is why the PSD must be kept.
A check you can do in Photoshop: open the saved JPEG and look at the Layers panel. You will see a single layer named Background. Open the saved PNG and you will usually see a single layer named Layer 0 if transparency is present, or Background if not.
Common errors
- Using JPEG as the working file. Repeated saves degrade the image, and layers are lost on the first save.
- Saving a logo as JPEG. Edges ring, flat color shifts, and the transparent background becomes a solid fill.
- Saving a photo as PNG for the web. It works, but the file is often several times larger than a JPEG of similar visual quality.
- Overwriting the PSD with a flat save. When you use Save As with a flat format and keep the same name, you may lose track of which file is the editable one. Use distinct names or Save a Copy.
- Assuming a lossless format means correct color. Lossless protects pixel values. It says nothing about whether the color profile was embedded or whether the viewer honors it.
How to tell what you have
You can inspect a file to see what it actually holds.
- Check the extension, but do not rely on it. A file named photo.png can contain JPEG data if it was renamed.
- Open the file and look at the Layers panel. Many layers suggest a layered format. A single Background layer suggests a flat one.
- Use File > File Info to see embedded metadata and, in some versions, the profile.
- Use Edit > Assign Profile or the status bar document profile display to see the color profile.
- Zoom to 200% and inspect edges and flat areas for blocky noise. Visible artifacts point to lossy compression.
Quick check with a script
This ExtendScript reports the number of layers and the color mode of the active document. It helps you confirm what you opened. The scripting chapter covers running scripts.
// ExtendScript: report what the active document contains
var doc = app.activeDocument;
var info = doc.name + "\n"
+ "Layers: " + doc.artLayers.length + "\n"
+ "Layer sets: " + doc.layerSets.length + "\n"
+ "Mode: " + doc.mode + "\n"
+ "Bit depth: " + doc.bitsPerChannel;
alert(info);Note that artLayers counts only top-level layers. Layers inside groups are counted through each group's own artLayers collection.
Exercise
You have a layered PSD of a product photo with a text layer and a clipping mask. A client wants a small file to email, and you must also keep the ability to change the text next week. Which formats do you save, and why does the order of operations matter?
Show answer
Save the PSD first as the editing master, because it is lossless and keeps the text layer and mask. Then save a JPEG copy for email, because it is small and the client only needs to view it. Use Save a Copy or a distinct file name so the open document stays the PSD. Creating the JPEG from the PSD, and never the reverse, means you always edit from the lossless source and the lossy loss happens only once.
Exercise
A designer saves a logo with a transparent background as JPEG, and it appears with a white box on a dark web page. What happened, and which format fixes it?
Show answer
JPEG has no transparency channel, so Photoshop filled the transparent area with a matte color, here white, when it saved. Saving the logo as PNG keeps the alpha channel, so the background stays transparent on the dark page.