What is a PPI Calculator?
The Pixels Per Inch (PPI) calculator is a tool to determine the pixel density of any screen on a computer, laptop, tablet, smartphone, or other display device. This tool measures the pixel density of a display by counting the number of pixels in a one-inch diagonal line.
PPI Formula
To calculate a screen PPI, you will need to provide the following information:
- Diagonal (in) - screen diagonal or screen size measured in inches.
- Width (px) - the horizontal resolution measured in pixels.
- Height (px) - the vertical resolution measured in pixels.
The Pythagorean Theorem can be used to calculate a screen's diagonal length in pixels based on its width and height in pixels.
To determine the number of pixels per inch (PPI), divide the screen's diagonal length in pixels by the diagonal length of the screen in inches.
The term pixels per inch, or PPI, is the screen pixel density measurement unit. It represents the number of pixels per 1 inch of the physical screen line. Since pixels are square and symmetrical, the PPI remains the same regardless of whether the inch is horizontal, vertical, or diagonal.
How do you calculate a screen PPI?
To determine the PPI of a screen, use the PPI formula. Check out the example below for a step-by-step guide on how to calculate screen PPI.
Find a screen PPI of the Apple iPhone 15 Pro Max.
According to the official specifications of the iPhone 15 Pro Max[1], the phone has a screen size of 6.7 inches and a resolution of 1,290 x 2,796.
Use the formula below to calculate the number of pixels across the diagonal line.
Then, divide the diagonal length in pixels by the diagonal length in inches.
So, the PPI of the iPhone 15 Pro Max is 460 PPI.
PPI vs. DPI
When discussing an image's resolution, we often hear the terms DPI and PPI. These terms are frequently used interchangeably, but they have different meanings.
- DPI refers to the number of dots a printer puts down on a square inch of a printed image
- PPI refers to the number of tiny colored squares that make up an image on a computer screen.
To understand the difference, think of DPI as the number of dots a printer can produce in a printed image, while PPI is the number of pixels a computer screen can display in an image.[2]
What is the Density-independent Pixel (DP)?
Android and Apple have introduced their measurement units for density-independent pixels to ensure that the user interface (UI) maintains a consistent size across devices with varying display densities.
This unit is known as DP (density-independent pixels) on Android devices, while on Apple devices, it is called Points [3]. These units allow developers to specify the size of UI elements independently of the device's pixel density (PPI), which can vary widely across devices of different sizes and resolutions.
By using DP or Points, developers can ensure that their apps look and feel consistent across a wide range of devices, which is especially important given the wide variety of devices on the market today.
The density-independent pixel (dp—all small caps) is the measurement unit for designing UI on screens with different pixel densities (PPI). In a medium or baseline density (160 dpi), one projected pixel equals one pixel on the screen.
Pixel Density Classification
Screen density is essential to designing an Android application that displays correctly on devices with varying screen sizes and resolutions. Android's support document[4] offers designers and developers a comprehensive guide outlining seven screen density classifications.
These classifications include LDPI (low density), MDPI (medium density), HDPI (high density), XHDPI (extra high density), XXHDPI (extra-extra high density), XXXHDPI (extra-extra-extra high density), and TVDPI (television density). Each of these classifications represents a specific range of pixels per inch (PPI) on a device's screen, and designers can use this information to create optimized resources for each class.
Use the table below to determine a device's screen density by comparing its pixels per inch (PPI) to the corresponding PPI range for each classification.
Class | PPI | Name | Factor |
---|---|---|---|
LDPI | < 120 | Low | 0.75 |
MDPI | 120 - 160 | Medium | 1 |
TVDPI | 160 - 213 | Television | 1.33 |
HDPI | 213 - 320 | High | 1.5 |
XHDPI | 320 - 480 | Extra High | 2 |
XXHDPI | 480 - 640 | Extra Extra High | 3 |
XXXHDPI | > 640 | Extra Extra Extra High | 4 |
Example: What's the Google Pixel 8 Pro screen density classification?
Based on the official Google Pixel 8 Pro hardware tech specs[5], it has a pixel density of 489 PPI.
Therefore, the Google Pixel 8 Pro has a XXHDPI (Extra Extra High) screen density screen.
DP to PX formula
Here is the formula to convert from the density-independent pixel units (dp) to pixel units (px).
See the examples below to learn more about converting from density-independent pixel units to actual screen pixel units.
Example: MDPI Screen
You want to draw a 0.5-inch line on a tablet with a pixel density of MDPI or 160 dpi. How many density-independent pixels (dp) and pixels (px) should you write in your code to achieve the desired output?
Use the following steps to solve the problems.
- The baseline or MDPI pixel density classification has 160 dp per inch.
- So 0.5 inch has 160/2 = 80 dp.
- Since the baseline density is 1 dp = 1px, the actual pixels used to draw the line are 80 pixels.
So, to draw a 0.5-inch line on an MDPI screen, you need to specify the length in either 80dp or 80px.
Example: XXHDPI Screen
With the same objective in the example above, How many density-independent pixels (dp) and pixels (px) should you specify in your design to draw a 0.5-inch line on a tablet with a pixel density of XXHDPI or 480 dpi?
Use the following steps to solve the problems.
- The baseline or MDPI pixel density classification has 480 dp per inch.
- So 0.5 inch has 480/2 = 240 dp.
- Use the formula below to calculate the pixels to draw the 0.5-inch line.
So, to draw a 0.5-inch line on an XXHDPI screen, you need to specify the length as 240dp or 720px.
FAQs
1. What is the difference between Dots Per Inch (DPI) and Density Independent Pixels Per Inch (dpi)?
Despite having the same abbreviation, the density-independent pixels per inch are often written in small caps. They also have a completely different meaning.
- Dots Per Inch (DPI) is a printing term that refers to the number of ink dots a printer can put on a square inch of paper to create a printed image.
- Density-independent Pixels per Inch (dpi) is a screen term used to design a consistent size on screens with different pixel densities (PPI).