Privacy-first • 100% local processing

Change ID Photo Background Color — Free Online, No Upload

Replace the background color of any ID or passport photo instantly — entirely in your browser, with nothing uploaded to any server. Choose from preset colors (white, blue, red, grey) or pick any custom hex color. A smart 3-pass flood-fill algorithm handles the replacement with feathered edges and automatic cleanup of background color trapped in hair gaps. Download as a lossless PNG ready for official document submission.

100% Private — No Upload Lossless PNG Output Smart Hair-Edge Cleanup Remove Background Too
Drag & drop your photo JPG or PNG — stays on your device. Nothing is uploaded.
Selected: No file selected
Ready. Choose a photo to start.
Current Background Color (to replace)

Click the image on the right to sample the background, or pick manually:

#FFFFFF Click to pick
New Background Color
Remove Background Transparent (PNG)
#0047AB Custom color
Tolerance (edge sensitivity)
Color matching range 30
Precise More coverage
Hair Gap Cleanup (passes)
Fill background trapped in hair 4
Conservative Aggressive fill
Output Format
💡 PNG is recommended for ID photos — it preserves 100% quality with no compression artifacts. JPEG may cause color banding near edges.
Privacy Notice
Processed entirely in your browser. We do not upload, store, or log your files.

Preview

Click image to sample background color
Upload a photo to get started
Original photo
Original — click to sample color
Result photo
Result

How to Change an ID Photo Background Color

Step-by-step guide

This tool uses a 3-pass flood-fill algorithm running entirely in your browser to replace the background color of a photo with surgical precision. It starts by identifying all background pixels reachable from the image edges, then cleans up color trapped in fine gaps (such as hair strands), and finally applies smooth edge feathering to avoid hard color halos at the boundary between the subject and the background.

Step 1 — Upload Your Photo

Click Choose Photo or drag and drop a JPG or PNG file. Once loaded, the original photo appears in the right panel. The tool automatically samples the color of the top-left corner of the image as the likely background color — this is displayed in the Current Background Color picker.

Step 2 — Sample or Set the Source Color

The tool needs to know which color to replace. The auto-sampled color is usually correct for plain-background photos. To adjust it, click directly on the background area of your photo in the preview panel — the tool samples the pixel color at that exact point. Alternatively, use the color picker to set any color manually. For best results, click on a clear area of the background that is not near the edges of the subject.

Step 3 — Choose the New Background Color

Select your target color from the preset swatches or the custom color picker. Common official ID photo standards:

  • White (#FFFFFF) — US passport, US visa, UK passport, Australian passport, Indonesian passport, most international passports.
  • Cobalt Blue (#0047AB) — Indonesian KTP for odd birth years, some visa application types.
  • Red (#CC0000) — Indonesian KTP for even birth years, some national ID documents.
  • Light Grey (#D3D3D3) — Certain Asian country IDs and civil service documents.
  • Sky Blue / Light Blue — Some regional ID cards and health documents.
  • Transparent (Remove Background) — Removes the background entirely, producing a PNG with a transparent background. Useful before placing the photo on a colored template or printed form.

Step 4 — Adjust Tolerance and Hair Gap Cleanup

Two sliders control how aggressively the algorithm replaces the background:

  • Tolerance — Controls how similar a pixel must be to the source color to be replaced. Low values (5–20) only replace very exact matches — best for clean, uniform studio backgrounds. Higher values (40–80) catch more variation, useful for slightly uneven or gradient backgrounds. Start at 30 (default) and adjust if needed.
  • Hair Gap Cleanup (Fringe Passes) — Each pass targets background color that got trapped inside hair strands and fine edges. The default value of 4 works for most photos. Increase to 8–12 if residual original background color remains in hair. Decrease if the tool is accidentally affecting areas near the face or clothing.

Step 5 — Apply and Download

Click Apply. The algorithm runs in three passes and the result appears in the preview. Compare it with the original to verify the background was correctly replaced and the subject edges look clean. If the result needs refinement, adjust Tolerance or Hair Gap Cleanup and click Apply again — the tool is non-destructive and always works from the original image. When satisfied, click Download to save the file.

Output Format: PNG vs JPEG

PNG (recommended) uses lossless encoding — no quality is lost during saving. The replaced pixels are stored exactly as computed, with no JPEG compression artifacts near edges. This is the format required by most official document submission systems. JPEG produces smaller files but introduces compression artifacts, particularly visible as color banding near the edge where the new background meets the subject. Choose JPEG only when file size is a strict constraint.

How the Algorithm Works

The replacement uses three passes. Pass 1 performs a BFS (Breadth-First Search) flood-fill starting from all four edges of the image, marking every pixel reachable from outside that matches the source color within the tolerance range. This handles large open background areas efficiently. Pass 2 (fringe cleanup) targets background color that is isolated inside hair strands or fine gaps — any unmarked pixel that strongly matches the source color and is adjacent to a marked pixel gets pulled into the replacement. This is repeated for the configured number of passes. Pass 3 applies edge feathering: pixels in the transition zone between replaced and non-replaced areas receive a smooth blend toward the new color, eliminating color halos and hard edges.

Frequently Asked Questions

About ID photo background replacement
Is my photo uploaded to a server?

No — your photo never leaves your device. All processing happens entirely in your browser using the HTML5 Canvas API and JavaScript. No image data is transmitted over the internet at any point. This makes the tool safe for ID photos, passport photos, and any other personal images you would not want to upload to a third-party service.

What background color do I need for a US passport photo?

US passport photos require a plain white background (#FFFFFF). The background must be white or off-white with no patterns, shadows, or other people visible. The same requirement applies to US visa photos. Select the White preset swatch or enter #FFFFFF in the custom color picker.

What background color is required for Indonesian KTP and passport?

Indonesian KTP (national ID) uses blue background for people born in odd-numbered years, and red background for even-numbered years. Indonesian passport photos require a white background. Use the Blue or Red preset swatches for KTP. Always verify the exact shade required with the issuing office, as the specific hex value can vary slightly.

Will the image quality be affected?

No, when using PNG output (the recommended setting). PNG is lossless — only the background pixels are mathematically recolored, and all other pixels remain bit-for-bit identical to the original. If you choose JPEG output, minor compression artifacts may appear near color boundaries. For official ID and passport photos where quality must be preserved, always use PNG.

What is the Tolerance setting and how should I adjust it?

Tolerance controls how similar a pixel's color must be to the sampled source color to be included in the replacement. A low value (5–20) only replaces pixels very close to the exact source color — best for clean, evenly-lit studio backgrounds. A higher value (40–80) catches more variation, useful for backgrounds with slight shadows, gradients, or uneven lighting. Start at the default (30) and increase gradually if residual background remains visible after applying.

What does Hair Gap Cleanup do?

The main flood-fill algorithm (Pass 1) can only reach background pixels that are connected to the image edges. Background color trapped inside hair strands — those tiny specks visible between individual hairs — cannot be reached from outside. Hair Gap Cleanup (Pass 2 fringe iterations) handles this: it repeatedly expands the replacement into any unmasked pixel that matches the source color and is adjacent to an already-replaced pixel. Increase the slider value if residual color still shows in hair. Decrease it if the tool accidentally bleeds into the subject.

What if the edges look rough or have a color halo?

The algorithm automatically applies edge feathering — a smooth blend zone at the boundary between replaced and non-replaced pixels. If a color halo still appears at hair edges, try increasing both the Tolerance and Hair Gap Cleanup values, then click Apply again. If the replacement is bleeding into the face or clothing, reduce Tolerance slightly. The tool always works from the original image, so repeated adjustments do not degrade quality.

Can I remove the background entirely?

Yes. Click the Remove Background option (the checkerboard swatch). This removes the background by making those pixels fully transparent. The output is automatically set to PNG, which supports transparency. The resulting image can be used on any colored background template, layered in a photo editor, or placed onto a colored form. This option uses the same 3-pass algorithm for clean edge detection.

Which background colors are standard for ID photos internationally?

White (#FFFFFF) — US, UK, Australia, Canada, Japan, Indonesia (passport). Blue (#0047AB or similar) — Indonesia KTP (odd birth year), some visa types. Red (#CC0000) — Indonesia KTP (even birth year), some national documents. Light Grey (#D3D3D3) — Certain Asian IDs and civil service documents. Light Blue (#87CEEB) — Some regional health cards and government IDs. Always verify exact requirements with the issuing authority before printing.

Does the tool work on photos with complex hair or fine edges?

Yes, better than simple color-replacement tools. The 3-pass algorithm is specifically designed for photos with hair, wispy edges, and fine details. The flood-fill approach (rather than simple pixel-by-pixel replacement) avoids replacing pixels that happen to match the background color but are part of the subject — like similarly-colored clothing or skin tones. Edge feathering produces a smooth transition even around curly or fine hair strands. For very complex hair against a similar-colored background, increase Tolerance and Hair Gap Cleanup passes.

Why Use Alfreto to Change ID Photo Background?

What makes this tool different

Most background removal tools use AI models that run on remote servers — meaning your ID photo is uploaded to a third party. For a document photo containing your face and identity information, that is an unnecessary privacy risk. Alfreto processes everything locally using a purpose-built pixel algorithm, with no upload required and no AI service involved.

🔒 Complete Privacy Your face and identity document photo never reaches any server. No AI service processes it, no third party stores it. The tool runs entirely in your browser tab — close it when done and there is no trace anywhere online.
🖼️ Lossless PNG Output Output is always lossless PNG by default. Only background pixels are changed — all other pixels are preserved exactly. No JPEG re-compression, no quality degradation, ready for submission to official government portals.
✂️ Smart Edge Algorithm The 3-pass flood-fill with hair-gap cleanup and edge feathering produces cleaner results on real-world ID photos than simple paint-bucket tools — handling the fine hair strands and color-fringe artifacts that basic algorithms miss.
🎨 Precise Color Control Click any point on your photo to sample the exact background color, then choose from official preset colors or enter any hex code. Tolerance and cleanup sliders give you fine control that auto-AI tools cannot offer.

Related tools

More image tools

Title

Message