PNG DPI and Print Size: Pixels, pHYs Metadata and Resampling
Explain what PNG stores, how apps infer print size and when changing DPI does or does not add detail.
How PNG Stores Physical Size: Pixels and the pHYs Chunk
A PNG file records a raster grid—a width and height measured in pixels. That is the only geometric dimension the format guarantees. According to the PNG specification (Third Edition, W3C), the file may optionally carry a pHYs chunk that suggests an intended physical pixel density, but conforming decoders are free to ignore it. The core constraint: PNG has no native concept of inches or centimeters. It contains a pixel matrix and, optionally, a ratio hint.
- Pixel dimensions (for example, 1200 × 1800) are mandatory and stored in the
IHDRchunk. - Physical pixel density (stored in the
pHYschunk as pixels per unit) is optional. - DPI or PPI is inferred from
pHYsmetadata; the format does not store a direct “DPI” integer.
When an application opens a PNG, it reads the pixel dimensions and, if present, the pHYs chunk, then calculates a default print size. If pHYs is absent, the application falls back to an arbitrary default—commonly 72 or 96 PPI. This fallback explains why the same file can appear as “72 DPI” in one viewer and “300 DPI” in another.
How the pHYs Chunk Determines Print Size
The pHYs chunk contains three fields: pixels-per-unit-X, pixels-per-unit-Y, and a unit specifier. Per the PNG specification (§11.3.5.3), a unit specifier of 1 means the values represent pixels per meter; 0 means the aspect ratio is defined but the absolute unit is unknown.
To convert to DPI, a viewer multiplies by 0.0254 (meters per inch):
DPI = pixels_per_meter × 0.0254
Example: A file with pHYs X = 11811, Y = 11811, unit = 1 yields 11811 × 0.0254 ≈ 300 DPI.
Print size is then calculated as:
print_width_inches = pixel_width / DPI
print_height_inches = pixel_height / DPI
For a 1200 × 1800 pixel image with 300 DPI metadata:
- Width: 1200 / 300 = 4 inches
- Height: 1800 / 300 = 6 inches
If that same file lacked a pHYs chunk and a viewer defaulted to 72 DPI, it would report:
- Width: 1200 / 72 ≈ 16.67 inches
- Height: 1800 / 72 = 25 inches
The pixel data has not changed. Only the interpreted physical dimensions differ.
Two Distinct Operations: Metadata Editing vs. Resampling
Changing “DPI” in a PNG involves one of two fundamentally different actions. Confusing them is the source of most print-size errors.
1. Metadata-Only Change (No Detail Added)
Editing the pHYs chunk without altering the pixel grid relabels the existing pixels. A 400 × 400 pixel image tagged at 100 DPI prints at 4 inches square. Tagged at 200 DPI, it prints at 2 inches square. The print becomes smaller and denser, but no new detail appears—the same 400 pixels are redistributed over a different physical area.
Limitation: Raising the DPI metadata alone cannot increase sharpness. If the source lacks sufficient pixel resolution for the target print size, changing only the metadata produces a smaller print, not a more detailed one.
2. Resampling the Pixel Grid
Resampling adds or removes pixels through interpolation, changing the actual image data. Upsampling an 800 × 600 image to 1600 × 1200 and setting the pHYs chunk to 300 DPI produces a larger physical print at that density than the original would. However, the new pixels are algorithmic estimates. The file size and pixel count increase, but the optical resolution—detail captured from the original scene—does not. The PNG specification does not define resampling; it is a preprocessing step performed before encoding.
Hard limit: No resampling algorithm recovers detail that was never recorded. A 72 PPI web graphic upsampled to 300 PPI will still appear soft when printed at the intended physical size. The only way to add genuine detail is to return to a higher-resolution source.
Diagnosing a PNG’s Current Density Metadata
Determine what a file actually contains without relying on a single viewer’s interpretation.
Check for the pHYs Chunk Directly
Use a hex editor or a PNG-aware metadata tool. The pHYs chunk appears after the IHDR chunk in the file structure. Its 9-byte payload consists of:
- 4 bytes: pixels per unit, X axis (big-endian unsigned integer)
- 4 bytes: pixels per unit, Y axis (big-endian unsigned integer)
- 1 byte: unit specifier (
0= unknown;1= meter)
If the chunk is absent, the file carries no embedded density hint. Any DPI value displayed is an application-level default.
Calculate Intended Print Size from Pixel Dimensions
Obtain the pixel width and height from a tool that reports them directly (ImageMagick’s identify, the file command on some systems, or a viewer’s properties panel). Divide by your target output DPI:
print_size_inches = pixel_dimension / target_DPI
Compare this to the size your print workflow expects. If the discrepancy is large, you must either resample—accepting the quality trade-off—or adjust the pHYs metadata to match the intended output.
Test with a Known Reference File
Create a 1000 × 1000 pixel PNG with a pHYs chunk set to 1000 pixels per meter (≈25.4 DPI). When printed at 100% scale with no software scaling, it should measure approximately 39.37 inches per side. If the output differs, the printing pipeline is overriding or ignoring the metadata.
Two Common Print-Size Failures and Corrections
Failure: The Lab Prints a Tiny Image
The lab’s raster image processor (RIP) ignores the pHYs chunk and assumes a fixed default density—often 300 or 254 DPI for photographic printers. If the file was saved with 72 DPI metadata or no pHYs chunk, the RIP interprets the pixel count at its own default, producing a much smaller print.
Correction: Embed a pHYs chunk set to the lab’s expected DPI, or resample the pixel grid so the dimensions match the desired print size at that default. For a 4 × 6-inch print at 300 DPI, the pixel grid must be exactly 1200 × 1800. If the source is smaller, upsampling is required, with the associated quality loss, or the print size must be reduced.
Failure: The Editor Shows 72 DPI and Blocks Changes
The application detects a missing pHYs chunk or a unit specifier of 0 (unknown). Some editors treat this condition as 72 DPI and disable density fields until a manual “set print resolution” command is issued.
Correction: Add a pHYs chunk with explicit pixels-per-meter values. If the editing application cannot write this chunk, use a command-line tool such as exiftool to inject it without re-encoding the pixel data:
exiftool -PixelsPerUnitX=11811 -PixelsPerUnitY=11811 -PixelsPerUnitSpecifier=meters image.png
This preserves the original compression and image quality; only the metadata block is modified.
What Metadata Changes Cannot Recover
- Optical resolution: Upsampling a low-resolution source to a higher pixel count does not create the fine detail a native high-resolution capture would contain. Interpolation generates plausible but synthetic pixel values.
- Edge sharpness: A metadata-only DPI change preserves existing sharpness but reduces physical dimensions. If the original image is soft, the print remains soft.
- Color accuracy: The
pHYschunk has no effect on color rendering. Color errors originate in profile chunks (cHRM,gAMA,iCCP) or the display pipeline, not in density metadata.
When a specific print size is required and the source resolution is insufficient, the only reliable path is to return to the original capture or vector source and export at the necessary pixel dimensions. The PNG specification provides a standard mechanism to suggest physical size, but it cannot compensate for missing image data.
Technical basis for PNG DPI and Print Size
Structural claims in this guide are grounded in the primary PNG technical reference.