<?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: Rajendra Sahu</title>
    <description>The latest articles on DEV Community by Rajendra Sahu (@raredigix).</description>
    <link>https://dev.to/raredigix</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%2F4175979%2F7dbc7e09-453e-4d41-989f-36e260f9de0c.jpg</url>
      <title>DEV Community: Rajendra Sahu</title>
      <link>https://dev.to/raredigix</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/raredigix"/>
    <language>en</language>
    <item>
      <title>How I Built an AI-Assisted Passport Photo Studio in the Browser</title>
      <dc:creator>Rajendra Sahu</dc:creator>
      <pubDate>Mon, 19 Oct 2026 11:39:10 +0000</pubDate>
      <link>https://dev.to/raredigix/how-i-built-an-ai-assisted-passport-photo-studio-in-the-browser-361j</link>
      <guid>https://dev.to/raredigix/how-i-built-an-ai-assisted-passport-photo-studio-in-the-browser-361j</guid>
      <description>&lt;p&gt;Getting a passport photo taken in 2026 is still surprisingly painful. &lt;/p&gt;

&lt;p&gt;You either visit a pharmacy or studio and pay $15–$25 for two tiny prints, or take a selfie at home and risk an application rejection because your head size was 2mm off, the lighting was uneven, or the background wasn't the exact shade of off-white required by the consulate.&lt;/p&gt;

&lt;p&gt;I wanted a better, faster, and cheaper way to do this from home without sacrificing government compliance. &lt;/p&gt;

&lt;p&gt;Here is how I built &lt;strong&gt;&lt;a href="https://passportphotobox.com" rel="noopener noreferrer"&gt;PassportPhotoBox&lt;/a&gt;&lt;/strong&gt; an in-browser passport and visa photo maker and the technical choices behind it.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Core Problem
&lt;/h2&gt;

&lt;p&gt;Different countries have wildly different biometric photo standards:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;US &amp;amp; India:&lt;/strong&gt; 2 × 2 inches (51 × 51 mm), with head height between 50% and 69%.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;UK &amp;amp; Schengen Area:&lt;/strong&gt; 35 × 45 mm, with face height between 32 mm and 36 mm.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Canada:&lt;/strong&gt; 50 × 70 mm, with specific head-to-chin proportions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Most existing online tools either require an expensive subscription, spam users with ads, or worst of all upload personal facial photos to unknown remote servers.&lt;/p&gt;

&lt;p&gt;I set out to build a platform guided by three rules:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Accurate compliance&lt;/strong&gt; for 100+ country standards.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Privacy first:&lt;/strong&gt; Process images in the user’s browser as much as possible.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Print-ready output:&lt;/strong&gt; Generate 300 DPI 4×6-inch sheets so users can print 4–6 photos at any local print kiosk for under 50 cents.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  The Tech Stack
&lt;/h2&gt;

&lt;p&gt;I chose a modern, performance-focused stack:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Framework:&lt;/strong&gt; Next.js (App Router) + React 19 + TypeScript&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Styling:&lt;/strong&gt; Tailwind CSS + Radix UI primitives&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vision &amp;amp; AI:&lt;/strong&gt; &lt;code&gt;@mediapipe/tasks-vision&lt;/code&gt; (client-side face landmark detection)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Image &amp;amp; Canvas Processing:&lt;/strong&gt; Native HTML5 Canvas API&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Document &amp;amp; Print Generation:&lt;/strong&gt; &lt;code&gt;pdf-lib&lt;/code&gt; (for generating exact 300 DPI print-ready sheets)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Backend &amp;amp; Auth:&lt;/strong&gt; Supabase (PostgreSQL + Auth + Edge Functions)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  How It Works (High-Level Pipeline)
&lt;/h2&gt;

&lt;p&gt;The photo pipeline follows four simple steps:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[User Photo] 
    │
    ▼
[Client-Side Face Detection (MediaPipe)]
    │
    ▼
[Biometric Alignment &amp;amp; Crop (HTML5 Canvas)]
    │
    ▼
[Background Cleanup &amp;amp; Contrast Fine-Tuning]
    │
    ▼
[Single Digital File + 4x6" Print-Ready Sheet (300 DPI)]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  1. In-Browser Face &amp;amp; Landmark Detection
&lt;/h3&gt;

&lt;p&gt;Instead of sending raw user selfies across the internet to an external server, I used lightweight client-side models with &lt;strong&gt;MediaPipe&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;When a user selects an image, the model detects facial landmarks (eye line, crown of the head, chin tip, and center of face) directly on the device.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Country-Specific Spec Matching
&lt;/h3&gt;

&lt;p&gt;Once face landmarks are identified, the app calculates whether the head size and eye level match the target country’s criteria:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If the user chooses a &lt;strong&gt;US Passport&lt;/strong&gt;, the canvas crops to a 1:1 ratio and ensures the face occupies 50–69% of the frame.&lt;/li&gt;
&lt;li&gt;If they choose a &lt;strong&gt;Schengen Visa&lt;/strong&gt;, it adjusts to a 35:45 ratio with strict vertical alignment.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Users always have manual controls (zoom, pan, rotation, and fine cropping) if they prefer adjusting it themselves.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Background &amp;amp; Lighting Prep
&lt;/h3&gt;

&lt;p&gt;Official guidelines require neutral, plain backgrounds (usually pure white, off-white, or light grey depending on the authority). The app provides automated background removal tools alongside contrast and exposure adjustments so photos pass automated consular checks.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. 300 DPI Print Sheet Export
&lt;/h3&gt;

&lt;p&gt;Consular offices don't accept low-res digital screenshots. Using &lt;code&gt;pdf-lib&lt;/code&gt; and high-density canvas rendering, the app creates a standard &lt;strong&gt;4R (4×6 inch) print layout&lt;/strong&gt; tiled with multiple photo copies at &lt;strong&gt;300 DPI&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Users can save the JPEG or PDF, upload it to any local pharmacy or photo booth app, and print it as a standard 4×6 photo for pocket change.&lt;/p&gt;




&lt;h2&gt;
  
  
  Key Lessons Learned
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Client-side processing builds immediate trust:&lt;/strong&gt; Users are rightfully cautious about uploading personal ID photos online. Processing photos locally in the browser removed a massive friction point.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Edge cases in facial geometry:&lt;/strong&gt; Hair volume, tilts, and varying phone lenses make automated cropping tricky. Giving users a split-view before/after comparison with manual fallback sliders proved essential.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Print dimensions are unforgiving:&lt;/strong&gt; Screen pixels don't equal print inches. Ensuring pixel-perfect 300 DPI coordinate mapping for physical print sheets required strict dimensional calculations.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you have questions about client-side image processing, canvas scaling, or biometric geometry, feel free to drop a comment below!&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>webdev</category>
      <category>nextjs</category>
      <category>react</category>
    </item>
  </channel>
</rss>
