A pixel is the smallest item in a display, camera sensor, or image that has an individual color value. Pictures are made up of pixels (also referred to as "px").
Camera sensor size is usually expressed in the total number of pixels. If your sensor is 4000 pixels wide and 3000 pixels high you have a 12,000,000 pixel or 12 megapixel sensor. Modern computer monitors have fixed horizontal and vertical pixel dimensions. Different monitor sizes can have the same pixel dimension, but different resolutions (see Resolution section below).
Resolution is the amount of pixels per length unit, commonly expressed as PPI (Pixels Per Inch) or DPI (Dots Per Inch).
- PPI is the correct way to express display or image resolution. For example, a 1920x1080 monitor that has a 30-inch wide display will have a 64 PPI horizontal resolution (1920 pixels / 30 inches = 64 PPI). The vertical resolution is usually the same value so that the pixels are square and do not distort images.
- DPI is a term from printing technology and refers to printed dots which form spots in a raster screen pattern. When an image is printed at a high enough resolution, you cannot detect spots but instead see a smooth gradient. Some printers simulate gradients with a raster screen pattern:
To view an image on a monitor, you can display each pixel of the image as a pixel on the monitor or scale the image to recalculate the image pixels since you can’t change the size of the monitor’s pixels. This can be as easy as multiplying existing pixels to upscale, or using more intelligent interpolation algorithms. Downscaling is done with similar methods.
Note: Repeated sampling of an image can result in quality loss. For best results, start from the original image and directly upscale or downscale to the output size (for example, avoid downscaling from an upscaled image).
When picture size is expressed in pixels without mentioning the resolution, the actual picture size that will be displayed is unknown. To get the size in inches, divide the size in pixels by the resolution in PPI.
Example: If a 4000x3000 px image has a 300 dpi resolution, it will print as a 13.33 x 10 inch photo. At 150 dpi, the image will print as a 26.67 x 20 inch photo.
If you want an image to print as a specific size, you can either let your software change the resolution and let the print driver resample the image for output, or you can manually resample to the correct resolution which means changing the pixel size of the image. In most cases both options will have the same effect.