DEV Community

ricco020
ricco020

Posted on Edited on

Passport photo sizes in pixels: the mm to px arithmetic and three traps

Passport photo rules are written in millimetres or inches. Upload forms ask for pixels. The bridge between the two is one line of arithmetic, and it is easy to get slightly wrong.

The formula

pixels = millimetres / 25.4 * dpi
Enter fullscreen mode Exit fullscreen mode

25.4 is the number of millimetres in an inch, and dpi is the print resolution. At 300 dpi:

Print size Used by Pixels at 300 dpi Pixels at 600 dpi
50.8 x 50.8 mm (2 x 2 in) US passport, US visa, DV lottery, India visa, OCI 600 x 600 1200 x 1200
35 x 45 mm UK, Australia, Schengen visa 413 x 531 827 x 1063
50 x 70 mm Canada passport 591 x 827 1181 x 1654

In JavaScript:

const px = (mm, dpi = 300) => Math.round(mm / 25.4 * dpi);
px(35);   // 413
px(45);   // 531
px(50.8); // 600
Enter fullscreen mode Exit fullscreen mode

Three traps

1. Rounding the wrong way. 35 mm at 300 dpi is 413.39 px. If you floor the width and ceil the height, the aspect ratio drifts and a strict validator may complain. Round both to nearest, and compute from millimetres each time instead of scaling an already rounded number.

2. The form wants more pixels than the print needs. The 300 dpi figure is the print size, not always the upload size. GOV.UK asks for a digital photo of at least 600 x 750 px for a 35 x 45 mm photo, and the US online passport renewal asks for at least 1200 x 1200. The fix is to keep the same aspect ratio and raise the density: scale factor f = max(1, minW / w, minH / h), then width = ceil(w * f) and dpi = round(300 * f). The file still prints at the right physical size because the density went up with the pixel count.

3. File weight caps. The US visa form (DS-160) and the Diversity Visa entry form cap the JPEG at 240 kB. A 600 x 600 portrait at quality 90 is usually well under that, but a noisy phone photo may not be. Lower the JPEG quality in a loop until the file fits, do not shrink the dimensions.

Head size is a fraction, not a pixel count

Rules give the head height in millimetres (UK: 29 to 34 mm from chin to crown on a 45 mm photo) or as a share of the image (US visa: 50 to 69 % of the height). Convert both to fractions of the photo height and the crop logic becomes resolution independent: 29 / 45 = 0.64 and 34 / 45 = 0.76 for the UK.

A reference file and a calculator

I put the ten formats I work with (sizes, pixel values, head rule, background rule, link to the official page for each) in a small open file, with an in-browser converter:

The same table drives passportphoto2x2.com, a cropping service I work on (private and paid for the final file, not a government site). Its guide on passport photo size in pixels goes through the US case in more detail.

Rules change, so read the official page before you apply. The file links each row to its source.

Top comments (0)