Image size explained: pixels, DPI, file size and quality

Updated:

“Make the image smaller” can mean three different things: fewer pixels, a smaller printed size, or fewer bytes in the file. They are linked, but changing one does not always change the others, which is why an image can look sharp on a phone and blurry on paper, or weigh 5 MB while looking no better than a 300 KB copy.

This guide separates the three, explains what the DPI and quality settings really do, and backs the advice with measurements: we encoded the same 1280 × 854 photo of a riverside street at different sizes and qualities in Chrome, the engine the nTools resizer uses, and compared the results with the original.

Three sizes that are easy to mix up

Most problems come from changing one of these while expecting another to follow: raising the DPI to make a print sharper, or lowering the quality to fix a photo that is simply too large in pixels.

Pixels and megapixels

A megapixel is a million pixels. A typical 12-megapixel phone photo is 4032 × 3024 pixels, which is 12,192,768 pixels.

The file on disk is compressed, but to show or edit the picture a program has to decode it into every pixel. At four bytes per pixel (red, green, blue and transparency) that 12-megapixel photo takes about 49 MB of memory, whatever the size of the file. That is why a phone can struggle with dozens of large photos at once, and why a web page full of oversized images feels slow even after they have downloaded.

Our 1280 × 854 test photo shows the gap between pixels and file size. Stored raw, three bytes per pixel, it is 3.3 MB. As a PNG, which loses nothing, it is 2.3 MB. As a JPEG at quality 82 it is 323 KB, about a seventh of the PNG, and it looks the same at normal viewing size.

DPI only matters on paper

JPEG files can carry a density value: the JFIF standard has a field for dots per inch or per centimetre, and camera metadata has a similar one. Many photos say 72 or 300 there. The number does not change a single pixel, the file size or how the picture looks on screen. Screens show pixels, not inches.

Changing 72 DPI to 300 DPI without resampling only rewrites that field. If a form demands “300 DPI”, what it usually needs is enough pixels for the printed size. The sum is simple: printed width = pixels ÷ pixels per inch, and one inch is 2.54 cm.

Print sizeAt 150 pixels per inchAt 300 pixels per inch
Photo 10 × 15 cm591 × 886 px1181 × 1772 px
A4, 21 × 29.7 cm1240 × 1754 px2480 × 3508 px
12 MP photo (4032 × 3024 px)68 × 51 cm34 × 26 cm

The print service decides which density it wants; with that number, the table tells you whether the photo has enough pixels. Adding pixels on a computer does not help, as the section on enlarging shows.

Screens: CSS pixels and sharp displays

Web pages are laid out in CSS pixels, a unit defined as 1/96 of an inch. On older screens one CSS pixel was one dot on the screen. Phones and many laptops now use two or three screen dots for each CSS pixel; browsers report this as the device pixel ratio.

So an image shown 600 CSS pixels wide needs about 1200 pixels to look crisp on a phone with a ratio of 2. Give it only 600 and it is stretched and looks soft; give it 4000 and visitors download pixels they never see. Websites can offer several sizes with the srcset attribute and let each browser pick the one that suits its screen.

Resizing: smaller is safe, larger adds nothing

Halving the width and height keeps a quarter of the pixels, and the file shrinks roughly in step. In our test, all at JPEG quality 82:

DimensionsShare of the pixelsJPEG sizeWebP size
1280 × 854100%323 KB288 KB
960 × 64156%180 KB159 KB
640 × 42725%89 KB80 KB
320 × 2146%23 KB21 KB

Going the other way does not bring detail back. We shrank the photo to 320 pixels wide and enlarged it again to 1280: the result scored 0.59 on SSIM, a measure of how close two images are where 1 means identical, against 0.96 for the full-size JPEG at quality 82. It is visibly blurred. Enlarging only spreads the existing pixels over more space; AI upscalers make it look sharper by inventing plausible detail, which is not the original.

Browsers can scale an image with more or less careful smoothing; the nTools resizer asks for the highest setting. Keep the proportions when resizing, or faces and circles stretch. When an exact shape is needed, such as a square profile picture, crop first and then resize.

Resize and compress images

What the quality number means

The quality setting is not a percentage of anything. For JPEG it is a 0 to 100 scale, defined by the reference JPEG library, that controls how coarsely detail is rounded away; its documentation suggests 50 to 95 for photos and warns that above about 95 the file grows dramatically for little gain. WebP has its own scale, so the same number does not mean the same thing in both formats.

Our measurements, on the 1280 × 854 photo in Chrome, with SSIM against the original (1 means identical):

QualityJPEG sizeJPEG SSIMWebP sizeWebP SSIM
50181 KB0.915180 KB0.944
75270 KB0.950231 KB0.963
82323 KB0.962288 KB0.976
92466 KB0.981410 KB0.988
95570 KB0.987474 KB0.990
1001275 KB0.9991306 KB1 (lossless)
PNG2302 KB1 (lossless)––

Three things stand out. Going from 95 to 100 more than doubles a JPEG for almost nothing visible. At the same similarity WebP is about a third smaller than JPEG, in line with Google’s figure of around 30%: WebP at 82 matches JPEG at 90 in 288 KB instead of 428 KB. And in Chrome, WebP at 100 switches to lossless compression, which here came out 43% smaller than the PNG.

When a website or program does not say which quality it uses, Chrome’s defaults are 92 for JPEG and 80 for WebP; we measured both by saving without a quality value. The nTools resizer starts at 82.

Colour detail goes first

JPEG stores brightness and colour separately, and the eye is far more sensitive to brightness. Most encoders therefore keep colour at half the width and half the height, a scheme called 4:2:0: a quarter of the colour information, with little visible effect on photos. It is the default in the reference JPEG library, and Chrome used it at every quality we tried except 100.

Where it shows is thin, saturated detail: red text on a white background, coloured lines in a chart or a logo. The edges bleed. For screenshots and graphics with text, PNG or lossless WebP avoids the problem, as the first part of this series explains.

Saving again and again

Each time a lossy file is opened, edited and saved, it is compressed again. How much is lost depends on whether the settings change. We saved the test photo ten times in a row:

Keep the original, make every copy from it, and do the resizing and quality change in one step at the end.

Sizes that work

These starting points come from the measurements above. Our test photo used about 0.3 bytes per pixel at JPEG quality 82; busy scenes with foliage or gravel need more, plain skies and walls less.

UseLong sideFormat and qualityExpect roughly
Image in a web pageDisplay width × 2WebP 75–82 or JPEG 80–85100–400 KB
Email or messaging, several photos1600–2000 pxJPEG 80–850.5–0.9 MB each
Upload form with a 1 or 2 MB limit2000 pxJPEG 80under 1 MB
PrintPrint size × the density the printer asks forJPEG 92–95, or the originalseveral MB
Screenshot or graphic with textUnchangedPNG or lossless WebPdepends on content

Gmail allows 25 MB of attachments per message on personal accounts and turns anything larger into a Google Drive link, so a handful of untouched phone photos can already reach the limit.

Everything the nTools image tools do happens in your browser: the photo is not uploaded anywhere.

Image format converter

Frequently asked questions

Does changing 72 DPI to 300 DPI improve a photo?

No. It only rewrites a number in the file. The pixels, the file size and the look on screen stay exactly the same. A print gets sharper only with more pixels, taken by the camera, not added afterwards.

Why does my resized photo look blurry?

Usually because it was made smaller than the space it is shown in and then stretched, for example on a phone screen with a device pixel ratio of 2 or 3. Make it about twice the width at which it is displayed.

What quality should I use for JPEG?

Between 75 and 85 suits most photos on screens. Above 95 the file grows quickly for little visible gain, and 100 is not lossless.

Is WebP always smaller than JPEG?

For photos at the same visual quality it usually is, by about a third in our test. Check that the place you are sending it to accepts WebP; some older programs and forms do not.

Can a small image be enlarged without losing quality?

No. Enlarging cannot recreate detail that was never captured. AI upscalers can make the result look sharper, but they invent the extra detail.

Why is my PNG photo so much bigger than the JPEG?

PNG keeps every pixel exactly, which suits screenshots and graphics. For photos it produced a file about seven times larger than a JPEG at quality 82 in our test, with no visible difference at normal viewing size.

Previous in the series ← Image formats explained: JPEG, PNG, WebP, AVIF and HEIC

References

  1. MDN — <length>: absolute length units (px, in)
  2. MDN — Window: devicePixelRatio property
  3. MDN — Responsive images
  4. MDN — HTMLCanvasElement: toBlob() method
  5. MDN — CanvasRenderingContext2D: imageSmoothingQuality property
  6. JPEG File Interchange Format (JFIF), version 1.02
  7. libjpeg-turbo 3.0.2 — usage.txt (cjpeg: -quality, -sample)
  8. Google for Developers — WebP: Frequently Asked Questions
  9. web.dev — Serve images with correct dimensions
  10. Gmail Help — Send attachments with your Gmail message

Related guides