<?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: Peter Hoang</title>
    <description>The latest articles on DEV Community by Peter Hoang (@peter_hoang_9b48d62c9a6dd).</description>
    <link>https://dev.to/peter_hoang_9b48d62c9a6dd</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%2F4268056%2F841a0ff4-cf0d-4972-86d4-b86ff35829f2.jpg</url>
      <title>DEV Community: Peter Hoang</title>
      <link>https://dev.to/peter_hoang_9b48d62c9a6dd</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/peter_hoang_9b48d62c9a6dd"/>
    <language>en</language>
    <item>
      <title>I built a passport photo maker that never uploads your face</title>
      <dc:creator>Peter Hoang</dc:creator>
      <pubDate>Fri, 27 Nov 2026 20:39:38 +0000</pubDate>
      <link>https://dev.to/peter_hoang_9b48d62c9a6dd/i-built-a-passport-photo-maker-that-never-uploads-your-face-ncj</link>
      <guid>https://dev.to/peter_hoang_9b48d62c9a6dd/i-built-a-passport-photo-maker-that-never-uploads-your-face-ncj</guid>
      <description>&lt;p&gt;I needed a passport photo. The shop wanted $15+, and the "free" websites I tried either put a watermark on the result, asked me to pay to download, or uploaded my face to their server. For a photo that goes on an ID document, that last one bugged me the most.&lt;/p&gt;

&lt;p&gt;So I built my own: &lt;strong&gt;&lt;a href="https://passportphotos.pages.dev" rel="noopener noreferrer"&gt;passportphotos.pages.dev&lt;/a&gt;&lt;/strong&gt;. It's free, open source, and everything happens in your browser. Here's how it works.&lt;/p&gt;

&lt;h2&gt;
  
  
  The idea
&lt;/h2&gt;

&lt;p&gt;Drop in a photo, pick your country, and the app:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;crops and scales it to the official size (35×45 mm, 2×2 in, and 163 country rules)&lt;/li&gt;
&lt;li&gt;checks head height, eye line, tilt, centring, eyes open, gaze, expression, lighting and background&lt;/li&gt;
&lt;li&gt;replaces the background with the colour your country asks for (France wants light grey, the UK wants cream, most others want white)&lt;/li&gt;
&lt;li&gt;makes a print sheet so you can print 4–8 photos on 6×4 paper for a few cents&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;No account, no cookies, no payment. It works offline after the first visit and can be installed as an app.&lt;/p&gt;

&lt;h2&gt;
  
  
  Face detection in the browser
&lt;/h2&gt;

&lt;p&gt;I used &lt;a href="https://ai.google.dev/edge/mediapipe/solutions/vision/face_landmarker" rel="noopener noreferrer"&gt;MediaPipe Tasks Vision&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;FaceLandmarker&lt;/strong&gt; gives 478 face landmarks plus blendshapes. The blendshapes are great for checks like "eyes open" (&lt;code&gt;eyeBlink*&lt;/code&gt;), "looking at the camera" (&lt;code&gt;eyeLook*&lt;/code&gt;) and "neutral expression" (&lt;code&gt;mouthSmile*&lt;/code&gt;, &lt;code&gt;jawOpen&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ImageSegmenter&lt;/strong&gt; (selfie segmenter) gives a person mask, used for background replacement and to find the top of the head.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The models and WASM files are served from the same site, so nothing calls a third-party server.&lt;/p&gt;

&lt;h2&gt;
  
  
  Finding the top of the head
&lt;/h2&gt;

&lt;p&gt;Passport rules measure &lt;strong&gt;chin to crown&lt;/strong&gt;, but face landmarks stop at the forehead - hair isn't part of the face mesh. So I walk upwards from the forehead landmark through the person mask until it ends. That point is the crown. To avoid silly results from big hair or a noisy mask, the distance is clamped to a sensible fraction of the face length.&lt;/p&gt;

&lt;h2&gt;
  
  
  One transform for everything
&lt;/h2&gt;

&lt;p&gt;Every edit (zoom, move, tilt) goes into a single transform:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;out(mm) = offset + scale · R(θ) · (p − pivot)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The pivot is the midpoint between the eyes. θ levels the eyes automatically, plus any tilt the user adds. The scale puts the head height in the middle of the allowed range. Because preview, checks and final render all use the same transform, what you see is exactly what gets measured and exported.&lt;/p&gt;

&lt;h2&gt;
  
  
  Checks that explain themselves
&lt;/h2&gt;

&lt;p&gt;Each check returns &lt;code&gt;{ id, status, message, vars }&lt;/code&gt; with no language baked in, so the UI translates it. That made it easy to support 20 languages. Instead of "failed", users see something like "Head 31.2 mm - must be 32–36 mm".&lt;/p&gt;

&lt;h2&gt;
  
  
  Hosting for $0
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Vite + React + Mantine&lt;/li&gt;
&lt;li&gt;Cloudflare Pages (free), plus one tiny Pages Function that reads the visitor's country to suggest the right rules&lt;/li&gt;
&lt;li&gt;A build step pre-renders 3,280 static pages (20 languages × 163 countries) for search engines&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try it / help out
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;App: &lt;a href="https://passportphotos.pages.dev" rel="noopener noreferrer"&gt;https://passportphotos.pages.dev&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Code (MIT): &lt;a href="https://github.com/hieuhoangtrung/passport-photo" rel="noopener noreferrer"&gt;https://github.com/hieuhoangtrung/passport-photo&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I couldn't confirm every country's rules, so if yours looks wrong, please open an issue. Feedback is very welcome! 🙌&lt;/p&gt;

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