Dev.to AI ๐Ÿค– Ai ๐Ÿ‘ 0 ๐Ÿ“– 5 min read

Preserving Window Geometry and Injecting IPTC XMP Provenance in Real Estate Diffusion Pipelines

Across five wide-angle 3:2 and 4:3 vacant property photos tested on December 1, 2026, naive image-to-image diffusion shifted window mullion edges and baseboard corners by 11 to 19 pixels, while an aspect-locked Kontext +

Preserving Window Geometry and Injecting IPTC XMP Provenance in Real Estate Diffusion Pipelines

Across five wide-angle 3:2 and 4:3 vacant property photos tested on December 1, 2026, naive image-to-image diffusion shifted window mullion edges and baseboard corners by 11 to 19 pixels, while an aspect-locked Kontext + 4K upscaling pipeline kept non-furniture architectural zones within a mean absolute pixel error (MAE) of 0.70 to 3.87 out of 255. Pairing that structural lock with lossless JPEG APP1 XMP injection lets browsers stamp California AB 723 side-by-side disclosures and IPTC provenance metadata in under 25 milliseconds without re-encoding image pixels.

Disclosure: I built Listing Virtual Staging (https://listingvirtualstaging.com), and I used AI assistance to organize and edit this engineering write-up around our December 1, 2026 pipeline benchmarks.

Architectural geometry preservation and 4-piece MLS compliance pipeline diagram for Listing Virtual Staging
First-hand test on December 1, 2026: aspect-locked 3:2 room staging keeps window mullions, exterior tree lines, and radiators aligned before 3840px 4K upscaling and APP1 XMP metadata injection.

When real estate listing agents and photographers stage vacant rooms for Multiple Listing Service (MLS) portals, two technical failure modes get photos flagged by compliance reviewers right away.

First, standard diffusion aspect buckets silently crop a native 3:2 DSLR frame (such as 4992 x 3328) or 4:3 smartphone frame into 16:9 or 1:1, or hallucinate away wall radiators, electrical outlets, HVAC grilles, and outdoor neighbor rooflines.

Second, starting in 2026 under California Civil Code Section 1102.6j (AB 723) and CRMLS Rule 11.5.2, virtually staged listing media requires clear disclosure, unaltered original room views, and standardized digital provenance rather than vendor watermarks.

Here is how we solved both problems in TypeScript on Cloudflare Workers and browser Canvas/ArrayBuffer primitives.

1. Preventing Aspect Drift and Architectural Hallucination

Most off-the-shelf staging wrappers resize incoming photos to fixed square or widescreen tensors before inference. Even a 2% aspect mismatch makes original and staged photos fail a 1:1 pixel blink test.

Before sending a room photo to inference, a client-side preflight pass checks four constraints in under 15 milliseconds:

  1. Minimum short-edge resolution (>= 600 px) so super-resolution does not invent fake wood grain.
  2. Aspect ratio bounds (rejecting extreme stitched panoramas > 2.6:1 or narrow vertical strips < 0.5:1).
  3. Mean luminance bounds (catching pitch-black underexposed basements or blown-out HDR windows).
  4. Native ratio locking (routing 3:2, 4:3, 16:9, or 4:5 inputs to exact matching output dimensions).

During our five-photo live benchmark on December 1, 2026 (covering a three-window radiator living room, a 4:3 smartphone bedroom, an angled dining hallway, a kitchen island, and an occupied room declutter pass), locking native 3:2 and 4:3 aspect ratios through fal-ai/flux-pro/kontext followed by 4K crisp upscaling (4992 x 3328 on 3:2 and 4736 x 3520 on 4:3) kept masked architectural zones (ceiling lines, window mullions, baseboards) at MAE 0.70 to 3.87 / 255.

2. Lossless JPEG APP1 XMP Injection for IPTC DigitalSourceType

Re-encoding a 4K JPEG just to attach provenance metadata degrades chroma subsampling and adds unnecessary CPU work. Because JPEG files are a sequence of 0xFFxx segments starting right after the two-byte Start of Image (0xFFD8) marker, you can splice an APP1 (0xFFE1) XMP packet directly after 0xFFD8 in pure Uint8Array memory.

For AI virtual staging where furniture is synthesized onto a real photograph, the IPTC Digital Source Type vocabulary defines a dedicated URI:

http://cv.iptc.org/newscodes/digitalsourcetype/compositeWithTrainedAlgorithmicMedia

Here is a minimal, zero-dependency TypeScript function that injects that exact IPTC DigitalSourceType XMP packet into any valid JPEG byte array without recompressing the image scan:

const XMP_HEADER = new TextEncoder().encode('http://ns.adobe.com/xap/1.0/\0');

export function injectIptcDigitalSourceXmp(jpegBytes: Uint8Array, creditText: string): Uint8Array {
  if (jpegBytes.length < 4 || jpegBytes[0] !== 0xff || jpegBytes[1] !== 0xd8) {
    throw new Error('Invalid JPEG SOI marker');
  }

  const safeCredit = creditText.replace(/[<>&"']/g, '');
  const xmpXml = [
    '<?xpacket begin="\ufeff" id="W5M0MpCehiHzreSzNTczkc9d"?>',
    '<x:xmpmeta xmlns:x="adobe:ns:meta/">', 
    '  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"',
    '           xmlns:Iptc4xmpExt="http://iptc.org/std/Iptc4xmpExt/2008-02-29/"',
    '           xmlns:dc="http://purl.org/dc/elements/1.1/">',
    '    <rdf:Description rdf:about=""',
    '      Iptc4xmpExt:DigitalSourceType="http://cv.iptc.org/newscodes/digitalsourcetype/compositeWithTrainedAlgorithmicMedia">',
    `      <dc:description><rdf:Alt><rdf:li xml:lang="x-default">${safeCredit}</rdf:li></rdf:Alt></dc:description>`,
    '    </rdf:Description>',
    '  </rdf:RDF>',
    '</x:xmpmeta>',
    '<?xpacket end="w"?>',
  ].join('\n');

  const xmlBytes = new TextEncoder().encode(xmpXml);
  const payloadLength = 2 + XMP_HEADER.length + xmlBytes.length;
  if (payloadLength > 0xffff) {
    throw new Error('XMP packet exceeds 64KB APP1 segment limit');
  }

  const app1 = new Uint8Array(2 + payloadLength);
  app1[0] = 0xff;
  app1[1] = 0xe1;
  app1[2] = (payloadLength >> 8) & 0xff;
  app1[3] = payloadLength & 0xff;
  app1.set(XMP_HEADER, 4);
  app1.set(xmlBytes, 4 + XMP_HEADER.length);

  const out = new Uint8Array(2 + app1.length + (jpegBytes.length - 2));
  out.set(jpegBytes.subarray(0, 2), 0);
  out.set(app1, 2);
  out.set(jpegBytes.subarray(2), 2 + app1.length);
  return out;
}

Because the Start of Scan (0xFFDA) entropy-coded data is copied byte-for-byte, the staged photo loses zero visual quality while any ExifTool or MLS ingestion parser immediately reads DigitalSourceType: compositeWithTrainedAlgorithmicMedia.

3. Packaging the 4-Piece MLS Compliance Bundle Client-Side

A single staged JPEG is rarely enough for North American listing workflows: CRMLS Rule 11.5(e) prohibits third-party company logos on photos while California AB 723 requires pairing virtually altered images with the original vacant view.

Instead of storing four redundant 4K copies on the server, our browser export pipeline fetches the clean 4K master once and builds a four-file ZIP locally in memory:

  • 01-staged-clean-4k.jpg: clean 3840px photo with IPTC XMP metadata and zero text overlays for portals that handle disclosure via caption checkboxes.
  • 02-staged-virtually-staged-label-4k.jpg: neutral VIRTUALLY STAGED corner badge with zero vendor branding.
  • 03-original-vacant.jpg: sequentially named unaltered original photo so agents upload the pair right next to each other.
  • 04-ab723-before-after-diptych.jpg: side-by-side Before and After comparison canvas stamped in one click.

We intentionally scoped our studio to fast 2D photo staging, occupied-room clutter removal, and MLS compliance packaging rather than manual 3D CAD floorplan modeling or structural wall demolition.

If you already have your own vacant and staged JPEG pair and want to test lossless IPTC compositeWithTrainedAlgorithmicMedia stamping plus side-by-side diptych export right in your browser, our California AB 723 Before/After Diptych & IPTC Merger is a $0 Free Browser Utility (No AI Generation) with watermark-free export and no sign-up. For full AI room staging on Listing Virtual Staging, we offer 4 built-in $0 sample rooms and a 1-time free instant browser preview on your own room photo (no sign-up, watermarked on-screen preview only, no original file export; 4K watermark-free 4-piece ZIP unlocked via non-expiring credit packs) starting at $19/20, $39/60, and $79/130 credits.

Listing Virtual Staging is an independent virtual staging software tool and is not affiliated with, sponsored by, or endorsed by NAR, CREA, CRMLS, or any Multiple Listing Service.

๐Ÿ“ฐ Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes โ€” full credit and traffic to the original publisher.