Formulas and sources
Each formula this calculator uses, where it comes from, and what it leaves out. "How it works" shows the same formula with your own numbers.
The other side, with the shape kept
Every mode
- Height
- the new height in pixels
- Width
- the new width you type
- Picture H
- the picture’s own height
- Picture W
- the picture’s own width
Rounded to a whole pixel, at least 1. Typing the height instead gives the width the same way. A percent scales both sides: 50% of 1080 × 1350 is 540 × 675.
Source: Standard formula; no single publisher.
Pixels for a print size
Every mode
- Pixels
- the width or height in pixels
- Inches
- the print width or height
- DPI
- pixels per inch; a blank field is 300
Centimeters are divided by 2.54 and millimeters by 25.4 first, and each side is rounded to a whole pixel: 35 × 45 mm at 300 DPI is 413 × 531.
Source: An inch is exactly 25.4 millimeters, NIST SP 811 [1].
Fit and Fill
Every mode
- Box W
- the width you type
- Box H
- the height you type
- W
- the picture’s width
- H
- the picture’s height
Fit shows the whole picture at the smaller scale, centered, with white bars. Fill covers the box at the larger scale and cuts the overflow, half on each side: 1080 × 1350 into 630 × 810 is scale 0.6, keeping 1050 × 1350 of the picture and cutting 15 pixels off each side. Stretch scales each side on its own.
Source: Standard formula; no single publisher.
Each new pixel, shrinking
Every mode
- New
- a new pixel’s red, green or blue
- Share
- how much of an old pixel it covers
- Opacity
- that pixel’s opacity, 0 to 1
- Old
- that pixel’s red, green or blue
Every old pixel under the new one counts by the part of it covered, so a new pixel over two and a half columns weighs the half column by half. Weighting by opacity keeps a transparent pixel’s hidden color out of the edges. Its opacity is the covered pixels’ average. When either side grows, the browser’s own smoothing draws it instead.
Source: An area average, a standard method with no single publisher; weighting by opacity is this page’s choice, stated here.
DPI in the file
Every mode
- Per metre
- the PNG’s pixels per metre
- DPI
- the DPI you set
A JPEG stores the DPI itself, its unit set to dots per inch. A PNG stores pixels per metre, rounded: 300 DPI is 11,811. Neither changes a pixel. WebP is saved without one.
Source: The JPEG’s JFIF header from [2], the PNG’s pHYs chunk from [3]; an inch is 0.0254 metre [1].
The crop in pixels
Every mode
- Crop
- an edge of the box in the picture’s pixels
- Fraction
- where the edge sits, as a share of the side
- Side
- the picture’s width or height
The box is kept as shares of the upright picture, so it stays on the same part whatever the turn, and each edge is rounded to a whole pixel. The size is then worked from the box, turned: a turn of 90° swaps its width and height. Turns and the mirror move whole pixels, so nothing is blurred.
Source: This page’s method, stated here; no single publisher.
Whiten the paper
Every mode
- Level
- a pixel’s new red, green or blue
- Old
- its value before
- Ink
- the channel’s darkest 1%
- Paper
- the channel’s median, less 8
Only when you tick it. Each channel on its own, from the picture’s own pixels: paper is most of a signature’s page, so its median, less 8 for the grain, turns white, and the darkest 1% black. Ink and paper stay at least 32 levels apart, so a page of paper alone turns white. Values past either end stay at 0 or 255.
Source: This page’s method, stated here; no single publisher.
The range in bytes
File Size (KB) mode
- Max bytes
- the most bytes the file may have
- Max KB
- the maximum you type
- Min bytes
- the fewest bytes it may have
- Min KB
- the minimum you type, if any
The stricter count at each end, so the file passes a form that counts a KB as 1,000 bytes or as 1,024: 20 to 50 KB is 20,480 to 50,000 bytes. A range too narrow for that uses 1,024 at both ends.
Source: This page’s rule, stated here; no single publisher.
The quality found
File Size (KB) mode
- Quality
- the JPEG or WebP quality the file is saved at
- Bytes
- the file’s real size at a quality tried
The steps are 0.50 to 0.99 by 0.01, then 0.995 and 1, because sizes jump near the top. Each quality tried is saved and its bytes counted, about seven tries a file. The page goes no lower than 0.50: past that it offers fewer pixels. A PNG has no quality, so its one file is checked.
Source: This page’s method, stated here; no single publisher.
A size that meets the range
File Size (KB) mode
- Scale
- both sides of the size tried, as a share of these
- Target bytes
- the minimum when too small, the maximum when too large
- Bytes
- the file’s real size at a quality tried
A file’s bytes follow its pixel count, so the first size tried is scaled by the square root of the shortfall, both sides alike, then by steps of 5%, at most 24, up to 8,000 pixels a side. The size is offered; the file is made at it only when you choose it.
Source: This page’s method, stated here; no single publisher.
Padding to the minimum
File Size (KB) mode
- Padded
- the padded file’s bytes
- Min bytes
- the fewest bytes it may have
- Max bytes
- the most bytes the file may have
Only when you choose Padding, and only for a JPEG. The bytes are comment blocks placed after the file’s header blocks, each at most 65,533 bytes, the first starting with a line saying it is padding. Decoders skip them, so no pixel changes, and nothing is added after the end of the image.
Source: This page’s method, stated here; the JFIF header stays first in the file, as [2] requires.
Sources
- National Institute of Standards and Technology. NIST Guide to the SI, Appendix B.9: Factors for units listed by kind of quantity or field of science, length and mass. Special Publication 811.
- International Telecommunication Union (ITU-T). Recommendation ITU-T T.871, Information technology - Digital compression and coding of continuous-tone still images: JPEG File Interchange Format (JFIF), section 10.1, JFIF file syntax: units, Hdensity and Vdensity. May 2011, with Erratum 1 of March 2013.
- World Wide Web Consortium (W3C). Portable Network Graphics (PNG) Specification (Third Edition), section 11.3.4.3, pHYs Physical pixel dimensions. W3C Recommendation, June 24, 2025.
What this calculator does not cover
- Enlarging: a larger file is smoothed between the pixels the picture has; it gains no detail.
- Very large images: past a browser’s canvas limit (16.7 megapixels on an iPhone) the image is opened smaller, and the page says so; the new size is at most 8,000 pixels a side and 16.7 megapixels.
- WebP: Safari and the browsers on an iPhone cannot save it.
- Animated images: only the first frame is resized.
- Form checks: the page sets pixels, KB and format, and cannot check a face, a background, a photo’s date or a signature’s ink.
- A KB range: quality comes in steps, so a very narrow range can fall between two of them; widen it or change the size.
- Color profiles: the file is saved in sRGB, the colors your screen shows; a wider-gamut photo’s most vivid colors are brought inside it.
Sources checked on
How we choose sources and test the calculators: How CalcTrail calculates