<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jun Liu</title>
    <description>The latest articles on DEV Community by Jun Liu (@freepassportpic).</description>
    <link>https://dev.to/freepassportpic</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4278790%2F7885b2fd-aa2e-434f-9da2-6f195ec66241.png</url>
      <title>DEV Community: Jun Liu</title>
      <link>https://dev.to/freepassportpic</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/freepassportpic"/>
    <language>en</language>
    <item>
      <title>How I crop official-size passport photos entirely in the browser</title>
      <dc:creator>Jun Liu</dc:creator>
      <pubDate>Wed, 02 Dec 2026 15:09:31 +0000</pubDate>
      <link>https://dev.to/freepassportpic/how-i-crop-official-size-passport-photos-entirely-in-the-browser-5hie</link>
      <guid>https://dev.to/freepassportpic/how-i-crop-official-size-passport-photos-entirely-in-the-browser-5hie</guid>
      <description>&lt;p&gt;Passport photo shops are simple in theory: a set size, a head-height band, a plain background, and a print layout. The awkward part, if you would rather not upload a portrait of yourself to a random server, is doing the crop on the device.&lt;/p&gt;

&lt;p&gt;I built a small static site, &lt;a href="https://freepassportpic.pages.dev/" rel="noopener noreferrer"&gt;FreePassportPic&lt;/a&gt;, that does that in the browser. This post is about the constraints, not a feature tour.&lt;/p&gt;

&lt;h2&gt;
  
  
  What “official size” actually means
&lt;/h2&gt;

&lt;p&gt;A US passport photo is 2 × 2 inches, with the head (chin to the top of the head) between 1 and 1 3/8 inches. A lot of visa portals then add a pixel and file-size cap on top of the same composition — for example a square JPEG around 600 × 600 pixels and under 240 KB for a DS-160 upload.&lt;/p&gt;

&lt;p&gt;Other countries are not a trimmed 2 × 2. Canada uses 50 × 70 mm. The UK and many Schengen-style documents use 35 × 45 mm, sometimes with a different head-height band and a cream or light grey background rather than white. Those numbers have to come from the issuing authority’s published page, and they change. A tool can pre-load the last checked spec; it cannot promise that a photo will be accepted.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the photo stays on the device
&lt;/h2&gt;

&lt;p&gt;Face detection, the crop, JPEG compression, and the 4 × 6 / A4 print-sheet layout all run in the page. The image is never posted to the server. That is a product choice, not a privacy badge: it also means the site cannot “fix” a bad original with a cloud model, and it cannot judge glasses glare or expression automatically. Those checks stay visual.&lt;/p&gt;

&lt;p&gt;An optional background-replacement control exists in the UI. I leave it off for US, UK, and Canadian passport use. Those authorities say they reject digitally altered photos, including a swapped backdrop. A real plain wall is the honest path.&lt;/p&gt;

&lt;h2&gt;
  
  
  The print sheet is a different file
&lt;/h2&gt;

&lt;p&gt;Online forms usually want a single JPEG. A paper application often wants a printed 2 × 2 (or 35 × 45 mm) photo. The site tiles the cropped image onto a 4 × 6 inch sheet at 300 DPI (six US 2 × 2 photos on the default preset) or onto A4. The sheet file is not a substitute for a 600 × 600 visa upload, and a kiosk that auto-crops the sheet can shrink the photos. Measuring one photo with a ruler before you cut the rest is more reliable than trusting the print dialog.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I would not claim
&lt;/h2&gt;

&lt;p&gt;This is not a government service. Canada still requires a commercial photographer for a passport print. Some official online forms, such as a UK application where you take the photo during the process, ask you not to crop the picture yourself. The browser tool is for sizes it actually exports, plus composition checks. If a country’s digital upload needs a much larger file than the preset, the page should say so rather than imply a compliant file.&lt;/p&gt;

&lt;p&gt;If you want to try the implementation, the live tool is at &lt;a href="https://freepassportpic.pages.dev/" rel="noopener noreferrer"&gt;freepassportpic.pages.dev&lt;/a&gt;. It is free, with no account and no watermark. Confirm the current rules on the authority’s own site before you apply.&lt;/p&gt;

</description>
      <category>photography</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>privacy</category>
    </item>
  </channel>
</rss>
