<?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: Akhouri Anmol Kumar</title>
    <description>The latest articles on DEV Community by Akhouri Anmol Kumar (@akhourianmolkumar).</description>
    <link>https://dev.to/akhourianmolkumar</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%2F3977056%2F2600bd4b-c3e1-447a-a260-3f86a2d31a73.png</url>
      <title>DEV Community: Akhouri Anmol Kumar</title>
      <link>https://dev.to/akhourianmolkumar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/akhourianmolkumar"/>
    <language>en</language>
    <item>
      <title>remove.bg shuts down Dec 1. Here's how to test any replacement in 60 seconds (including mine)</title>
      <dc:creator>Akhouri Anmol Kumar</dc:creator>
      <pubDate>Sat, 21 Nov 2026 10:24:53 +0000</pubDate>
      <link>https://dev.to/akhourianmolkumar/removebg-shuts-down-dec-1-heres-how-to-test-any-replacement-in-60-seconds-including-mine-397d</link>
      <guid>https://dev.to/akhourianmolkumar/removebg-shuts-down-dec-1-heres-how-to-test-any-replacement-in-60-seconds-including-mine-397d</guid>
      <description>&lt;p&gt;On &lt;strong&gt;December 1, 2026 (9:00 CET)&lt;/strong&gt;, remove.bg closes its website and self-serve API. Web users are pointed to Canva's Background Remover and API users to Leonardo.Ai. Unused pay-as-you-go credits expire, and the Photoshop plugin and other integrations stop working.&lt;/p&gt;

&lt;p&gt;Expect a flood of "best remove.bg alternative" listicles this month. Most are ranked by who has the best affiliate deal. So instead of another list, here is a test you can run on &lt;em&gt;any&lt;/em&gt; tool.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 60-second test
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Open DevTools → &lt;strong&gt;Network&lt;/strong&gt; and clear it.&lt;/li&gt;
&lt;li&gt;Drop in a photo and run the cutout.&lt;/li&gt;
&lt;li&gt;Look for any request that carries your image bytes.&lt;/li&gt;
&lt;li&gt;Download the result and compare its pixel size to your original.&lt;/li&gt;
&lt;li&gt;Count the clicks (and walls) between you and a transparent PNG.&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Check&lt;/th&gt;
&lt;th&gt;Why it matters&lt;/th&gt;
&lt;th&gt;A bad answer looks like&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Is your photo uploaded?&lt;/td&gt;
&lt;td&gt;Privacy, plus speed on bad Wi-Fi&lt;/td&gt;
&lt;td&gt;A large request leaving your browser&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Output resolution&lt;/td&gt;
&lt;td&gt;"Free" often means thumbnail size&lt;/td&gt;
&lt;td&gt;Smaller than your input&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Account or credits&lt;/td&gt;
&lt;td&gt;Friction, and a bill later&lt;/td&gt;
&lt;td&gt;"3 free, then subscribe"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Edge touch-up&lt;/td&gt;
&lt;td&gt;No model nails hair on the first pass&lt;/td&gt;
&lt;td&gt;No way to fix mistakes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cost&lt;/td&gt;
&lt;td&gt;Obvious, but check the fine print&lt;/td&gt;
&lt;td&gt;Watermarks or per-image fees&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  I ran it on my own tool
&lt;/h2&gt;

&lt;p&gt;I'm the dev behind &lt;strong&gt;APIC STUDIO&lt;/strong&gt; (&lt;a href="https://apic-studio.vercel.app/" rel="noopener noreferrer"&gt;https://apic-studio.vercel.app/&lt;/a&gt;), a free in-browser image toolkit, so yes, this is where I tell you about it. Here are the honest results:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Upload:&lt;/strong&gt; The cut-out runs in your browser, so no request carries your image. You &lt;em&gt;will&lt;/em&gt; see a one-time model download in the Network tab (about 5 MB for Lite, 44 MB for Fast, 176 MB for Maximum). It's cached after that.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resolution:&lt;/strong&gt; Built to work at your image's own resolution, not a thumbnail.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Account:&lt;/strong&gt; Editing and every tool work without one. &lt;strong&gt;Exporting needs a free Google sign-in.&lt;/strong&gt; That's the trade-off, and I'd rather you hear it from me than discover it at the download button.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cost:&lt;/strong&gt; No credits, no paid tiers, no watermark.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Edge touch-up:&lt;/strong&gt; A Restore/Erase brush, plus one-click background replacement.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How the cut-out works (no magic)
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;A segmentation model runs through ONNX Runtime Web (WebAssembly, and WebGPU where available).&lt;/li&gt;
&lt;li&gt;The rough mask is cleaned of specks and pinholes.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;guided filter&lt;/strong&gt; snaps the mask onto the real edges of your full-resolution photo.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Blur-Fusion foreground estimation&lt;/strong&gt; reduces the colored halos you get around hair.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What it costs you (the honest part)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;First run is slower&lt;/strong&gt; because the model downloads once.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It runs on your hardware.&lt;/strong&gt; An old phone will be slower than a cloud GPU, and Remove Object limits its working area on low-memory devices.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No single-pass model is perfect.&lt;/strong&gt; Wispy hair and see-through fabric may need the Restore/Erase brush.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Export requires a free Google sign-in&lt;/strong&gt;, as above.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you need a high-volume API for a pipeline, Leonardo.Ai is the official remove.bg successor. APIC Web is built for people, not production pipelines.&lt;/p&gt;

&lt;h2&gt;
  
  
  Since you're switching anyway
&lt;/h2&gt;

&lt;p&gt;The same tab also handles resizing with social-media presets (profile pictures, banners, posts, stories), compressing to a &lt;strong&gt;target file size&lt;/strong&gt;, converting between PNG, JPEG, WebP, BMP, ICO and PDF, HEIC input, blurring faces or plates, batch processing to a ZIP, and merging images into one PDF.&lt;/p&gt;

&lt;h2&gt;
  
  
  Before December 1 checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Export or finish anything still sitting in remove.bg.&lt;/li&gt;
&lt;li&gt;Use your remaining credits before they expire.&lt;/li&gt;
&lt;li&gt;Search your automations (Zapier, scripts, plugins) for remove.bg calls. They won't show up in a code repo.&lt;/li&gt;
&lt;li&gt;Run the 60-second test on whichever replacement you pick.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Is remove.bg really shutting down?&lt;/strong&gt; Yes. The website and self-serve API close on December 1, 2026.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is there a free remove.bg alternative that doesn't upload photos?&lt;/strong&gt; Tools that run the model in your browser don't send the image anywhere. APIC Web is one. Check the Network tab to confirm for any tool.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Does APIC Web cost anything?&lt;/strong&gt; No credits and no paid tiers. Exporting needs a free Google sign-in.&lt;/p&gt;

&lt;h2&gt;
  
  
  One solo-dev note
&lt;/h2&gt;

&lt;p&gt;I have no team and no GPU bill. That's only possible because the compute runs on &lt;em&gt;your&lt;/em&gt; device instead of my server. A big company's advantage is infrastructure, and moving the work to the user's device removes it. That's also why this is free.&lt;/p&gt;

&lt;p&gt;I wrote about the economics here: &lt;a href="https://dev.to/akhourianmolkumar/free-online-image-tools-are-not-free-here-are-the-receipts-3nnm"&gt;Free Online Image Tools Are Not Free. Here Are the Receipts.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What's the last tool you relied on that got shut down or absorbed? What did you move to, and was it worth it?&lt;/strong&gt; I'd like to read your stories.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>privacy</category>
      <category>webassembly</category>
      <category>showdev</category>
    </item>
    <item>
      <title>APIC Desktop v2: A Free Offline Photo Editor With Layers, RAW, Curves &amp; a Healing Brush</title>
      <dc:creator>Akhouri Anmol Kumar</dc:creator>
      <pubDate>Thu, 19 Nov 2026 07:20:40 +0000</pubDate>
      <link>https://dev.to/akhourianmolkumar/apic-desktop-v2-a-free-offline-photo-editor-with-layers-raw-curves-a-healing-brush-2e90</link>
      <guid>https://dev.to/akhourianmolkumar/apic-desktop-v2-a-free-offline-photo-editor-with-layers-raw-curves-a-healing-brush-2e90</guid>
      <description>&lt;p&gt;What if your photo editor had layers, RAW development, a healing brush and a Photoshop-compatible file format, ran 100% offline, never asked you to sign in, and cost nothing?&lt;/p&gt;

&lt;p&gt;That's &lt;strong&gt;APIC Desktop v2&lt;/strong&gt;, and as of this update it is no longer a sketch. It's 15,000+ lines of Python ☠️, 320 passing tests, and a very different app from the one I showed you two weeks ago.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;📍 Catching up? &lt;a href="https://dev.to/akhourianmolkumar/apic-v2-development-has-begun-a-new-desktop-image-editor-is-coming-2hoh"&gt;Update #1: Development has begun&lt;/a&gt; → &lt;a href="https://dev.to/akhourianmolkumar/apic-v2-sneak-peek-a-free-offline-image-editor-converter-compressor-for-desktop-4ilk"&gt;Update #2: The sneak peek&lt;/a&gt; → Update #3 (you are here).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  ⚡ TL;DR
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;APIC Desktop v2 is a &lt;strong&gt;free, offline image editor, converter and compressor for Windows&lt;/strong&gt;, built with Python and PyQt6 by Akhouri Systems.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;New since Update #2:&lt;/strong&gt; layers with 18 blend modes, selections and masks, curves, an 8-band colour mixer, clone/healing/liquify retouching, RAW development, PSD import/export, 16-bit editing with full ICC colour management, and optional GPU acceleration.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tests:&lt;/strong&gt; 128 in Update #2, &lt;strong&gt;320 passing&lt;/strong&gt; now.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Privacy:&lt;/strong&gt; local-only. No network, no telemetry, no accounts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Release:&lt;/strong&gt; still unlocked at 2,000 total downloads across Akhouri Systems products.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7kviecmal46s8giv83b1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7kviecmal46s8giv83b1.png" alt=" " width="800" height="491"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🧭 What is APIC Desktop?
&lt;/h2&gt;

&lt;p&gt;APIC stands for &lt;strong&gt;Advanced Image Processing Center&lt;/strong&gt;. It's a free desktop app for &lt;strong&gt;editing, converting, compressing and searching images&lt;/strong&gt;, and it runs entirely on your own computer.&lt;/p&gt;

&lt;p&gt;If you've ever opened one app to edit a photo, a second to convert it to WebP, a third website to compress it (and quietly uploaded a private photo to a stranger's server along the way), APIC Desktop is built to replace that whole chain with one window.&lt;/p&gt;

&lt;p&gt;It comes in two forms:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🖥️ &lt;strong&gt;APIC Desktop:&lt;/strong&gt; the offline app this post is about. v1 is out, v2 is in development.&lt;/li&gt;
&lt;li&gt;🌐 &lt;strong&gt;APIC Studio:&lt;/strong&gt; the browser version, covered briefly near the end.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  📈 From Update #2 to Update #3: what changed
&lt;/h2&gt;

&lt;p&gt;Update #2 showed the foundation: Smart Export, the Privacy Inspector, Batch Studio and a new workspace. This update is the jump from "a very good converter with an editor" to "an editor with real depth".&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Update #2&lt;/th&gt;
&lt;th&gt;Update #3 (v2.2)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Layers&lt;/td&gt;
&lt;td&gt;Text and logo layers&lt;/td&gt;
&lt;td&gt;Full layer stack, 18 blend modes, masks, adjustment layers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Selections&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;td&gt;Rectangle, ellipse, lasso, magic wand, selection brush&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Colour tools&lt;/td&gt;
&lt;td&gt;Levels, white balance, vibrance&lt;/td&gt;
&lt;td&gt;Plus per-channel curves and an 8-band HSL colour mixer&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Retouching&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;td&gt;Clone stamp, healing brush, spot healing, red-eye, liquify&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;RAW files&lt;/td&gt;
&lt;td&gt;Not supported&lt;/td&gt;
&lt;td&gt;Develop dialog with live preview&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Photoshop files&lt;/td&gt;
&lt;td&gt;Not supported&lt;/td&gt;
&lt;td&gt;PSD/PSB import and layered export&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Colour depth&lt;/td&gt;
&lt;td&gt;8-bit&lt;/td&gt;
&lt;td&gt;16 bits per channel, full ICC profiles&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Speed&lt;/td&gt;
&lt;td&gt;CPU only&lt;/td&gt;
&lt;td&gt;Optional OpenCL GPU engine with automatic CPU fallback&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tests&lt;/td&gt;
&lt;td&gt;128&lt;/td&gt;
&lt;td&gt;320 passing&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Now the details.&lt;/p&gt;

&lt;h2&gt;
  
  
  🧱 Layers, blend modes and masks
&lt;/h2&gt;

&lt;p&gt;The edit stack &lt;strong&gt;is&lt;/strong&gt; the layer stack. Every step acts on everything beneath it, and the Layers tab shows the whole thing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Visibility ticks, ▲▼ reordering, duplicate and delete&lt;/li&gt;
&lt;li&gt;Per-layer opacity and &lt;strong&gt;18 blend modes&lt;/strong&gt; (checked against an independent compositor in the test suite)&lt;/li&gt;
&lt;li&gt;Layer masks&lt;/li&gt;
&lt;li&gt;Adjustment layers whose parameters stay editable&lt;/li&gt;
&lt;li&gt;Image layers from files, the clipboard or PSD, kept at &lt;strong&gt;full 16-bit precision&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Projects save as &lt;code&gt;.apic&lt;/code&gt; files (format v3, hash-checked), so your layers survive a close and reopen.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 Thanks to Alex Shev on Update #1, who argued the document model should be settled before the canvas tools. Versioned, integrity-checked project files are the result.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fe1bm6qzic2vqpa35w2zx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fe1bm6qzic2vqpa35w2zx.png" alt=" " width="800" height="491"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  ✂️ Selections that actually drive the edit
&lt;/h2&gt;

&lt;p&gt;You get rectangle, ellipse, lasso, &lt;strong&gt;magic wand&lt;/strong&gt; (tolerance, contiguous, sample size) and a selection brush. Combine them with Shift to add, Alt to subtract, or intersect. Then invert, grow, shrink, smooth or feather.&lt;/p&gt;

&lt;p&gt;With a selection active, &lt;strong&gt;every adjustment slider, curves and the colour mixer apply to the selection only&lt;/strong&gt;, as a masked layer. Masks are resolution independent, so a selection drawn on the preview hits the same area at export.&lt;/p&gt;

&lt;h2&gt;
  
  
  🎨 Curves and the 8-band colour mixer
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Curves:&lt;/strong&gt; monotone-spline curves per channel (RGB, R, G, B) with presets. Monotone means no weird overshoot when you drag a point.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;HSL colour mixer:&lt;/strong&gt; eight bands with hue (±30°), saturation and lightness, smoothly blended and designed so it never touches neutral greys.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both run on the CPU or the GPU and agree to within 1/65535.&lt;/p&gt;

&lt;h2&gt;
  
  
  🩹 Retouching: clone, heal, liquify
&lt;/h2&gt;

&lt;p&gt;This is the section I'm most excited about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Clone stamp&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Healing brush&lt;/strong&gt; using Poisson blending, so the copied texture adopts the tone and colour of its surroundings&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Spot healing&lt;/strong&gt; that finds its own source area&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Red-eye removal&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Liquify:&lt;/strong&gt; push, bloat, pinch and twirl&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Brush effects:&lt;/strong&gt; dodge, burn, saturate, blur, sharpen and more, kept editable as masked layers&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Manual lens correction:&lt;/strong&gt; distortion, vignette and chromatic aberration&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  📷 RAW development, built in
&lt;/h2&gt;

&lt;p&gt;Open a RAW file and a develop dialog appears with a &lt;strong&gt;live half-resolution preview&lt;/strong&gt;: white balance (as shot, daylight, grey-world, click-to-neutral, temperature, tint), exposure, highlight recovery, demosaic algorithm, noise reduction, chromatic aberration and the output colour space (sRGB, Adobe RGB, Display P3, ProPhoto, Rec. 2020).&lt;/p&gt;

&lt;p&gt;Supported formats include DNG, CR2/CR3, NEF, ARW, ORF, RW2, RAF and PEF, and you can choose &lt;strong&gt;Develop RAW again…&lt;/strong&gt; later without losing your edits.&lt;/p&gt;

&lt;h2&gt;
  
  
  🗂️ PSD, HEIC, AVIF, JPEG XL and more
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;PSD/PSB:&lt;/strong&gt; layered import (masks, blend modes, opacity, visibility, groups) and layered export at 8 or 16 bits, or a flattened PSD&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Open and save:&lt;/strong&gt; HEIC/HEIF, AVIF, JPEG XL&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Open:&lt;/strong&gt; TGA, JPEG 2000, DDS&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Everything else:&lt;/strong&gt; JPEG, PNG, WebP, BMP, TIFF, GIF, ICO&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🌈 16-bit editing and real colour management
&lt;/h2&gt;

&lt;p&gt;Most "simple" editors quietly flatten everything to sRGB. APIC doesn't.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Edits run at &lt;strong&gt;16 bits per channel&lt;/strong&gt; with float maths and a single quantisation at the end&lt;/li&gt;
&lt;li&gt;Embedded ICC profiles are &lt;strong&gt;kept&lt;/strong&gt;: Adobe RGB, Display P3, ProPhoto, Rec. 2020 and any RGB profile&lt;/li&gt;
&lt;li&gt;Convert or assign profiles, with all four rendering intents and black-point compensation&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Soft-proofing&lt;/strong&gt; with a gamut warning&lt;/li&gt;
&lt;li&gt;Export 8/16-bit PNG or TIFF, or &lt;strong&gt;CMYK JPEG/TIFF&lt;/strong&gt; with the right profile embedded&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🚀 GPU acceleration (with an honest asterisk)
&lt;/h2&gt;

&lt;p&gt;Every edit (tone, colour, blur, sharpen, resize, rotate, colour transforms) also exists as an &lt;strong&gt;OpenCL kernel&lt;/strong&gt; for NVIDIA, AMD and Intel GPUs. If an image doesn't fit in VRAM, or the GPU errors, APIC &lt;strong&gt;falls back to the CPU automatically&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The asterisk: the kernels are verified against the CPU reference engine on the PoCL OpenCL runtime, but &lt;strong&gt;I haven't run them on physical GPUs yet&lt;/strong&gt;. So I'm not going to quote a speed-up I haven't measured. More on that in the testers section below. 👇&lt;/p&gt;

&lt;h2&gt;
  
  
  🔐 The foundation is still here
&lt;/h2&gt;

&lt;p&gt;Everything from Update #2 carried forward:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Smart Export&lt;/strong&gt; with a real before/after and a Format Advisor that measures PSNR across JPEG, WebP, AVIF and PNG&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Privacy Inspector&lt;/strong&gt; that shows GPS, camera serial, name and dates, and strips them on export&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Auto Enhance&lt;/strong&gt; that sets ordinary sliders instead of baking changes in&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Batch Studio&lt;/strong&gt; for convert, compress, resize and watermark in one pass&lt;/li&gt;
&lt;li&gt;Command palette (&lt;code&gt;Ctrl+K&lt;/code&gt;), live histogram with clipping warnings, split view, crash recovery&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🔧 Under the hood
&lt;/h2&gt;

&lt;p&gt;For the developers reading this 👋&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apic/core   Qt-free engine, unit-tested (ops, color/ICC, layers, masks, retouch, RAW, PSD, export)
apic/core/engine   CPU reference backend + OpenCL backend, memory planning, automatic fallback
apic/ui     PyQt6 pages, canvas, panels, dialogs, background workers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;One shared pipeline:&lt;/strong&gt; editor preview, export and batch all go through the same &lt;code&gt;ops.apply_ops&lt;/code&gt; → &lt;code&gt;engine.run_ops&lt;/code&gt; path, so what you see is what you export.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The CPU engine is the reference.&lt;/strong&gt; A dedicated test checks every GPU kernel against it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Validated, serialisable operations&lt;/strong&gt;, which is why projects reload reliably.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stack:&lt;/strong&gt; Python, PyQt6, Pillow, NumPy, SciPy, lcms2 (via imagecodecs), tifffile, LibRaw (rawpy), psd-tools.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tests:&lt;/strong&gt; 320 passing, including headless UI tests.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a class="mentioned-user" href="https://dev.to/merbayerp"&gt;@merbayerp&lt;/a&gt; said on Update #1 that I should prioritise stability and testing over the download counter. This is me taking that seriously. 🙏&lt;/p&gt;

&lt;h2&gt;
  
  
  🧪 What's NOT done yet (the honest list)
&lt;/h2&gt;

&lt;p&gt;I'd rather you hear it from me:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;⚠️ The OpenCL kernels are &lt;strong&gt;untested on real GPUs&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;⚠️ RAW, PSD and the retouch tools are verified with synthetic and generated files, &lt;strong&gt;not a big library of real camera files yet&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;⚠️ PSD import skips Photoshop adjustment layers, clipping masks and layer styles (and tells you how many it skipped).&lt;/li&gt;
&lt;li&gt;⚠️ Layered TIFF isn't supported. Use PSD or an &lt;code&gt;.apic&lt;/code&gt; project.&lt;/li&gt;
&lt;li&gt;⚠️ Editing is 16-bit, not 32-bit float.&lt;/li&gt;
&lt;li&gt;⚠️ macOS and Linux are still on the roadmap. I haven't forgotten, &lt;a class="mentioned-user" href="https://dev.to/xulingfeng"&gt;@xulingfeng&lt;/a&gt;, &lt;a class="mentioned-user" href="https://dev.to/merbayerp"&gt;@merbayerp&lt;/a&gt;, &lt;a class="mentioned-user" href="https://dev.to/effessdev"&gt;@effessdev&lt;/a&gt;. 🍎🐧&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🙋 Want to help test?
&lt;/h2&gt;

&lt;p&gt;When v2 goes public, the most valuable thing you can send me is a report from real hardware:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Try your own RAW files, big PSDs and weird colour profiles.&lt;/li&gt;
&lt;li&gt;On a GPU machine, open &lt;strong&gt;Image ▸ Colour &amp;amp; performance settings ▸ Run a quick speed test&lt;/strong&gt; and tell me the result and your GPU model.&lt;/li&gt;
&lt;li&gt;Break things and tell me in the comments.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;My promise from Update #1 still stands: worthy suggestions get built.&lt;/p&gt;

&lt;h2&gt;
  
  
  ⏳ When does APIC v2 release?
&lt;/h2&gt;

&lt;p&gt;Same rule as before:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;APIC v2 goes public when Akhouri Systems reaches &lt;strong&gt;2,000 total downloads&lt;/strong&gt; across all products.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Update #1 started at 1,400. Update #2 reached 1,470. As of today we're at &lt;strong&gt;[1779]&lt;/strong&gt;. Every download of APIC v1 moves v2 closer.&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://github.com/Akhouri-Systems/APIC/releases/download/APIC/APIC.zip" rel="noopener noreferrer"&gt;Download APIC Desktop v1 (free, portable, no installer)&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🌐 Not at your own PC? Meet APIC Studio
&lt;/h2&gt;

&lt;p&gt;Quick detour. If you're on a phone, a school computer or any machine where you can't install anything, there's the browser sibling: &lt;strong&gt;&lt;a href="https://apic-studio.vercel.app" rel="noopener noreferrer"&gt;APIC Studio&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It's a free online photo editor with eleven tools: Edit, Advanced (curves, HSL, grading), Remove Object, Resize, Convert, Compress, &lt;strong&gt;Remove BG&lt;/strong&gt;, AI Tools, Layers (with PSD import/export), Social sizes for 15 networks and Visual Intelligence preflight checks.&lt;/p&gt;

&lt;p&gt;Like the desktop app, your photos aren't uploaded: the AI background remover runs on your device in the browser. (The first AI run downloads a model once, about 5 MB for Lite up to 176 MB for Maximum, then caches it.)&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;APIC Studio&lt;/th&gt;
&lt;th&gt;APIC Desktop v2&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Where it runs&lt;/td&gt;
&lt;td&gt;Your browser&lt;/td&gt;
&lt;td&gt;Your PC, fully offline&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Install&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;td&gt;Portable ZIP&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Best for&lt;/td&gt;
&lt;td&gt;Quick jobs, background removal, any device&lt;/td&gt;
&lt;td&gt;RAW, 16-bit/ICC colour, GPU, big batches&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Price&lt;/td&gt;
&lt;td&gt;Free&lt;/td&gt;
&lt;td&gt;Free&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;👉 &lt;a href="https://apic-studio.vercel.app" rel="noopener noreferrer"&gt;Try APIC Studio&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  ❓ FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Is there a free offline Photoshop alternative?&lt;/strong&gt;&lt;br&gt;
APIC Desktop v2 is built to cover everyday and enthusiast editing offline: layers, masks, curves, healing and RAW development. It isn't a clone of every Photoshop feature, and the list above says exactly where the gaps are.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can APIC open and save PSD files?&lt;/strong&gt;&lt;br&gt;
Yes. It imports layered PSD/PSB (masks, blend modes, opacity, groups) and exports layered or flattened PSD.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can APIC edit RAW photos?&lt;/strong&gt;&lt;br&gt;
Yes. It opens DNG, CR2/CR3, NEF, ARW, ORF, RW2, RAF and PEF with a live-preview develop dialog.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Does APIC upload my images?&lt;/strong&gt;&lt;br&gt;
No. It's local-only: no network, no telemetry, no accounts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can APIC remove EXIF and GPS data?&lt;/strong&gt;&lt;br&gt;
Yes. The Privacy Inspector shows what a file reveals and can strip it on export.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can it convert and compress images in bulk?&lt;/strong&gt;&lt;br&gt;
Yes. Batch Studio converts, compresses, resizes and watermarks many files in one pass.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can I compress to a target file size?&lt;/strong&gt;&lt;br&gt;
Yes. Set a goal like "under 500 KB" and APIC searches for the right quality.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is APIC free?&lt;/strong&gt;&lt;br&gt;
Yes. Both APIC Desktop and APIC Studio are free.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is there a macOS or Linux version?&lt;/strong&gt;&lt;br&gt;
Windows comes first. macOS and Linux are on the roadmap.&lt;/p&gt;

&lt;h2&gt;
  
  
  💬 Your turn
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Which new feature excites you most: layers, healing brush, RAW or PSD?&lt;/li&gt;
&lt;li&gt;What would make you switch your daily image editor to APIC?&lt;/li&gt;
&lt;li&gt;Windows, macOS or Linux, and which one first?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Drop your answers below 👇, follow me here for Update #4, and share this with the one friend who still opens three apps to resize a single photo. 😄&lt;/p&gt;

&lt;p&gt;&lt;em&gt;We Build What Others Forgot To Fix.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;— Akhouri Anmol Kumar, Founder, Akhouri Systems&lt;/em&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>showdev</category>
      <category>productivity</category>
      <category>discuss</category>
    </item>
    <item>
      <title>From GPT-3 to Agents: How AI Rewired Software in Six Years (2020-2026)</title>
      <dc:creator>Akhouri Anmol Kumar</dc:creator>
      <pubDate>Wed, 18 Nov 2026 05:26:43 +0000</pubDate>
      <link>https://dev.to/akhourianmolkumar/from-gpt-3-to-agents-how-ai-rewired-software-in-six-years-2020-2026-5al1</link>
      <guid>https://dev.to/akhourianmolkumar/from-gpt-3-to-agents-how-ai-rewired-software-in-six-years-2020-2026-5al1</guid>
      <description>&lt;p&gt;If you had told a developer in early 2020 that by the end of 2026 most of their peers would use AI every working day, that software agents would open pull requests, and that a model would be &lt;em&gt;better than a PhD-level human baseline&lt;/em&gt; on science questions while still fumbling an analog clock, they would have asked what you were smoking.&lt;/p&gt;

&lt;p&gt;Well. It's mid-November 2026.&lt;/p&gt;

&lt;p&gt;So let's do something we rarely do in this industry: stop, zoom out, and measure how far AI has actually travelled in six and a half years. Not hype. Numbers, milestones, and one uncomfortable pattern in the data that I think every developer should think about.&lt;/p&gt;

&lt;p&gt;And at the end, there's a very concrete story about what all this means for a tool millions of people use, and a deadline that is &lt;strong&gt;15 days away&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  First, a correction: AI didn't "arrive" in 2020
&lt;/h2&gt;

&lt;p&gt;Dev.to will eat me alive if I skip this. AI research is decades old. Deep learning broke through in 2012, and the Transformer architecture dropped in 2017.&lt;/p&gt;

&lt;p&gt;But 2020 is the year the curve bent for &lt;em&gt;everyone else&lt;/em&gt;. GPT-3 showed that if you scale a Transformer far enough, you get something that follows instructions from a handful of examples, with no task-specific training. That one idea (&lt;strong&gt;you can "program" a model with text&lt;/strong&gt;) is the root of almost everything that followed. So I'm using 2020 as year zero of the era we're all living in.&lt;/p&gt;

&lt;h2&gt;
  
  
  The six-year timeline
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Year&lt;/th&gt;
&lt;th&gt;The moment&lt;/th&gt;
&lt;th&gt;Why developers cared&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;2020&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;GPT-3 arrives (mid-year). AlphaFold 2 dominates the CASP14 protein-folding challenge (late-year).&lt;/td&gt;
&lt;td&gt;Few-shot prompting is born. And AI cracks a 50-year-old science problem.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;2021&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;DALL·E (Jan). GitHub Copilot technical preview (Jun).&lt;/td&gt;
&lt;td&gt;For the first time, AI lives &lt;em&gt;inside the editor&lt;/em&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;2022&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;DALL·E 2, open-weights Stable Diffusion, then &lt;strong&gt;ChatGPT on Nov 30&lt;/strong&gt;.&lt;/td&gt;
&lt;td&gt;Image generation goes open source. ChatGPT turns "AI" into a text box anyone can use; analysts estimated ~100M users within about two months.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;2023&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;GPT-4, Claude, Llama 2 (open weights).&lt;/td&gt;
&lt;td&gt;Multimodal and long-context models; RAG becomes a default architecture; "prompt engineer" becomes a job title (briefly).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;2024&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Sora preview. Nobel Prizes in Physics and Chemistry both honour AI-related work.&lt;/td&gt;
&lt;td&gt;Legitimacy. AI is now science, not just product.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;2025&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Reasoning models. DeepSeek-R1 open weights (Jan). Terminal and IDE coding agents go mainstream.&lt;/td&gt;
&lt;td&gt;Models "think" before answering. Costs fall. Developers start delegating, not just autocompleting.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;2026&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Agents inside everyday workflows. Stanford's AI Index says capability is &lt;em&gt;accelerating, not plateauing&lt;/em&gt;.&lt;/td&gt;
&lt;td&gt;The question changes from "can it do it?" to "can I trust it, and who's accountable?"&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  What the numbers say
&lt;/h2&gt;

&lt;p&gt;Timelines are fun; surveys are honest. Stack Overflow has been asking developers about AI since 2023, and the trajectory is steep.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Developers using AI tools&lt;/strong&gt; (&lt;a href="https://stackoverflow.blog/2026/09/30/getting-ready-for-2026-results-a-look-back-on-developer-survey-findings/" rel="noopener noreferrer"&gt;Stack Overflow&lt;/a&gt;):&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;2023&lt;/th&gt;
&lt;th&gt;2024&lt;/th&gt;
&lt;th&gt;2025&lt;/th&gt;
&lt;th&gt;2026&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;44%&lt;/td&gt;
&lt;td&gt;62%&lt;/td&gt;
&lt;td&gt;79%&lt;/td&gt;
&lt;td&gt;only ~17% say they &lt;em&gt;don't&lt;/em&gt; use AI tools at work&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;AI agents&lt;/strong&gt; are the faster story. In the 2025 survey, &lt;a href="https://survey.stackoverflow.co/2025/ai" rel="noopener noreferrer"&gt;31% of respondents used agents&lt;/a&gt;. A smaller pulse survey in April 2026 found agent use had &lt;a href="https://stackoverflow.blog/2026/10/01/a-look-back-before-we-look-forward-a-developer-survey-retrospective" rel="noopener noreferrer"&gt;almost doubled to 59%&lt;/a&gt;, with Claude Code usage among agent users rising from 41% to 55%.&lt;/p&gt;

&lt;p&gt;And outside our bubble, &lt;a href="https://lightcast.io/resources/blog/stanford-ai-2026" rel="noopener noreferrer"&gt;Lightcast's read of the Stanford data&lt;/a&gt; shows 2.5% of all US job postings now mention AI skills: up 55% in a year and roughly 300% over a decade.&lt;/p&gt;

&lt;p&gt;So: massive adoption. Done, right? Not quite.&lt;/p&gt;

&lt;h2&gt;
  
  
  The uncomfortable pattern: usage up, trust down
&lt;/h2&gt;

&lt;p&gt;Here's the part that doesn't fit the hype narrative.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In 2025, &lt;a href="https://survey.stackoverflow.co/2025/ai" rel="noopener noreferrer"&gt;46% of developers said they distrust AI output, versus 33% who trust it&lt;/a&gt;. Only 3% said they "highly trust" it.&lt;/li&gt;
&lt;li&gt;In the &lt;a href="https://itbrief.co.uk/story/stack-overflow-survey-shows-developers-trust-ai-with-caveats" rel="noopener noreferrer"&gt;2026 survey&lt;/a&gt;, nearly half trust AI output &lt;em&gt;when they can easily verify it&lt;/em&gt;. Just &lt;strong&gt;6.6%&lt;/strong&gt; would trust it with an important decision.&lt;/li&gt;
&lt;li&gt;The most common frustration in 2025: solutions that are &lt;em&gt;"almost right, but not quite."&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Governance is lagging: only &lt;strong&gt;24%&lt;/strong&gt; of respondents said their employer had published approved AI tools or guidance.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I'd argue this is the defining dynamic of 2026: &lt;strong&gt;AI has become infrastructure faster than it has become trustworthy.&lt;/strong&gt; We use it constantly &lt;em&gt;and&lt;/em&gt; check it constantly.&lt;/p&gt;

&lt;p&gt;Stanford's 2026 AI Index captures the same weirdness from the capability side: &lt;a href="https://the-decoder.com/?p=34331" rel="noopener noreferrer"&gt;models now beat human baselines on PhD-level science questions, yet still fail at tasks like reading an analog clock&lt;/a&gt;. Researchers call this &lt;em&gt;jagged&lt;/em&gt; intelligence: brilliant peaks, baffling potholes.&lt;/p&gt;

&lt;p&gt;My takeaway (opinion, not data): the most valuable developer skill of the next few years isn't prompting. It's &lt;strong&gt;verification&lt;/strong&gt;: writing tests, reading diffs, designing systems where a wrong-but-plausible answer gets caught.&lt;/p&gt;

&lt;h2&gt;
  
  
  The quiet shift nobody is tweeting about: AI left the data center
&lt;/h2&gt;

&lt;p&gt;In 2020, running a serious neural network meant renting GPUs and calling an API. That model (&lt;em&gt;your data goes up, the answer comes down, and you pay per call&lt;/em&gt;) defined the first half of this era.&lt;/p&gt;

&lt;p&gt;The second half is different. Thanks to WebAssembly, WebGPU, and runtimes like ONNX Runtime Web, a browser tab can now run real models locally:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;ort&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"onnxruntime-web"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Simplified: load a model once, cache it, run inference on-device&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;ort&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;InferenceSession&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/models/segmenter.onnx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;executionProviders&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"wasm"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// or "webgpu" where supported&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;imageTensor&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// Nothing was uploaded. No API key. No per-call bill.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why this matters:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Privacy&lt;/strong&gt;: sensitive data never leaves the device.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cost&lt;/strong&gt;: inference runs on the user's hardware, so there are no per-image credits.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Latency and availability&lt;/strong&gt;: after the first download there is no round trip, and some tools work offline.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Longevity&lt;/strong&gt;: your tool can't be switched off because someone else's API changed pricing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That last point just became very real for millions of people.&lt;/p&gt;

&lt;h2&gt;
  
  
  Case study: the end of an era
&lt;/h2&gt;

&lt;p&gt;For years, remove.bg was &lt;em&gt;the&lt;/em&gt; answer to "how do I remove a background?" It popularised one-click AI background removal and was a textbook example of the cloud-API era.&lt;/p&gt;

&lt;p&gt;Now its &lt;a href="https://alternativeto.net/news/2026/9/end-of-an-era-remove-bg-shuts-down-standalone-service-and-moves-to-the-canva-ecosystem/" rel="noopener noreferrer"&gt;standalone website is closing on &lt;strong&gt;December 1, 2026&lt;/strong&gt;&lt;/a&gt;, with the functionality moving into Canva (which has owned it since 2021). Reporting based on remove.bg's own FAQ says the closure is at 9:00 CET, &lt;a href="https://www.explainx.ai/blog/remove-bg-shutting-down-alternatives-2026" rel="noopener noreferrer"&gt;unused pay-as-you-go credits expire, and the self-serve API moves to Leonardo.Ai&lt;/a&gt; (also Canva-owned). If you rely on it, export your usage reports and invoices before the cutoff.&lt;/p&gt;

&lt;p&gt;There's a lesson here that has nothing to do with any single company: &lt;strong&gt;if your workflow depends on someone else's server, it has an expiry date you don't control.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you're already in the Canva ecosystem, Canva is the official successor and will be fine for you. But if you want something that doesn't ask for an account or a credit card, or send your photos anywhere, read on.&lt;/p&gt;

&lt;h2&gt;
  
  
  Meet APIC: the on-device approach, in practice
&lt;/h2&gt;

&lt;p&gt;Full disclosure: &lt;strong&gt;I built APIC&lt;/strong&gt;, so weigh my opinion accordingly. But everything below is verifiable in about 60 seconds, which is exactly why I'm comfortable showing it to a room full of skeptical developers.&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;&lt;a href="https://apic-studio.vercel.app/" rel="noopener noreferrer"&gt;apic-studio.vercel.app&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;APIC (Advanced Image Processing Center) is a free, browser-based photo editor where the AI runs &lt;strong&gt;on your device&lt;/strong&gt;. No upload. No credits. No account required to edit &lt;em&gt;or&lt;/em&gt; export (there's an optional Google sign-in, nothing more).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Background removal, the remove.bg use case&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;On-device AI cut-out with three model sizes: &lt;strong&gt;Light (~5 MB, built for phones)&lt;/strong&gt;, &lt;strong&gt;Fast (~44 MB)&lt;/strong&gt;, and &lt;strong&gt;Maximum (~176 MB, multi-pass, best on a PC)&lt;/strong&gt;. Models download once and are cached.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;Restore / Erase brush&lt;/strong&gt; to fix hair, fur and awkward edges, plus one-click replacement with white, black or a blurred copy of your photo.&lt;/li&gt;
&lt;li&gt;Full-resolution output as transparent PNG or WebP.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Batch mode&lt;/strong&gt;: remove backgrounds, resize, compress and convert many images, then download one ZIP.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;And because I got tired of juggling ten tabs, it's eleven tools in one&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Remove Object&lt;/strong&gt;: paint over a person, sign or blemish; inpainting runs locally (MI-GAN ~28 MB, or LaMa ~208 MB for big, complex fills).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AI upscale&lt;/strong&gt; (2x / 4x) with Real-ESRGAN.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Compress to an exact file size&lt;/strong&gt; ("under 200 KB" for that upload form), &lt;strong&gt;resize&lt;/strong&gt;, and &lt;strong&gt;convert&lt;/strong&gt; between PNG, JPEG, WebP, AVIF, BMP, ICO, PDF and PSD, with &lt;strong&gt;HEIC&lt;/strong&gt; photos accepted as input.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pro colour tools&lt;/strong&gt;: histogram, RGB curves, HSL mixer, 3-way grading, and &lt;strong&gt;3D LUT (.cube) export&lt;/strong&gt; for DaVinci Resolve, Premiere and Photoshop.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Social presets&lt;/strong&gt; for 15+ networks with safe-zone guides; &lt;strong&gt;Layers&lt;/strong&gt; with blend modes and PSD import/export; &lt;strong&gt;Hide area&lt;/strong&gt; to blur or pixelate faces, plates and card numbers before you share.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;Windows app that runs fully offline&lt;/strong&gt;, no account needed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The honest trade-offs&lt;/strong&gt; (because you'd find them anyway):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The first run of any AI tool downloads its model, so it's slower once and fast afterwards.&lt;/li&gt;
&lt;li&gt;The heaviest models are best on a desktop-class machine. On phones, use Light.&lt;/li&gt;
&lt;li&gt;It's a browser tool, not a replacement for Photoshop's full ecosystem.&lt;/li&gt;
&lt;li&gt;I'm one developer shipping this, not a 500-person company. Feedback genuinely shapes the roadmap.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Try it with your &lt;em&gt;hardest&lt;/em&gt; photo
&lt;/h3&gt;

&lt;p&gt;Don't test it on a clean studio shot. Take the image remove.bg struggled with (wispy hair, glass, a busy background) and run it through APIC's &lt;strong&gt;Remove BG&lt;/strong&gt; tab on &lt;strong&gt;Maximum&lt;/strong&gt;. Use the Restore brush if needed. If it doesn't hold up, tell me where it failed. If it does, you've just saved yourself a subscription.&lt;/p&gt;

&lt;h2&gt;
  
  
  Make it your default (it takes 20 seconds)
&lt;/h2&gt;

&lt;p&gt;With 15 days left on the old default, now is the moment to build a new habit:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Open &lt;a href="https://apic-studio.vercel.app/" rel="noopener noreferrer"&gt;apic-studio.vercel.app&lt;/a&gt;&lt;/strong&gt; and drop in a photo.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bookmark it&lt;/strong&gt; and pin the tab, so "remove background" now means one click on your own bookmarks bar.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Send it to the one person&lt;/strong&gt; in your team, family or client list who still says "just use remove.bg."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tell me what's missing&lt;/strong&gt;: a comment below, or find me on &lt;a href="https://github.com/Akhouri-Anmol-Kumar" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt; / &lt;a href="https://dev.to/akhourianmolkumar"&gt;dev.to&lt;/a&gt;. I read everything.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;(I also wrote a shorter, practical guide on the remove.bg shutdown specifically: &lt;a href="https://dev.to/akhourianmolkumar/removebg-is-shutting-down-heres-a-free-no-upload-alternative-4ebo"&gt;remove.bg Is Shutting Down — Here's a Free, No-Upload Alternative&lt;/a&gt;.)&lt;/p&gt;

&lt;h2&gt;
  
  
  So, how much AI is there in six years?
&lt;/h2&gt;

&lt;p&gt;Started as a research demo behind a waitlist in 2020. By 2026 it's in the editor, the terminal, the job postings, the Nobel Prizes, the survey data, and increasingly, &lt;strong&gt;in your browser tab, running on your own hardware&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The next six years won't be about who has the biggest model. They'll be about three questions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Can I verify it?&lt;/strong&gt; (trust)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Who controls it?&lt;/strong&gt; (open weights, on-device, no kill switch)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Does it respect the user?&lt;/strong&gt; (privacy by architecture, not by policy)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The tools that win on all three won't need a marketing budget. They'll just be the ones people quietly never switch away from.&lt;/p&gt;

&lt;p&gt;I'm betting on that. &lt;strong&gt;&lt;a href="https://apic-studio.vercel.app/" rel="noopener noreferrer"&gt;Come try APIC&lt;/a&gt;&lt;/strong&gt;, and tell me where I'm wrong.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Your turn:&lt;/strong&gt; what was &lt;em&gt;your&lt;/em&gt; "oh, this changes everything" AI moment between 2020 and 2026: GPT-3, Copilot, ChatGPT, or something else? Drop it in the comments. 👇&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Sources: &lt;a href="https://survey.stackoverflow.co/2025/ai" rel="noopener noreferrer"&gt;Stack Overflow Developer Survey 2025&lt;/a&gt; · &lt;a href="https://itbrief.co.uk/story/stack-overflow-survey-shows-developers-trust-ai-with-caveats" rel="noopener noreferrer"&gt;Stack Overflow Developer Survey 2026 coverage&lt;/a&gt; · &lt;a href="https://hai.stanford.edu/ai-index/2026-ai-index-report" rel="noopener noreferrer"&gt;Stanford HAI AI Index 2026&lt;/a&gt; · &lt;a href="https://lightcast.io/resources/blog/stanford-ai-2026" rel="noopener noreferrer"&gt;Lightcast&lt;/a&gt; · &lt;a href="https://alternativeto.net/news/2026/9/end-of-an-era-remove-bg-shuts-down-standalone-service-and-moves-to-the-canva-ecosystem/" rel="noopener noreferrer"&gt;remove.bg shutdown reporting&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>productivity</category>
      <category>css</category>
    </item>
    <item>
      <title>Are You a CSS Developer or a CSS Expert? 9 Tests I Failed Styling a 12,400-Line Photo Editor</title>
      <dc:creator>Akhouri Anmol Kumar</dc:creator>
      <pubDate>Sun, 15 Nov 2026 06:01:51 +0000</pubDate>
      <link>https://dev.to/akhourianmolkumar/are-you-a-css-developer-or-a-css-expert-9-tests-i-failed-styling-a-12400-line-photo-editor-161p</link>
      <guid>https://dev.to/akhourianmolkumar/are-you-a-css-developer-or-a-css-expert-9-tests-i-failed-styling-a-12400-line-photo-editor-161p</guid>
      <description>&lt;p&gt;Most developers can make a button blue, centre a div and copy a flexbox cheat sheet.&lt;/p&gt;

&lt;p&gt;CSS experts know what happens when &lt;strong&gt;the browser disagrees with you&lt;/strong&gt;: when the page flashes white before it turns dark, when a phone's address bar eats the bottom of your layout, when a "simple" gradient border refuses to follow rounded corners, and when your grey text looks elegant on your monitor and invisible in sunlight.&lt;/p&gt;

&lt;p&gt;I found out which one I was while styling &lt;strong&gt;APIC&lt;/strong&gt;, a free photo editor that runs entirely in your browser: edit, convert, compress, resize and remove backgrounds, with no sign-up. It is one HTML file of about &lt;strong&gt;12,400 lines&lt;/strong&gt;, and its whole look lives in just &lt;strong&gt;~1,100 lines of CSS&lt;/strong&gt; inside it. This post is about those 1,100 lines (and the HTML around them).&lt;/p&gt;

&lt;p&gt;Every test below is a real decision or a real bug from that file. The code is trimmed for reading, but the ideas are exactly what ships. 👇&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;New here? Good. This post is written for you too.&lt;/strong&gt; Every test has a &lt;em&gt;plain English&lt;/em&gt; part first, then the code, then the "what is really going on" part. If you only read the plain English parts, you will still learn something true. If you are an expert, skip straight to the code and the last line of each test.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🧰 Five words you will see (read this once)
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Word&lt;/th&gt;
&lt;th&gt;What it means, no jargon&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Custom property&lt;/strong&gt; (&lt;code&gt;--bg&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;A variable for CSS. Define a colour once, use it everywhere with &lt;code&gt;var(--bg)&lt;/code&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Pseudo-element&lt;/strong&gt; (&lt;code&gt;::before&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;A free extra box the browser lets you attach to any element, with no extra HTML.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Stacking context&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;A "layer fence". Things inside it can be ordered among themselves, but cannot escape it.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Viewport&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The part of the page you can currently see on screen.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Paint&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The moment the browser actually draws pixels on your screen.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  📊 APIC's CSS by the numbers
&lt;/h2&gt;

&lt;p&gt;These are counted straight from the file:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;~1,100 lines&lt;/strong&gt; of CSS&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;666&lt;/strong&gt; uses of &lt;code&gt;var(--...)&lt;/code&gt;: the whole design runs on variables&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;33&lt;/strong&gt; &lt;code&gt;@media&lt;/code&gt; queries&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;20&lt;/strong&gt; uses of &lt;code&gt;color-mix()&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;12&lt;/strong&gt; &lt;code&gt;@keyframes&lt;/code&gt; animations&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;18&lt;/strong&gt; &lt;code&gt;:focus-visible&lt;/code&gt; rules (keyboard users get a visible outline)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;8&lt;/strong&gt; &lt;code&gt;prefers-reduced-motion: reduce&lt;/code&gt; guards (people who get dizzy from animation get less of it)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;20&lt;/strong&gt; &lt;code&gt;&amp;lt;details&amp;gt;&lt;/code&gt; elements (accordions with no JavaScript)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now the tests. Score yourself honestly.&lt;/p&gt;




&lt;h2&gt;
  
  
  Test 1: Does your dark site flash white before it turns dark?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;In plain English.&lt;/strong&gt; You choose "light mode", you reload the page, and for a split second the screen is &lt;em&gt;dark&lt;/em&gt; before it switches. That flash is the browser drawing the page with the wrong colours, then fixing them. It looks cheap, and it hurts if you are in a dark room.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why it happens.&lt;/strong&gt; The browser paints as soon as it has your HTML and CSS. If the code that picks your theme runs &lt;em&gt;after&lt;/em&gt; that, the first frame is already wrong.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The fix.&lt;/strong&gt; Pick the theme in a tiny script in the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt;, so it runs &lt;em&gt;before the first paint&lt;/em&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
  &lt;span class="c1"&gt;// Runs before anything is drawn&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;mode&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'system'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;localStorage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'apic_theme'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'light'&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'dark'&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'system'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;mode&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;                       &lt;span class="c1"&gt;// storage can be blocked, so never trust it&lt;/span&gt;

    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mode&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'system'&lt;/span&gt;
      &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;matchMedia&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'(prefers-color-scheme: light)'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;matches&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s1"&gt;'light'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'dark'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;documentElement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'data-theme'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the CSS only has to change a handful of variables:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nt"&gt;root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;                                   &lt;span class="cm"&gt;/* dark is the default */&lt;/span&gt;
  &lt;span class="nv"&gt;--bg&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#07070a&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="nv"&gt;--bg-2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#0d0d13&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="nv"&gt;--bg-3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#14141c&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nv"&gt;--line&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;150&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;210&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;14&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nv"&gt;--text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#eef1f6&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;--text-muted&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#8b8fa3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;html&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;data-theme&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"light"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;                &lt;span class="cm"&gt;/* light only overrides the values */&lt;/span&gt;
  &lt;span class="nv"&gt;--bg&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#f2f3ee&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="nv"&gt;--bg-2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#e8e9e1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="nv"&gt;--bg-3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#dcded2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nv"&gt;--line&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;14&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nv"&gt;--text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#0c0e0a&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;--text-muted&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#5b5f52&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;--bg&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;--text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;APIC's light theme overrides &lt;strong&gt;8 variables&lt;/strong&gt;. The other 600+ places that use colours never needed to know a second theme exists.&lt;/p&gt;

&lt;p&gt;Three small details separate "it works" from "it works every time":&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;try/catch&lt;/code&gt; around &lt;code&gt;localStorage&lt;/code&gt;.&lt;/strong&gt; Private modes and strict settings can make it throw. A theme script that crashes leaves you with no theme at all.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Three modes, not two:&lt;/strong&gt; &lt;code&gt;light&lt;/code&gt;, &lt;code&gt;dark&lt;/code&gt; and &lt;code&gt;system&lt;/code&gt;. "Follow my device" is a real choice, so it gets stored as one.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The script is inline and in the head.&lt;/strong&gt; A script loaded from a file, or placed at the bottom, runs too late. Being &lt;em&gt;render-blocking&lt;/em&gt; is exactly what you want here.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Developer:&lt;/strong&gt; toggles a class after the page loads.&lt;br&gt;
&lt;strong&gt;Expert:&lt;/strong&gt; decides the theme before the first pixel exists.&lt;/p&gt;


&lt;h2&gt;
  
  
  Test 2: Can one line make a see-through header that works in &lt;em&gt;both&lt;/em&gt; themes?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;In plain English.&lt;/strong&gt; A sticky header that is slightly see-through, so content blurs underneath it as you scroll, looks premium. The trap: "slightly see-through" needs a colour &lt;em&gt;with transparency&lt;/em&gt;, and you have two themes with two different background colours.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The old way:&lt;/strong&gt; write &lt;code&gt;rgba(7, 7, 10, .82)&lt;/code&gt; for dark, then write a second &lt;code&gt;rgba(...)&lt;/code&gt; for light. Now you have two numbers to keep in sync forever.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The expert way:&lt;/strong&gt; &lt;code&gt;color-mix()&lt;/code&gt; takes the colour from your variable and mixes it with "nothing":&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;header&lt;/span&gt;&lt;span class="nc"&gt;.top&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;sticky&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;color-mix&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;in&lt;/span&gt; &lt;span class="n"&gt;srgb&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;--bg&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="mi"&gt;82&lt;/span&gt;&lt;span class="kt"&gt;%&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;transparent&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="cm"&gt;/* 82% bg, 18% see-through */&lt;/span&gt;
  &lt;span class="nl"&gt;backdrop-filter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;blur&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;12px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                                  &lt;span class="cm"&gt;/* blur what's behind it */&lt;/span&gt;
  &lt;span class="nl"&gt;border-bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1px&lt;/span&gt; &lt;span class="n"&gt;solid&lt;/span&gt; &lt;span class="nf"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;--line&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cm"&gt;/* when you scroll, the border quietly turns slightly green */&lt;/span&gt;
&lt;span class="nt"&gt;header&lt;/span&gt;&lt;span class="nc"&gt;.top.scrolled&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;border-bottom-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;color-mix&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;in&lt;/span&gt; &lt;span class="n"&gt;srgb&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;--green&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="mi"&gt;22&lt;/span&gt;&lt;span class="kt"&gt;%&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;--line&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Switch the theme and &lt;code&gt;--bg&lt;/code&gt; changes, so the header changes with it. No second rule. APIC uses this trick &lt;strong&gt;20 times&lt;/strong&gt;: hover glows, drag-and-drop highlights, active buttons, the lot.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;rgba()&lt;/code&gt; cannot do this, because it wants raw numbers, not "whatever &lt;code&gt;--bg&lt;/code&gt; currently is". &lt;code&gt;color-mix()&lt;/code&gt; works in all current major browsers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Developer:&lt;/strong&gt; copies a colour and lowers its alpha, twice.&lt;br&gt;
&lt;strong&gt;Expert:&lt;/strong&gt; derives colours from the tokens, so there is only one source of truth.&lt;/p&gt;


&lt;h2&gt;
  
  
  Test 3: Why does my glow lag, or vanish behind the wrong thing?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;In plain English.&lt;/strong&gt; APIC's main card has a soft rainbow glow behind it. When you open a photo, the glow fades out so the picture is easy to see. Simple idea. Two things can go wrong: the glow ends up in the wrong layer, and the animation stutters on cheap phones.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.studio&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;relative&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;isolation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;isolate&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                    &lt;span class="cm"&gt;/* 1. build a layer fence around this card */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.studio&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nt"&gt;before&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;                        &lt;span class="cm"&gt;/* the glow is a free extra box */&lt;/span&gt;
  &lt;span class="nl"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;absolute&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;inset&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;-1px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;z-index&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;-1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                           &lt;span class="cm"&gt;/* behind the card's content... */&lt;/span&gt;
  &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;inherit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;--grad-brand&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;         &lt;span class="cm"&gt;/* green → cyan → pink */&lt;/span&gt;
  &lt;span class="nl"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;28&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;blur&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;18px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;will-change&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;opacity&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;9s&lt;/span&gt; &lt;span class="nf"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;--ease-out&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;transform&lt;/span&gt; &lt;span class="mf"&gt;1.1s&lt;/span&gt; &lt;span class="nf"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;--ease-out&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.studio.has-image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nt"&gt;before&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;              &lt;span class="cm"&gt;/* JS adds .has-image; CSS does the animation */&lt;/span&gt;
  &lt;span class="nl"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;scale&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;94&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;prefers-reduced-motion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nc"&gt;.studio&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;before&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;  &lt;span class="cm"&gt;/* 3. respect people who opt out of motion */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;1. &lt;code&gt;isolation: isolate&lt;/code&gt;&lt;/strong&gt; creates a stacking context, the "layer fence" from the glossary. Without it, &lt;code&gt;z-index: -1&lt;/code&gt; means "go behind whatever the page decides", and that can change when some ancestor gets a &lt;code&gt;transform&lt;/code&gt; or &lt;code&gt;opacity&lt;/code&gt; later. With the fence, it means "behind &lt;em&gt;this card's content&lt;/em&gt;", always.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Only cheap properties animate.&lt;/strong&gt; Fading (&lt;code&gt;opacity&lt;/code&gt;) and moving or scaling (&lt;code&gt;transform&lt;/code&gt;) are the two things browsers can usually animate on the GPU without re-measuring the page. The expensive part is the blur, and the blur &lt;strong&gt;never changes&lt;/strong&gt;, so it is drawn once and then just faded. Animating &lt;code&gt;box-shadow&lt;/code&gt;, &lt;code&gt;width&lt;/code&gt; or &lt;code&gt;filter&lt;/code&gt; itself would redo that work on every frame.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Reduced motion.&lt;/strong&gt; Some people get dizzy or distracted by animation, and their system tells your site so. One &lt;code&gt;@media&lt;/code&gt; line is the whole accommodation.&lt;/p&gt;

&lt;p&gt;Notice who does what: JavaScript only flips a class (&lt;code&gt;has-image&lt;/code&gt;). CSS owns every pixel of the animation. That split keeps both sides small.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Developer:&lt;/strong&gt; animates &lt;code&gt;box-shadow&lt;/code&gt; and wonders why it is janky.&lt;br&gt;
&lt;strong&gt;Expert:&lt;/strong&gt; animates only &lt;code&gt;opacity&lt;/code&gt; and &lt;code&gt;transform&lt;/code&gt;, and builds a fence first.&lt;/p&gt;


&lt;h2&gt;
  
  
  Test 4: Can you put a &lt;em&gt;gradient&lt;/em&gt; on a &lt;em&gt;rounded&lt;/em&gt; border?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;In plain English.&lt;/strong&gt; You want a thin rainbow outline around a rounded floating bar. Sounds like one line: &lt;code&gt;border: 1px solid &amp;lt;gradient&amp;gt;&lt;/code&gt;. It is not. A border can only be a flat colour, and the tool made for fancy borders, &lt;code&gt;border-image&lt;/code&gt;, &lt;strong&gt;ignores &lt;code&gt;border-radius&lt;/code&gt;&lt;/strong&gt;. Your corners come out square.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The trick:&lt;/strong&gt; don't use a border at all. Draw a gradient box, then &lt;strong&gt;cut a hole in the middle&lt;/strong&gt;, so only a 1px ring is left:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nn"&gt;#apicDock&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nt"&gt;before&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;absolute&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;inset&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;-1px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;inherit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;               &lt;span class="cm"&gt;/* the ring follows the rounded corners */&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                         &lt;span class="cm"&gt;/* 1px = the thickness of the ring */&lt;/span&gt;
  &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;--grad-brand&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;55&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;pointer-events&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                 &lt;span class="cm"&gt;/* never block clicks on the real bar */&lt;/span&gt;

  &lt;span class="nl"&gt;-webkit-mask&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;linear-gradient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mh"&gt;#000&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;content-box&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;linear-gradient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mh"&gt;#000&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;-webkit-mask-composite&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;xor&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;          &lt;span class="cm"&gt;/* older browsers */&lt;/span&gt;
  &lt;span class="nl"&gt;mask&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;linear-gradient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mh"&gt;#000&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;content-box&lt;/span&gt; &lt;span class="n"&gt;exclude&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;linear-gradient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mh"&gt;#000&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;mask-composite&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;exclude&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;              &lt;span class="cm"&gt;/* standard */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How to read it. A &lt;strong&gt;mask&lt;/strong&gt; says "show the element only where the mask is solid". Here are two solid masks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;one covers the &lt;strong&gt;content box&lt;/strong&gt; (the middle),&lt;/li&gt;
&lt;li&gt;one covers the &lt;strong&gt;whole box&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;exclude&lt;/code&gt; means "show where they &lt;em&gt;don't&lt;/em&gt; overlap". The only place the two masks differ is the thin padding strip around the edge. That strip is your ring, and because the element itself has rounded corners, so does the ring.&lt;/p&gt;

&lt;p&gt;APIC ships both the &lt;code&gt;-webkit-&lt;/code&gt; version and the standard one, because older browsers only know the prefixed one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Developer:&lt;/strong&gt; gives up and uses a wrapper &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; with a gradient background and a smaller &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; on top.&lt;br&gt;
&lt;strong&gt;Expert:&lt;/strong&gt; subtracts one shape from another with a mask.&lt;/p&gt;


&lt;h2&gt;
  
  
  Test 5: How do you animate something to "gone", when &lt;code&gt;display: none&lt;/code&gt; can't be animated?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;In plain English.&lt;/strong&gt; When you open a photo, APIC's tagline fades and slides up, and its space &lt;em&gt;collapses&lt;/em&gt; so the editor moves up smoothly. When you close the photo, it comes back. You cannot animate &lt;code&gt;display&lt;/code&gt;, and you cannot animate &lt;code&gt;height: auto&lt;/code&gt;. So how?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.eyebrow&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;                                &lt;span class="cm"&gt;/* visible state */&lt;/span&gt;
  &lt;span class="nl"&gt;max-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;40px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="nl"&gt;overflow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;hidden&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;        &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;visibility&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;visible&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;max-height&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;5s&lt;/span&gt; &lt;span class="nf"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;--ease-out&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="n"&gt;opacity&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;35s&lt;/span&gt; &lt;span class="n"&gt;ease&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="n"&gt;transform&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;5s&lt;/span&gt; &lt;span class="nf"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;--ease-out&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="n"&gt;visibility&lt;/span&gt; &lt;span class="mi"&gt;0s&lt;/span&gt; &lt;span class="n"&gt;linear&lt;/span&gt; &lt;span class="mi"&gt;0s&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;    &lt;span class="cm"&gt;/* flip to visible immediately */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;body&lt;/span&gt;&lt;span class="nc"&gt;.studio-active&lt;/span&gt; &lt;span class="nc"&gt;.eyebrow&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;             &lt;span class="cm"&gt;/* hidden state */&lt;/span&gt;
  &lt;span class="nl"&gt;max-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;translateY&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;-12px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;visibility&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;hidden&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;pointer-events&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;max-height&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;5s&lt;/span&gt; &lt;span class="nf"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;--ease-out&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="n"&gt;opacity&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;35s&lt;/span&gt; &lt;span class="n"&gt;ease&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="n"&gt;transform&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;5s&lt;/span&gt; &lt;span class="nf"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;--ease-out&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="n"&gt;visibility&lt;/span&gt; &lt;span class="mi"&gt;0s&lt;/span&gt; &lt;span class="n"&gt;linear&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;5s&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="cm"&gt;/* ...but wait .5s before hiding */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two ideas hold this up:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;max-height&lt;/code&gt; instead of &lt;code&gt;height&lt;/code&gt;.&lt;/strong&gt; Browsers can animate between two numbers (40px → 0px) but not between a number and &lt;code&gt;auto&lt;/code&gt;. Pick a ceiling that is safely bigger than the content, and animate to it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The delayed &lt;code&gt;visibility&lt;/code&gt; flip.&lt;/strong&gt; That last line is the expert part. &lt;code&gt;visibility: hidden&lt;/code&gt; makes an element unclickable, unfocusable and invisible to screen readers, which is what you want &lt;em&gt;eventually&lt;/em&gt;. But if it flipped instantly, the fade would never be seen. So when hiding, it waits &lt;code&gt;.5s&lt;/code&gt; (the length of the animation) and &lt;em&gt;then&lt;/em&gt; flips. When showing, it flips right away so the fade-in can be seen.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Without this, you get one of two bad endings: an invisible tagline that keyboard users can still tab into, or a tagline that vanishes with no animation at all.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Developer:&lt;/strong&gt; &lt;code&gt;display: none&lt;/code&gt; and a jump.&lt;br&gt;
&lt;strong&gt;Expert:&lt;/strong&gt; fades first, then removes it from the page's reach.&lt;/p&gt;


&lt;h2&gt;
  
  
  Test 6: Why does &lt;code&gt;100vh&lt;/code&gt; hide the bottom of my layout on a phone?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;In plain English.&lt;/strong&gt; On a phone, the browser's address bar slides away as you scroll. &lt;code&gt;100vh&lt;/code&gt; means "the screen height &lt;em&gt;with the bar hidden&lt;/em&gt;", so when the bar is showing, the bottom 60 or so pixels of your layout are tucked underneath it. Buttons you can't tap. That is not your imagination.&lt;/p&gt;

&lt;p&gt;Modern CSS has three honest heights:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Unit&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;lvh&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the &lt;strong&gt;large&lt;/strong&gt; viewport: bars hidden&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;svh&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the &lt;strong&gt;small&lt;/strong&gt; viewport: bars showing, so it always fits&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;dvh&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the &lt;strong&gt;dynamic&lt;/strong&gt; viewport: follows the bars live&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;APIC uses them on purpose. The photo area must never push the tools off screen, so it uses &lt;code&gt;svh&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nt"&gt;root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nv"&gt;--apic-header&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;66px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="cm"&gt;/* Old browsers: vh. Photo is never smaller than 260px, never taller than 60% of the screen,
     and always leaves 330px for the title bar, tabs and first controls. */&lt;/span&gt;
  &lt;span class="nv"&gt;--apic-img-max&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;260px&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;60vh&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100vh&lt;/span&gt; &lt;span class="n"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;330px&lt;/span&gt; &lt;span class="n"&gt;-&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;--apic-header&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;62px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;@supports&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;100svh&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;              &lt;span class="cm"&gt;/* Browsers that understand svh override it */&lt;/span&gt;
  &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;--apic-img-max&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;260px&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;60svh&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100svh&lt;/span&gt; &lt;span class="n"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;330px&lt;/span&gt; &lt;span class="n"&gt;-&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;--apic-header&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;62px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;body&lt;/span&gt;&lt;span class="nc"&gt;.studio-active&lt;/span&gt; &lt;span class="nc"&gt;.studio-wrap&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;min-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100vh&lt;/span&gt;  &lt;span class="n"&gt;-&lt;/span&gt; &lt;span class="nf"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;--apic-header&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="cm"&gt;/* fallback */&lt;/span&gt;
  &lt;span class="nl"&gt;min-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100svh&lt;/span&gt; &lt;span class="n"&gt;-&lt;/span&gt; &lt;span class="nf"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;--apic-header&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="cm"&gt;/* wins if understood */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Read &lt;code&gt;max(260px, min(60svh, …))&lt;/code&gt; as a sandwich: &lt;strong&gt;"at least 260px, at most 60% of the screen, and never so tall that the controls fall off."&lt;/strong&gt; APIC's full-screen design studio (a &lt;code&gt;position: fixed; inset: 0&lt;/code&gt; overlay) is different: it should fill the screen &lt;em&gt;exactly&lt;/em&gt;, and keep doing so as the bar slides in and out, so it uses &lt;code&gt;dvh&lt;/code&gt;: &lt;code&gt;#dsApp { height: 100vh; height: 100dvh; }&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The pattern is also worth stealing: write the old value first, then the new one on the next line. A browser that doesn't understand the second line ignores it. No JavaScript, no feature detection.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Developer:&lt;/strong&gt; &lt;code&gt;height: 100vh&lt;/code&gt;, tests on desktop, ships.&lt;br&gt;
&lt;strong&gt;Expert:&lt;/strong&gt; knows which of three heights each element actually means.&lt;/p&gt;


&lt;h2&gt;
  
  
  Test 7: Is a small screen the same thing as a finger?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;In plain English.&lt;/strong&gt; No. A small laptop window is small but has a precise mouse. An iPad is big but has a thumb. If your "mobile layout" is triggered by &lt;em&gt;width&lt;/em&gt;, both get the wrong thing.&lt;/p&gt;

&lt;p&gt;CSS can ask about the &lt;strong&gt;pointer&lt;/strong&gt; instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;pointer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;coarse&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;                       &lt;span class="cm"&gt;/* "the main input is a finger" */&lt;/span&gt;
  &lt;span class="n"&gt;html&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;-webkit-tap-highlight-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;transparent&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;-webkit-text-size-adjust&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="kt"&gt;%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nc"&gt;.btn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;.tool-btn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;.quick-btn&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;min-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;44px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;          &lt;span class="cm"&gt;/* finger-sized targets */&lt;/span&gt;
  &lt;span class="n"&gt;select&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;textarea&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;16px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                                         &lt;span class="cm"&gt;/* stops the iPhone zoom-in */&lt;/span&gt;
    &lt;span class="nl"&gt;min-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;44px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;range&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;min-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;32px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cm"&gt;/* the area you draw on with a finger or mouse */&lt;/span&gt;
&lt;span class="nn"&gt;#overlay&lt;/span&gt;&lt;span class="nc"&gt;.active&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;crosshair&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;touch-action&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                  &lt;span class="cm"&gt;/* drawing must not scroll or zoom the page */&lt;/span&gt;
  &lt;span class="nl"&gt;-webkit-touch-callout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;user-select&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three small rules, three real problems:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;44px&lt;/strong&gt; is the size Apple's guidelines recommend for a tappable thing. Smaller, and people hit the wrong button.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;16px inputs.&lt;/strong&gt; On iPhone Safari, tapping a text field with a font smaller than 16px makes the whole page zoom in. Annoying, and it does not zoom back out on its own.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;touch-action: none&lt;/code&gt;&lt;/strong&gt; on the drawing layer. Without it, dragging your finger across a photo to erase a background &lt;em&gt;scrolls the page&lt;/em&gt; instead. The browser has to be told "this area is mine".&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Developer:&lt;/strong&gt; &lt;code&gt;@media (max-width: 600px)&lt;/code&gt; and hope.&lt;br&gt;
&lt;strong&gt;Expert:&lt;/strong&gt; designs for the input device, not the screen size.&lt;/p&gt;


&lt;h2&gt;
  
  
  Test 8: Is your "stylish" grey text actually readable?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;In plain English.&lt;/strong&gt; Dark themes love soft grey text. It looks calm in a design tool. Then someone opens your site outdoors, or is tired, or is 55, and the secondary text turns into fog.&lt;/p&gt;

&lt;p&gt;You do not have to guess. Readability has a number: the &lt;strong&gt;contrast ratio&lt;/strong&gt;. WCAG, the accessibility standard, asks for &lt;strong&gt;4.5 or more&lt;/strong&gt; for normal text (level AA), and &lt;strong&gt;7 or more&lt;/strong&gt; is the gold level (AAA). Here is the whole calculation, in 5 lines of JavaScript:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;lin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;/=&lt;/span&gt; &lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mf"&gt;0.03928&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mf"&gt;12.92&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.055&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mf"&gt;1.055&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="mf"&gt;2.4&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;lum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;hex&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;g&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;lin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;parseInt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hex&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mf"&gt;0.2126&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.7152&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;g&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.0722&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;      &lt;span class="c1"&gt;// how bright the eye sees it&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;ratio&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;lum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;lum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;05&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;05&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;ratio&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'#8b8fa3'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'#07070a'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// 6.28&lt;/span&gt;
&lt;span class="nf"&gt;ratio&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'#a3a9bd'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'#07070a'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// 8.59&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;APIC's first dark theme used &lt;code&gt;#8b8fa3&lt;/code&gt; for muted text. That is already a pass. But a late "dark-mode legibility pass" lifted it anyway, and it started with one line of variables:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;html&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nf"&gt;not&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;data-theme&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"light"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nv"&gt;--text-muted&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#a3a9bd&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                 &lt;span class="cm"&gt;/* was #8b8fa3 */&lt;/span&gt;
  &lt;span class="nv"&gt;--line&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;160&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;220&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;      &lt;span class="cm"&gt;/* was .14: borders you can actually see */&lt;/span&gt;
  &lt;span class="nv"&gt;--btn-text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#d9deec&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Muted text on&lt;/th&gt;
&lt;th&gt;Before&lt;/th&gt;
&lt;th&gt;After&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;page background &lt;code&gt;#07070a&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;6.28&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;8.59&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;card &lt;code&gt;#0d0d13&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;6.05&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;8.27&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;raised panel &lt;code&gt;#14141c&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;5.72&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;7.82&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;That moves every one of them from "passes" to "gold level", with three variable changes, not 200 selector edits. This is the quiet payoff of Test 1: when your colours live in variables, an accessibility fix is a small diff.&lt;/p&gt;

&lt;p&gt;(The bright green of the main buttons is easy: &lt;code&gt;#39ff9d&lt;/code&gt; against the page is &lt;strong&gt;15.3&lt;/strong&gt;.)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Developer:&lt;/strong&gt; "it looks fine on my monitor."&lt;br&gt;
&lt;strong&gt;Expert:&lt;/strong&gt; measures it, and fixes it where the colour is defined.&lt;/p&gt;


&lt;h2&gt;
  
  
  Test 9: How much can your HTML do &lt;em&gt;before&lt;/em&gt; you write any JavaScript?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;In plain English.&lt;/strong&gt; CSS gets the glory, but a lot of "interactive" features are already built into HTML. Using them means fewer bugs, less code, and a page that works for people using keyboards and screen readers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. An accordion in four lines.&lt;/strong&gt; APIC's FAQ and its advanced tool sections are 20 &lt;code&gt;&amp;lt;details&amp;gt;&lt;/code&gt; elements:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;details&lt;/span&gt; &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"faq-item"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;Is APIC really free?&lt;span class="nt"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;Yes. APIC is a free online photo editor that runs in your browser…&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/details&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.faq-item&lt;/span&gt; &lt;span class="nt"&gt;summary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nt"&gt;focus-visible&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;outline&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2px&lt;/span&gt; &lt;span class="n"&gt;solid&lt;/span&gt; &lt;span class="nf"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;--cyan&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;outline-offset&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You get open and close, keyboard support (Tab, Enter, Space) and screen readers announcing "expanded" or "collapsed", for free. CSS only adds a focus outline so keyboard users can see where they are. That is the whole component.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Landmarks.&lt;/strong&gt; The page uses &lt;code&gt;&amp;lt;header&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;nav&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;main&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;section&amp;gt;&lt;/code&gt; ×7 and &lt;code&gt;&amp;lt;footer&amp;gt;&lt;/code&gt; instead of a pile of &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;s. Screen reader users can jump straight to "main content". Search engines also understand the page's shape.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. One honest security line.&lt;/strong&gt; In the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;http-equiv&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Content-Security-Policy"&lt;/span&gt; &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"object-src 'none'; base-uri 'self'"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It does two small things: no old-style plugins (&lt;code&gt;object-src 'none'&lt;/code&gt;), and nobody can sneak in a &lt;code&gt;&amp;lt;base&amp;gt;&lt;/code&gt; tag that redirects your relative links elsewhere (&lt;code&gt;base-uri 'self'&lt;/code&gt;). It is a small policy and I will not pretend it is a full shield. Honest, narrow rules are better than a big one nobody maintains.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. A page that explains itself to machines.&lt;/strong&gt; A short block of JSON-LD in the head tells crawlers "this is a free photo-editing app, here is its feature list, here are the questions people ask". Plus Open Graph tags so a pasted link shows a proper preview card instead of a bare URL.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Developer:&lt;/strong&gt; builds an accordion with &lt;code&gt;div&lt;/code&gt;s, an &lt;code&gt;onclick&lt;/code&gt; and an &lt;code&gt;isOpen&lt;/code&gt; variable.&lt;br&gt;
&lt;strong&gt;Expert:&lt;/strong&gt; uses the element that already exists.&lt;/p&gt;


&lt;h2&gt;
  
  
  🎁 Bonus: a checkerboard with zero image files
&lt;/h2&gt;

&lt;p&gt;When you open a transparent PNG in an image editor, you see the grey checkerboard behind it. APIC draws it with &lt;strong&gt;one declaration&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.has-alpha&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;repeating-conic-gradient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mh"&gt;#8a8a8a&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="kt"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="kt"&gt;%&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;#5c5c5c&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="kt"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="kt"&gt;%&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;18px&lt;/span&gt; &lt;span class="mi"&gt;18px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A &lt;em&gt;conic&lt;/em&gt; gradient sweeps around a centre point like a clock hand. This one says "grey A for the first quarter turn, grey B for the second quarter, then repeat". Each stop starts at &lt;code&gt;0%&lt;/code&gt;, which is &lt;em&gt;earlier&lt;/em&gt; than where the previous one ended, so the browser snaps it up to the previous stop, which gives hard edges instead of a blend. Four quarters make two light squares and two dark ones. Shrink it to an 18px tile, repeat it, and you have a checkerboard.&lt;/p&gt;

&lt;p&gt;No PNG to download, no extra request, and it stays sharp on any screen.&lt;/p&gt;




&lt;h2&gt;
  
  
  😬 Two tests I still fail in APIC's own code
&lt;/h2&gt;

&lt;p&gt;A post called "tests I failed" would be dishonest if it only covered the ones I fixed. I audited the shipping file for this article and found two:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fail 1: smooth scrolling ignores reduced motion.&lt;/strong&gt; The file has &lt;code&gt;html { scroll-behavior: smooth; }&lt;/code&gt; and no matching opt-out. So someone who asked their device to minimise motion still gets animated scrolling on anchor links. The fix is to &lt;em&gt;only&lt;/em&gt; turn it on for people who haven't asked otherwise:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;prefers-reduced-motion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;no-preference&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;html&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;scroll-behavior&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;smooth&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Fail 2: safe-area insets that do nothing.&lt;/strong&gt; APIC writes &lt;code&gt;bottom: calc(18px + env(safe-area-inset-bottom, 0px))&lt;/code&gt; for its back-to-top button, so it should clear the iPhone's home bar. But &lt;code&gt;env(safe-area-inset-*)&lt;/code&gt; only returns real values if the page asks to draw edge to edge:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"viewport"&lt;/span&gt; &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"width=device-width, initial-scale=1.0, viewport-fit=cover"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The file's viewport tag doesn't have &lt;code&gt;viewport-fit=cover&lt;/code&gt;, so in that file those &lt;code&gt;env()&lt;/code&gt; lines quietly resolve to their &lt;code&gt;0px&lt;/code&gt; fallback. The CSS half was written; the HTML half was missing. The lesson fits this whole series: &lt;strong&gt;a line of code that never errors can still never run.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🔍 Check my work in 60 seconds
&lt;/h2&gt;

&lt;p&gt;Don't trust me, trust DevTools. Open &lt;strong&gt;&lt;a href="https://apic-studio.vercel.app/" rel="noopener noreferrer"&gt;APIC&lt;/a&gt;&lt;/strong&gt;, press &lt;code&gt;F12&lt;/code&gt;, then:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Elements → &lt;code&gt;&amp;lt;html&amp;gt;&lt;/code&gt;.&lt;/strong&gt; Watch &lt;code&gt;data-theme&lt;/code&gt; flip when you change the theme (Test 1).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Styles panel → search &lt;code&gt;isolation&lt;/code&gt;, &lt;code&gt;mask-composite&lt;/code&gt;, &lt;code&gt;color-mix&lt;/code&gt;.&lt;/strong&gt; Every technique above is in there (Tests 2 to 4).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Toolbar → device icon.&lt;/strong&gt; Pick a phone, then look at the layout with the address bar showing (Test 6).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rendering tab → "Emulate CSS media feature prefers-reduced-motion".&lt;/strong&gt; Watch the glow animation switch off (Test 3).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pick any grey text → click the colour swatch.&lt;/strong&gt; DevTools shows the contrast ratio for you (Test 8).&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  🏆 Your score
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tests you already knew&lt;/th&gt;
&lt;th&gt;You are…&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;0–3&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;A CSS &lt;em&gt;developer&lt;/em&gt;. You build things that work. Pick one test above and recreate it from scratch. That is how this stuff sticks.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;4–6&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Solid. You have shipped real interfaces and met real browsers.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;7–9&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;A CSS &lt;em&gt;expert&lt;/em&gt;. Come argue with me in the comments.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;And the part nobody puts in a score table: the experts in this post aren't people who memorised more properties. They're people who stopped asking "what does this line do?" and started asking &lt;strong&gt;"what will the browser do &lt;em&gt;before&lt;/em&gt;, &lt;em&gt;after&lt;/em&gt; and &lt;em&gt;instead&lt;/em&gt;?"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Which test did you fail first?&lt;/strong&gt; Mine is in the "Two tests I still fail" section, so you already know. Tell me yours below 👇 &lt;em&gt;(and if you spot a mistake in my code, say so. That's the point of this series.)&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Try APIC, and break it
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://apic-studio.vercel.app/" rel="noopener noreferrer"&gt;Open APIC&lt;/a&gt;&lt;/strong&gt; is free, runs in your browser, and (per its own description) processes images on your device rather than uploading them. Try the background remover, drag in a transparent PNG for the checkerboard, switch themes for Test 1, then open DevTools and hunt for every technique above.&lt;/p&gt;

&lt;p&gt;Not just try it: &lt;strong&gt;break it too.&lt;/strong&gt; I want feedback, because feedback is what makes the next version better.&lt;br&gt;
&lt;strong&gt;Desktop version:&lt;/strong&gt;&lt;br&gt;
[APIC DESKTOP]🖥️💻&lt;br&gt;
-----&amp;gt;  &lt;a href="https://github.com/Akhouri-Systems/APIC/releases/download/APIC/APIC.zip" rel="noopener noreferrer"&gt;https://github.com/Akhouri-Systems/APIC/releases/download/APIC/APIC.zip&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  📢 remove.bg is shutting down on December 1. Here is a free alternative
&lt;/h2&gt;

&lt;p&gt;If you use remove.bg, you have a deadline. The service has announced that its standalone website and self-serve API close on &lt;strong&gt;1 December 2026 at 9:00 am CET&lt;/strong&gt;. Background removal is moving into Canva, the developer API is moving to Leonardo.Ai, and unused pay-as-you-go credits expire the same day. (Always check remove.bg's own notice for the latest details.)&lt;/p&gt;

&lt;p&gt;If what you actually need is &lt;em&gt;"drop in a photo, get a transparent PNG"&lt;/em&gt;, &lt;strong&gt;&lt;a href="https://apic-studio.vercel.app/" rel="noopener noreferrer"&gt;APIC&lt;/a&gt;&lt;/strong&gt; does that for free, and everything you just read about is how it is built:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🔒 &lt;strong&gt;Runs in your browser.&lt;/strong&gt; The AI model runs on your own device using WebAssembly. Per APIC's own description, your photos are not uploaded to a server.&lt;/li&gt;
&lt;li&gt;⚡ &lt;strong&gt;Three model sizes.&lt;/strong&gt; Lite (about 5 MB), Fast (about 44 MB) and Maximum (about 176 MB). The model downloads once, is cached on your device, and later runs start much faster.&lt;/li&gt;
&lt;li&gt;🆓 &lt;strong&gt;No paid tiers and no credits.&lt;/strong&gt; There is nothing to run out of on December 1. You can edit without an account, and the site signs you in with Google only when you export.&lt;/li&gt;
&lt;li&gt;🧰 &lt;strong&gt;More than a remover.&lt;/strong&gt; Resize, compress to a target file size, convert between PNG, JPEG, WebP, BMP, ICO and PDF, remove objects, social media size presets, and a batch studio for many images at once.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What APIC is &lt;em&gt;not&lt;/em&gt;:&lt;/strong&gt; it is a web tool, not an API and not a Photoshop plugin. If a script or a plugin depends on remove.bg, you need a developer replacement (remove.bg points API users to Leonardo.Ai). And no tool is perfect on every photo, so try your hardest images (hair, glass, fine edges) before you switch a real workflow.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do these before December 1, whatever you choose:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Use up any remove.bg credits. They do not roll over.&lt;/li&gt;
&lt;li&gt;Download your invoices and usage reports while the account still exists.&lt;/li&gt;
&lt;li&gt;Test APIC on 5 of your real photos. It takes two minutes: &lt;strong&gt;&lt;a href="https://apic-studio.vercel.app/" rel="noopener noreferrer"&gt;apic-studio.vercel.app&lt;/a&gt;&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;




</description>
      <category>css</category>
      <category>html</category>
      <category>beginners</category>
      <category>webassembly</category>
    </item>
    <item>
      <title>remove.bg Is Shutting Down — Here's a Free, No-Upload Alternative</title>
      <dc:creator>Akhouri Anmol Kumar</dc:creator>
      <pubDate>Fri, 13 Nov 2026 11:05:50 +0000</pubDate>
      <link>https://dev.to/akhourianmolkumar/removebg-is-shutting-down-heres-a-free-no-upload-alternative-4ebo</link>
      <guid>https://dev.to/akhourianmolkumar/removebg-is-shutting-down-heres-a-free-no-upload-alternative-4ebo</guid>
      <description>&lt;p&gt;On &lt;strong&gt;December 1, 2026 at 9:00 AM CET&lt;/strong&gt;, remove.bg — the site that turned "one-click background removal" into an entire category — pulls the plug on its standalone website. It's being folded into Canva, and the API crowd is being pointed toward Leonardo.ai. You can read the notice on &lt;a href="https://www.remove.bg/pricing" rel="noopener noreferrer"&gt;remove.bg's own pricing page&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If your workflow just lost its favorite button: &lt;strong&gt;don't cry. Your hero is here.&lt;/strong&gt; It's free, it runs in your browser, and it never uploads your photos.&lt;/p&gt;

&lt;p&gt;It's called &lt;strong&gt;&lt;a href="https://apic-studio.vercel.app/" rel="noopener noreferrer"&gt;APIC Web&lt;/a&gt;&lt;/strong&gt;, I built it solo, and this post is the official "shift here" announcement.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fl18z9jrygadt9i68ivi3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fl18z9jrygadt9i68ivi3.png" alt=" " width="800" height="379"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjcm74cepcagmbyotvh5s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjcm74cepcagmbyotvh5s.png" alt=" " width="799" height="382"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What's actually happening to remove.bg?
&lt;/h2&gt;

&lt;p&gt;Quick recap, because a lot of people are about to find out the hard way:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The standalone site dies on Dec 1, 2026.&lt;/strong&gt; Bookmarks, muscle memory, that one tab you always keep open — gone.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Background removal moves into Canva&lt;/strong&gt;, where it's a Pro-tier feature, not a free utility.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Free was never really free.&lt;/strong&gt; remove.bg's free tier only ever gave you preview-resolution downloads. Full-resolution cut-outs cost credits — roughly $9/month for 40 images.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;API users&lt;/strong&gt; are being migrated to Leonardo.ai's pricing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So the real question trending right now is: &lt;em&gt;"What's the best free remove.bg alternative that gives full-resolution transparent PNGs without a subscription?"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;That's literally the question I built APIC to answer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Meet APIC Web — the free background remover that never uploads your photos
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;👉 &lt;a href="https://apic-studio.vercel.app/" rel="noopener noreferrer"&gt;https://apic-studio.vercel.app/&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;APIC Web is a free online photo editor and AI background remover that runs &lt;strong&gt;100% on your device&lt;/strong&gt;, inside your browser tab. The AI models are compiled to WebAssembly, downloaded once, cached, and executed locally. Your images are never sent to any server. Not for processing, not for "quality improvement", not for anything.&lt;/p&gt;

&lt;p&gt;And the part that matters most for everyone migrating off remove.bg:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ &lt;strong&gt;Full-resolution output&lt;/strong&gt; — not a preview thumbnail&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Transparent PNG / WebP&lt;/strong&gt; with edge refinement and color-fringe removal&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;No credits, no watermarks, no paid tiers&lt;/strong&gt; — there is no pricing page because there is no price&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;No account required — for anything.&lt;/strong&gt; Editing, AI tools, exporting, even batch ZIP downloads all work signed-out. There's an optional one-tap Google sign-in if you &lt;em&gt;want&lt;/em&gt; to join the community counter — if you don't, just ignore it. Sign-in is a community feature, not a gate.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  APIC vs remove.bg vs Canva: the honest comparison
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;APIC Web&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;remove.bg (until Dec 1)&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Canva BG Remover&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Price&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;$0, forever&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Free previews; ~$9/mo for 40 full-res credits&lt;/td&gt;
&lt;td&gt;Pro subscription&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Full-res free downloads&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;✅ Unlimited&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;❌ Credits only&lt;/td&gt;
&lt;td&gt;❌ Pro only&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Photo uploads to a server&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Never — on-device AI&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Every image&lt;/td&gt;
&lt;td&gt;Every image&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Account needed&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;No (optional)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bulk / batch removal&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;✅ Free Batch Studio → ZIP&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Paid API&lt;/td&gt;
&lt;td&gt;Pro feature&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Works offline&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;✅ Free Windows app&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Why "no upload" isn't a gimmick — it's the architecture
&lt;/h2&gt;

&lt;p&gt;Here's the dev-to-dev explanation of why APIC can be genuinely free while everyone else meters credits:&lt;/p&gt;

&lt;p&gt;Cloud editors pay for GPU compute every time you click "remove background". That's why they ration you — credits, queues, paywalls. Their free tier is a funnel.&lt;/p&gt;

&lt;p&gt;APIC flips the model: &lt;strong&gt;your device is the GPU.&lt;/strong&gt; The segmentation and inpainting models run in your browser via WebAssembly. My per-image compute cost is exactly ₹0.00, so "free forever" isn't a marketing promise — it's a property of the architecture.&lt;/p&gt;

&lt;p&gt;It also means APIC is the rare background remover you can safely use on &lt;strong&gt;ID scans, client work under NDA, unreleased product photos, or anything you'd never paste into someone else's server.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Three engines, picked for your hardware
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Mode&lt;/th&gt;
&lt;th&gt;First download&lt;/th&gt;
&lt;th&gt;Built for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Light&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;~5 MB&lt;/td&gt;
&lt;td&gt;Phones&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Fast&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;~44 MB&lt;/td&gt;
&lt;td&gt;Everyday use, any device&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Maximum&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;~176 MB&lt;/td&gt;
&lt;td&gt;Multi-pass accuracy, PC recommended&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Models download once and are cached — repeat runs start fast. If a download fails, APIC retries automatically. Every AI result can be undone with &lt;strong&gt;Ctrl+Z&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fspiqr1nb1f8xxxk4xb1r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fspiqr1nb1f8xxxk4xb1r.png" alt=" " width="800" height="380"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Plot twist: it's not just a background remover
&lt;/h2&gt;

&lt;p&gt;remove.bg did one thing. APIC is a full studio. Same tab, same zero-upload promise:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;🧽 Remove Object&lt;/strong&gt; — paint over anything and an on-device inpainting model fills it in, color-matched and re-grained to your photo. &lt;em&gt;Ultra&lt;/em&gt; mode uses &lt;strong&gt;LaMa&lt;/strong&gt; (a large Fourier-convolution inpainting network, ~208 MB) for big/complex objects; &lt;em&gt;Best/Fast&lt;/em&gt; use the lighter &lt;strong&gt;MI-GAN&lt;/strong&gt; (~28 MB) that works on phones. If a model can't load, it degrades gracefully: Ultra → MI-GAN → quick patch fill.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;🔍 AI Upscale 2× / 4×&lt;/strong&gt; — &lt;strong&gt;Real-ESRGAN&lt;/strong&gt; (x4plus for max accuracy, a 5 MB fast model for phones).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;🎨 Pro color suite&lt;/strong&gt; — live histogram, RGB curves, an 8-band HSL mixer, 3-way color grading, white balance, tone and detail controls.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;🎬 Export your grade as a &lt;code&gt;.cube&lt;/code&gt; LUT&lt;/strong&gt; — a real 33×33×33 3D LUT you can drop into &lt;strong&gt;DaVinci Resolve, Premiere, or Photoshop&lt;/strong&gt;. Grade a still, carry the look into your video timeline. (Color-only operations are baked in; spatial effects like grain and vignette aren't, because they're not color transforms.) I haven't seen another browser tool do this.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;🔁 Convert&lt;/strong&gt; — PNG, JPEG, WebP, BMP, ICO, PDF, even &lt;strong&gt;PSD with layers kept&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;🗜️ Compress to a target file size&lt;/strong&gt; — tell it "300 KB" and it searches quality levels for the best-looking image that fits. No guessing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;📐 Resize&lt;/strong&gt; — exact pixels or percent, with step-down (multi-pass halving) resampling so shrinks stay crisp instead of muddy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;📦 Batch Studio&lt;/strong&gt; — drop in many images, remove backgrounds / resize / compress / convert them all, download one ZIP. Free, on-device, no account.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;📱 Social presets&lt;/strong&gt; — exact-size profiles, banners, posts and stories for &lt;strong&gt;15 networks&lt;/strong&gt; (Instagram, YouTube, X, TikTok, LinkedIn, Discord, Twitch, Spotify…), with safe-zone guides and automatic platform size limits. Export one size or a ZIP of all of them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;✨ One-click extras&lt;/strong&gt; — auto-enhance, smart crop, fit subject, crop to subject.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Prefer offline? There's a Windows app
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/Akhouri-Anmol-Kumar/APIC/releases/download/APIC/APIC.zip" rel="noopener noreferrer"&gt;Download APIC for PC&lt;/a&gt;&lt;/strong&gt; — fully offline, same edit/convert/compress stack, no account needed to download or use it. &lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ (the stuff you're about to Google)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is the best free remove.bg alternative in 2026?
&lt;/h3&gt;

&lt;p&gt;If you want full-resolution cut-outs with no credits and no uploads: &lt;strong&gt;&lt;a href="https://apic-studio.vercel.app/" rel="noopener noreferrer"&gt;APIC Web&lt;/a&gt;&lt;/strong&gt;. It runs on-device AI in your browser and stays free because there's no server compute to pay for.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is APIC Web really free? What's the catch?
&lt;/h3&gt;

&lt;p&gt;No paid tiers, no credits, no watermarks. The "catch" is that your own device does the work — which is also the privacy feature.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do I need to sign up to remove a background or export?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;No.&lt;/strong&gt; Everything works without an account, including exports and batch downloads. Google sign-in is optional — it exists for the community counter and update emails. Skip it freely.&lt;/p&gt;

&lt;h3&gt;
  
  
  Are my photos uploaded anywhere?
&lt;/h3&gt;

&lt;p&gt;Never. The only network traffic is the one-time model download from a CDN. Your images stay in your browser's memory, on your machine.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does it work on phones?
&lt;/h3&gt;

&lt;p&gt;Yes — the Light engine is a ~5 MB model made for phones, and MI-GAN object removal works on mobile too.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can I remove backgrounds from many images at once?
&lt;/h3&gt;

&lt;p&gt;Yes. Batch Studio processes a whole pile locally and hands you one ZIP. Free, no sign-in.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bookmark it before December 1
&lt;/h2&gt;

&lt;p&gt;The remove.bg shutdown is going to strand a lot of people in three weeks. If this post found you before that happens — you're early, not late.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🔗 &lt;a href="https://apic-studio.vercel.app/" rel="noopener noreferrer"&gt;apic-studio.vercel.app&lt;/a&gt;&lt;/strong&gt; — open it, drop an image, hit &lt;em&gt;Remove background&lt;/em&gt;. That's the whole onboarding.&lt;/p&gt;

&lt;p&gt;I'm a solo developer, and APIC is a product of &lt;strong&gt;Akhouri Systems&lt;/strong&gt;. If it saves your workflow, do me one favor: share it with someone who's still mourning remove.bg. And if you want a feature, comment — I read everything.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Built with WebAssembly, stubbornness, and an HP 240 G9(my bro).&lt;/em&gt;&lt;br&gt;
&lt;em&gt;— Akhouri Anmol Kumar, Akhouri Systems&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Thanks to &lt;a class="mentioned-user" href="https://dev.to/effessdev"&gt;@effessdev&lt;/a&gt; bro for finding bugs in APIC, it helped me to make APIC perfect day by day&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>webdev</category>
      <category>ai</category>
      <category>webassembly</category>
    </item>
    <item>
      <title>Claude Fable 5.2 vs GPT-6 Astra vs Gemini 4 Argon: The AI Endgame of 2026 🔥</title>
      <dc:creator>Akhouri Anmol Kumar</dc:creator>
      <pubDate>Thu, 12 Nov 2026 05:13:52 +0000</pubDate>
      <link>https://dev.to/akhourianmolkumar/claude-fable-52-vs-gpt-6-astra-vs-gemini-4-argon-the-ai-endgame-of-2026-3k4l</link>
      <guid>https://dev.to/akhourianmolkumar/claude-fable-52-vs-gpt-6-astra-vs-gemini-4-argon-the-ai-endgame-of-2026-3k4l</guid>
      <description>&lt;h2&gt;
  
  
  The battlefield is set ⚔️
&lt;/h2&gt;

&lt;p&gt;Imagine the opening scene of a final battle. Three armies, one field, and every developer on the internet sitting in the stands with popcorn.&lt;/p&gt;

&lt;p&gt;In September, OpenAI dropped &lt;strong&gt;GPT-6 Astra&lt;/strong&gt; and X.com lost its mind. At the end of the month Google answered with &lt;strong&gt;Gemini 4 Argon&lt;/strong&gt;. And on &lt;strong&gt;November 9, 2026&lt;/strong&gt;, just day before yesterday, Anthropic walked in with &lt;strong&gt;Claude Fable 5.2&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Three models. One question: &lt;strong&gt;which one is the most powerful AI of 2026?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I went through the launch numbers and the wildest posts on X.com so you don't have to. Grab your seat. 🍿&lt;/p&gt;




&lt;h2&gt;
  
  
  🧬 Meet the contenders
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Claude Fable 5.2&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;GPT-6 Astra&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Gemini 4 Argon&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Maker&lt;/td&gt;
&lt;td&gt;Anthropic&lt;/td&gt;
&lt;td&gt;OpenAI&lt;/td&gt;
&lt;td&gt;Google DeepMind&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Launched&lt;/td&gt;
&lt;td&gt;Nov 9, 2026&lt;/td&gt;
&lt;td&gt;Sep 3-4, 2026&lt;/td&gt;
&lt;td&gt;Announced Sep 30, broadly available Oct 13, 2026&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;API price (per 1M tokens, in/out)&lt;/td&gt;
&lt;td&gt;$8 / $40&lt;/td&gt;
&lt;td&gt;$10 / $50&lt;/td&gt;
&lt;td&gt;$2 / $10 introductory (through Nov 30), $4 / $20 standard&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Headline trick&lt;/td&gt;
&lt;td&gt;Ambitious, open-ended technical work, with more than 1,000 subagents in one demo&lt;/td&gt;
&lt;td&gt;"Anything you can do on a computer", plus 3D and game building&lt;/td&gt;
&lt;td&gt;1M-token &lt;em&gt;output&lt;/em&gt; and strong knowledge work&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Now let's see them fight.&lt;/p&gt;




&lt;h2&gt;
  
  
  🛡️ Round 1: Claude Fable 5.2, the fresh arrival
&lt;/h2&gt;

&lt;p&gt;Fable 5.2 is barely a 2 day old and the timeline is already on fire.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The operating system from an empty folder.&lt;/strong&gt; Per Anthropic, an engineer pointed Fable 5.2 at an empty folder and it coordinated &lt;strong&gt;over 1,000 subagents over eight days&lt;/strong&gt; to write, test and review code around the clock. The result was a working prototype that boots on a laptop, with a kernel, disk, keyboard and network drivers, a login screen and an installer.&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-2119870808143298647-336" src="https://platform.twitter.com/embed/Tweet.html?id=2119870808143298647"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-2119870808143298647-336');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=2119870808143298647&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;🔗 &lt;a href="https://x.com/kimmonismus/status/2119870808143298647" rel="noopener noreferrer"&gt;View on X&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;One prompt, an entire 4K film.&lt;/strong&gt; Riley Brown gave Fable 5.2 a single prompt, live on stream. It wrote the code that builds a whole room in Blender, animated 13 camera shots, rented 10 GPUs, rendered it in 4K in 52 minutes for &lt;strong&gt;$5.75 total&lt;/strong&gt;, then added music and sound effects.&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-2119902109709537708-103" src="https://platform.twitter.com/embed/Tweet.html?id=2119902109709537708"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-2119902109709537708-103');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=2119902109709537708&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;🔗 &lt;a href="https://x.com/rileybrown/status/2119902109709537708" rel="noopener noreferrer"&gt;View on X&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hardware &lt;em&gt;and&lt;/em&gt; physics.&lt;/strong&gt; Anthropic's own thread says Fable 5.2 designed three working electronic devices from a one-paragraph prompt (specs, components, four-layer circuit boards, enclosures and software). It also claims to have solved two open problems in theoretical physics related to black holes.&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-2119899459761131615-269" src="https://platform.twitter.com/embed/Tweet.html?id=2119899459761131615"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-2119899459761131615-269');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=2119899459761131615&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;🔗 &lt;a href="https://x.com/claudeai/status/2119899459761131615" rel="noopener noreferrer"&gt;View on X&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🚀 Round 2: GPT-6 Astra, the computer-use monster
&lt;/h2&gt;

&lt;p&gt;OpenAI's pitch for Astra was simple: anything you can do on a computer, it can do for you. Then developers discovered it can drive &lt;strong&gt;Blender, Godot, Unreal and Three.js&lt;/strong&gt; by itself, and the game-dev posts started pouring in.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;10 wild examples in one thread.&lt;/strong&gt; Min Choi's roundup includes Astra rebuilding Manhattan street by street in Unreal Engine, recreating San Francisco's Palace of Fine Arts in Blender, a Minecraft one-shot, and one grey-box kart prototype turned into three complete themed games.&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-2095837897647686028-412" src="https://platform.twitter.com/embed/Tweet.html?id=2095837897647686028"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-2095837897647686028-412');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=2095837897647686028&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;🔗 &lt;a href="https://x.com/minchoi/status/2095837897647686028" rel="noopener noreferrer"&gt;View on X&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3D from a single image.&lt;/strong&gt; Elvis (@omarsar0) fed Astra one image reference and got a polished interactive 3D product visualization back, then shared the prompts so you can try it yourself.&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-2096321091148947887-38" src="https://platform.twitter.com/embed/Tweet.html?id=2096321091148947887"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-2096321091148947887-38');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=2096321091148947887&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;🔗 &lt;a href="https://x.com/omarsar0/status/2096321091148947887" rel="noopener noreferrer"&gt;View on X&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🌌 Round 3: Gemini 4 Argon, the dark horse
&lt;/h2&gt;

&lt;p&gt;Argon is Google's first Gemini with a codename instead of Pro/Flash tiers. Its party tricks: spatial reasoning, visual coding, and an industry-first &lt;strong&gt;1 million token output limit&lt;/strong&gt;, up from 64K.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wizard chess, a pagoda, a battle helicopter and more.&lt;/strong&gt; Another Min Choi roundup collects the Argon builds that went viral on launch day, including a full 3D wizard chess game shared by Demis Hassabis himself, and a detailed pagoda temple complex sculpted in Blender through multi-agent critique loops.&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-2110218145277395191-848" src="https://platform.twitter.com/embed/Tweet.html?id=2110218145277395191"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-2110218145277395191-848');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=2110218145277395191&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;🔗 &lt;a href="https://x.com/minchoi/status/2110218145277395191" rel="noopener noreferrer"&gt;View on X&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Google's own 5-build thread.&lt;/strong&gt; Fourier-epicycle animation, an interactive WebGL Mahjong game with spring physics, and playable stylized 3D games in Three.js.&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-2110440180142498036-635" src="https://platform.twitter.com/embed/Tweet.html?id=2110440180142498036"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-2110440180142498036-635');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=2110440180142498036&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;🔗 &lt;a href="https://x.com/Google/status/2110440180142498036" rel="noopener noreferrer"&gt;View on X&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  📊 The scoreboard (vendor numbers, take with salt 🧂)
&lt;/h2&gt;

&lt;p&gt;Here is what the published benchmarks say:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Benchmark&lt;/th&gt;
&lt;th&gt;Fable 5.2&lt;/th&gt;
&lt;th&gt;GPT-6 Astra&lt;/th&gt;
&lt;th&gt;Gemini 4 Argon&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;FrontierCode 2.0 (High effort)&lt;/td&gt;
&lt;td&gt;45.3%&lt;/td&gt;
&lt;td&gt;42.8%&lt;/td&gt;
&lt;td&gt;n/a&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;FrontierSWE v2&lt;/td&gt;
&lt;td&gt;69.9%&lt;/td&gt;
&lt;td&gt;65.5%&lt;/td&gt;
&lt;td&gt;55.0%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Humanity's Last Exam (with tools)&lt;/td&gt;
&lt;td&gt;74.2%&lt;/td&gt;
&lt;td&gt;57.2%&lt;/td&gt;
&lt;td&gt;n/a&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Remote Labor Index&lt;/td&gt;
&lt;td&gt;41.3%&lt;/td&gt;
&lt;td&gt;20.8%&lt;/td&gt;
&lt;td&gt;n/a&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Vals Index&lt;/td&gt;
&lt;td&gt;n/a&lt;/td&gt;
&lt;td&gt;63.1%&lt;/td&gt;
&lt;td&gt;68.9%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AutomationBench&lt;/td&gt;
&lt;td&gt;51.4%&lt;/td&gt;
&lt;td&gt;41.4%&lt;/td&gt;
&lt;td&gt;51.3%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Fable 5.2 and Astra numbers come from Anthropic's launch table; Argon numbers from Google's model card. One early write-up citing Artificial Analysis's independent index puts Fable 5.2 at 65 versus 57 for Astra at max effort, but treat that as early data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What stands out:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fable 5.2&lt;/strong&gt; leads Astra on every row Anthropic published, and Anthropic says it matches Opus 5.5 at roughly half the cost per task on FrontierCode 2.0.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GPT-6 Astra&lt;/strong&gt; is the strongest of the three on hard terminal and computer-use work in Google's table (FrontierSWE v2, OSWorld 2.0), and it's the one people use to drive Blender and game engines.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gemini 4 Argon&lt;/strong&gt; wins on legal, finance and business automation benchmarks, has the biggest output window, and is by far the cheapest right now. One analysis also reports a much lower hallucination rate for Argon than for Astra.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🎬 Plot twists (read before you crown anyone)
&lt;/h2&gt;

&lt;p&gt;I'd rather be honest than hype you into a bad decision:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Most Fable 5.2 numbers are Anthropic's own,&lt;/strong&gt; and the model launched yesterday. Independent side-by-sides are still coming.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Viral demos aren't proof.&lt;/strong&gt; When OpenAI's own account posted an Astra demo, critics pointed out the city matched a free Unity asset pack. Some Astra users also complain it burns usage on tests nobody asked for.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Argon's coding scores are mixed.&lt;/strong&gt; At launch it came last on FrontierSWE v2 and Terminal-Bench 4.0 in Google's table, even while winning elsewhere.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The sequel is already teased.&lt;/strong&gt; A &lt;code&gt;gpt-6.2-astra&lt;/code&gt; model ID has been spotted in Codex usage data. OpenAI hasn't confirmed anything, but expect the next round soon.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  🏆 So... who wins?
&lt;/h2&gt;

&lt;p&gt;If I had to answer for &lt;em&gt;today&lt;/em&gt;, on the evidence so far:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Most powerful on the published numbers:&lt;/strong&gt; Claude Fable 5.2. It leads Astra on every benchmark Anthropic reported and shows the most jaw-dropping long-horizon demos (an OS, hardware, physics).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Best for driving real software and 3D tools:&lt;/strong&gt; Claude Fable 5.2&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Best value and best for long outputs and business knowledge work:&lt;/strong&gt; Gemini 4 Argon, especially at its introductory pricing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There's no single Thanos here. The honest answer is that the right model depends on the job, and the lead could flip again by December. 😅&lt;/p&gt;

&lt;p&gt;Which one are you betting on? Drop your pick in the comments. 👇&lt;/p&gt;




&lt;h2&gt;
  
  
  💛 Support this writing
&lt;/h2&gt;

&lt;p&gt;I put hours into digging through benchmarks, model cards and X threads to make posts like this one accurate and fun. If it saved you time or taught you something, you can support my writing with a small contribution via &lt;strong&gt;UPI&lt;/strong&gt; (FamPay):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;7633003470@fam
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a&gt;&lt;strong&gt;Support via UPI&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;🇮🇳 &lt;em&gt;UPI works only for Indian bank accounts, so this option is for readers in India. Everyone else: a like, a share or a follow means just as much.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Thank you, truly. 🙏&lt;/p&gt;




&lt;h2&gt;
  
  
  🔗 Follow along
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;👨‍💻 &lt;strong&gt;Follow me on GitHub:&lt;/strong&gt; &lt;a href="https://github.com/Akhouri-Anmol-Kumar" rel="noopener noreferrer"&gt;github.com/Akhouri-Anmol-Kumar&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;🚀 &lt;strong&gt;Check out some great apps I shipped under Akhouri Systems:&lt;/strong&gt; &lt;a href="https://akhouri-anmol-kumar.github.io/Akhouri-systems/" rel="noopener noreferrer"&gt;akhouri-anmol-kumar.github.io/Akhouri-systems&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Sources: &lt;a href="https://openai.com/index/gpt-6-astra-next-generation-work/" rel="noopener noreferrer"&gt;OpenAI on GPT-6 Astra&lt;/a&gt;, &lt;a href="https://x.com/claudeai/status/2119867114450268322" rel="noopener noreferrer"&gt;Anthropic's Fable 5.2 announcement on X&lt;/a&gt;, &lt;a href="https://deepmind.google/models/model-cards/gemini-4-argon/" rel="noopener noreferrer"&gt;Google DeepMind's Gemini 4 Argon model card&lt;/a&gt;, &lt;a href="https://thenewstack.io/google-gemini-4-argon/" rel="noopener noreferrer"&gt;The New Stack on Argon&lt;/a&gt;, &lt;a href="https://kingy.ai/blog/fable-5-2-vs-gpt-6-astra/" rel="noopener noreferrer"&gt;Kingy AI on Fable 5.2 vs Astra&lt;/a&gt;, &lt;a href="https://lorphic.com/gemini-4-argon-benchmarks/" rel="noopener noreferrer"&gt;Lorphic's Argon benchmark table&lt;/a&gt;, &lt;a href="https://www.testingcatalog.com/gpt-6-2-astra-appears-codex-usage/" rel="noopener noreferrer"&gt;TestingCatalog on GPT-6.2 Astra&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>claude</category>
      <category>chatgpt</category>
      <category>gemini</category>
    </item>
    <item>
      <title>How a Privacy-First Online Image Editor Works Without Uploading Your Photos (WebAssembly + On-Device AI)</title>
      <dc:creator>Akhouri Anmol Kumar</dc:creator>
      <pubDate>Wed, 11 Nov 2026 07:11:29 +0000</pubDate>
      <link>https://dev.to/akhouri-systems/how-a-privacy-first-online-image-editor-works-without-uploading-your-photos-webassembly--ae8</link>
      <guid>https://dev.to/akhouri-systems/how-a-privacy-first-online-image-editor-works-without-uploading-your-photos-webassembly--ae8</guid>
      <description>&lt;p&gt;Most online image editors follow the same pattern. You pick a file, the browser uploads it, a server processes it, and a result comes back. It is simple to build, and it quietly means every photo you edit passes through someone else's infrastructure.&lt;/p&gt;

&lt;p&gt;Browsers no longer need that arrangement. With WebAssembly, the Canvas API, and models that run on the client, the work of a photo editor, background remover, and image converter can happen on the device in front of you.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://akhouri-anmol-kumar.github.io/Akhouri-systems/" rel="noopener noreferrer"&gt;Akhouri Systems&lt;/a&gt; built &lt;a href="https://apic-studio.vercel.app/" rel="noopener noreferrer"&gt;APIC&lt;/a&gt;, a free browser-based editor, around that constraint. This article documents how a &lt;strong&gt;privacy-first online image editor&lt;/strong&gt; is put together when nothing is uploaded, which trade-offs come with that design, and what users can reasonably expect from it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why "no upload" is an architecture decision, not a slogan
&lt;/h2&gt;

&lt;p&gt;Privacy claims are cheap. Architecture is harder to fake.&lt;/p&gt;

&lt;p&gt;When image processing happens on a server, privacy depends on policy: retention windows, access controls, and trust. When processing happens on the device, the image never leaves the browser tab, so there is nothing to retain and nothing to leak in transit.&lt;/p&gt;

&lt;p&gt;That changes a few things for anyone building or choosing an online photo editor:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Sensitive images stay local.&lt;/strong&gt; ID photos, product prototypes, client work, family pictures.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;There is no upload queue.&lt;/strong&gt; Speed depends on the user's hardware, not on server load.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Large files are no longer a bandwidth problem.&lt;/strong&gt; A 40 MB photo does not need to travel anywhere.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Offline use becomes possible.&lt;/strong&gt; After the first load, much of the tooling does not need a connection.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The cost is that the client has to do real work. The rest of this article is about how that work gets done.&lt;/p&gt;

&lt;h2&gt;
  
  
  The building blocks of a browser-based image editor
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Canvas for live editing
&lt;/h3&gt;

&lt;p&gt;Filters, brightness, contrast, saturation, blur, rotation, and flipping are all operations on pixel data, and the Canvas API handles them well. Because the work is local, sliders update the preview live with no round trip.&lt;/p&gt;

&lt;p&gt;For more demanding color work, the same approach scales up. APIC's advanced panel includes a live histogram with shadow and highlight clipping indicators, RGB curves, an 8-band HSL mixer, three-way color grading, clarity, and grain. It can also export a &lt;strong&gt;33×33×33 3D LUT as a &lt;code&gt;.cube&lt;/code&gt; file&lt;/strong&gt;, so a grade built in the browser can be reused in tools such as DaVinci Resolve, Premiere, or Photoshop.&lt;/p&gt;

&lt;p&gt;One honest limitation: spatial effects like clarity, sharpening, vignette, and grain are not purely color transforms, so they cannot be baked into a LUT. The export covers the color-only parts of the grade.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. WebAssembly for the heavy lifting
&lt;/h3&gt;

&lt;p&gt;JavaScript alone is not the right tool for neural-network inference on a full-resolution photo. WebAssembly gives near-native execution inside the browser sandbox, which is what makes on-device AI practical. Every AI feature below runs this way.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Model caching so the cost is paid once
&lt;/h3&gt;

&lt;p&gt;On-device AI has a real first-run cost: the model has to be downloaded. A well-behaved implementation downloads it once, caches it in the browser, and reuses it afterward.&lt;/p&gt;

&lt;p&gt;For background removal, APIC offers three tiers so users can match the model to their device:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tier&lt;/th&gt;
&lt;th&gt;First download&lt;/th&gt;
&lt;th&gt;Best for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Light&lt;/td&gt;
&lt;td&gt;about 5 MB&lt;/td&gt;
&lt;td&gt;Phones and quick cut-outs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fast&lt;/td&gt;
&lt;td&gt;about 44 MB&lt;/td&gt;
&lt;td&gt;Everyday use&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Maximum&lt;/td&gt;
&lt;td&gt;about 176 MB&lt;/td&gt;
&lt;td&gt;Highest accuracy, multi-pass, desktop-class hardware&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;After the first run, the model loads from cache, and nothing is sent to a server at any point. If a download fails, the app retries automatically and surfaces a retry button rather than failing silently.&lt;/p&gt;

&lt;h2&gt;
  
  
  On-device AI background removal
&lt;/h2&gt;

&lt;p&gt;Background removal is a segmentation problem: classify every pixel as subject or not, then turn that mask into transparency. Doing this locally means the full-resolution original stays in memory on the user's device.&lt;/p&gt;

&lt;p&gt;Two details matter for quality:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Edge refinement.&lt;/strong&gt; Raw masks tend to leave hard or jagged boundaries. A refinement pass smooths them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Color-fringe removal.&lt;/strong&gt; Pixels at the edge often carry color from the old background. Removing that spill is the difference between a cut-out that looks pasted on and one that looks natural.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For output, keep transparency by exporting to &lt;strong&gt;PNG or WebP&lt;/strong&gt;. JPEG has no alpha channel, so it will flatten the result.&lt;/p&gt;

&lt;h2&gt;
  
  
  Removing objects with on-device inpainting
&lt;/h2&gt;

&lt;p&gt;Object removal is a different problem from background removal. You paint over what you want gone, such as a stray person, a sign, or a blemish, and a model fills the region so it blends with its surroundings.&lt;/p&gt;

&lt;p&gt;APIC uses two engines, which illustrates a useful design pattern, graceful degradation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;MI-GAN&lt;/strong&gt; (about 28 MB) is lightweight enough to run on phones.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LaMa&lt;/strong&gt;, a large Fourier-convolution inpainting network (about 208 MB), gives the most accurate fills for big or complex areas, and is intended for desktop-class devices.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If a model cannot load, the tool steps down automatically: Ultra, then MI-GAN, then a quick patch fill. Only the area around the brush is processed, and the fill is color-matched and re-grained to match the original photo, which avoids the telltale "too clean" patch.&lt;/p&gt;

&lt;p&gt;A practical tip that applies to any inpainting tool: paint slightly outside the object, so shadows and reflections are covered too.&lt;/p&gt;

&lt;h2&gt;
  
  
  Compressing an image to an exact file size
&lt;/h2&gt;

&lt;p&gt;A common real-world task is hitting an upload limit: "under 200 KB" for a form, "under 1 MB" for a CMS. Guessing a quality slider is tedious.&lt;/p&gt;

&lt;p&gt;A better approach is to search across quality levels and keep the highest one that fits the target. APIC's &lt;strong&gt;compress image online&lt;/strong&gt; tool works this way. If the target is impossible at any quality, it reduces the dimensions as a fallback and reports the actual resulting size rather than pretending it hit the number.&lt;/p&gt;

&lt;h2&gt;
  
  
  Resizing without the muddy look
&lt;/h2&gt;

&lt;p&gt;A single large downscale is a classic source of soft, blurry results. Resampling in several half-size steps preserves more detail, and every pixel is recomputed at full quality. The tool leaves the image uncropped and unstretched unless you deliberately change the aspect ratio. You can specify exact pixels or a percentage, with an aspect-ratio lock.&lt;/p&gt;

&lt;h2&gt;
  
  
  Converting formats: PNG, JPG, WebP, BMP, ICO, PDF
&lt;/h2&gt;

&lt;p&gt;Format conversion is where most people start. The practical rules of thumb:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;PNG:&lt;/strong&gt; lossless, supports transparency. Best after background removal.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;JPEG:&lt;/strong&gt; small files, no transparency. Best for photos.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;WebP:&lt;/strong&gt; small files and transparency. A strong default for the web.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;BMP:&lt;/strong&gt; uncompressed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ICO:&lt;/strong&gt; app and favicon icons.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PDF:&lt;/strong&gt; a single-page document from an image.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All six conversions run locally, so converting a private document scan does not involve a third party.&lt;/p&gt;

&lt;h2&gt;
  
  
  Social media sizes without the guesswork
&lt;/h2&gt;

&lt;p&gt;Every platform has its own dimensions for profile pictures, banners, covers, posts, and stories, and they change. APIC's Social tab holds exact-size presets for 15 networks, including Instagram, YouTube, Facebook, X, TikTok, LinkedIn, Pinterest, Snapchat, Threads, Bluesky, Discord, Twitch, and Spotify.&lt;/p&gt;

&lt;p&gt;Two features make this more useful than a list of numbers: safe-zone guides that show where a platform crops or covers your image, and ZIP export so you can download every size for a network at once.&lt;/p&gt;

&lt;h2&gt;
  
  
  Batch processing and an offline desktop version
&lt;/h2&gt;

&lt;p&gt;Single-image tools only go so far. A batch studio takes many images through background removal, resizing, compression, and conversion in one pass and returns one ZIP, again processed entirely on the device.&lt;/p&gt;

&lt;p&gt;For people who want no browser involved at all, there is also a Windows desktop build that runs fully offline with the edit, convert, and compress tools.&lt;/p&gt;

&lt;h2&gt;
  
  
  A note on accounts and what data is involved
&lt;/h2&gt;

&lt;p&gt;Being specific here matters, because "no upload" can be misread. The editing tools work without an account. Signing in with Google is optional, and it uses your name, email, and photo for the account. The images themselves are not uploaded.&lt;br&gt;
We request you to signing in APIC even when it is optional because it will help us to send you guys update emails.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently asked questions
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What is a privacy-first online image editor?&lt;/strong&gt;&lt;br&gt;
It is an editor that processes images on your own device instead of sending them to a server. Editing, conversion, compression, resizing, and AI features all run in the browser.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can AI background removal run without uploading the photo?&lt;/strong&gt;&lt;br&gt;
Yes. A segmentation model can run in the browser through WebAssembly. The model downloads once, is cached, and processes the image locally.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is there a free online photo editor that keeps images on-device?&lt;/strong&gt;&lt;br&gt;
APIC is one. It is free, has no paid tiers, and runs its tools locally.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I compress an image to a specific size in KB?&lt;/strong&gt;&lt;br&gt;
Use a compressor that searches for the highest quality under your target size, such as the Compress tool in APIC.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Which format keeps a transparent background?&lt;/strong&gt;&lt;br&gt;
PNG and WebP. JPEG does not support transparency.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Does it work on phones?&lt;/strong&gt;&lt;br&gt;
Yes. Lighter model tiers exist specifically for phones, with heavier ones recommended for desktop hardware.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where to try it
&lt;/h2&gt;

&lt;p&gt;If you want to see these techniques in practice, &lt;a href="https://apic-studio.vercel.app/" rel="noopener noreferrer"&gt;APIC&lt;/a&gt; is a free online photo editor, background remover, and image converter that runs in your browser, with no uploads of your images.&lt;/p&gt;

&lt;p&gt;We are interested in how other engineers approach on-device processing. Which tasks have you moved from the server to the client, and what held you back? Share your experience in the comments.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;About Akhouri Systems: we build software with privacy and performance as design constraints. Follow &lt;a href="https://dev.to/akhouri-systems"&gt;our dev.to organization&lt;/a&gt; for more engineering write-ups.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;WE BUILD WHAT OTHERS FORGOT TO FIX&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>ai</category>
      <category>webdev</category>
      <category>webassembly</category>
    </item>
    <item>
      <title>ATLOCK v5, Inch by Inch: How a 10,000-Line Pure-Python Security Suite Actually Works</title>
      <dc:creator>Akhouri Anmol Kumar</dc:creator>
      <pubDate>Tue, 10 Nov 2026 05:22:17 +0000</pubDate>
      <link>https://dev.to/akhourianmolkumar/atlock-v5-inch-by-inch-how-a-10000-line-pure-python-security-suite-actually-works-4kb2</link>
      <guid>https://dev.to/akhourianmolkumar/atlock-v5-inch-by-inch-how-a-10000-line-pure-python-security-suite-actually-works-4kb2</guid>
      <description>&lt;p&gt;&lt;em&gt;From your first &lt;code&gt;print('Hello')&lt;/code&gt; to Argon2id, key commitment, rollback-proof state, Shamir secret sharing and ransomware decoys. Every idea explained, with the real code.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Who this post is for
&lt;/h2&gt;

&lt;p&gt;This post has two readers in mind.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reader A&lt;/strong&gt; just typed &lt;code&gt;print('Hello, world!')&lt;/code&gt; for the first time and is wondering what all the fuss about "cryptography" is.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reader B&lt;/strong&gt; writes code for a living and wants to know exactly how a serious, single-file security tool is put together: where the keys come from, what the file format looks like, and what happens when the power dies halfway through encrypting your only copy of a file.&lt;/p&gt;

&lt;p&gt;I wrote it so both can finish it. Part 0 is gentle. From Part 2 onward it gets deep. Everything below comes from the real source of &lt;strong&gt;ATLOCK v5&lt;/strong&gt;, an &lt;em&gt;Akhouri Systems&lt;/em&gt; product by Akhouri Anmol Kumar: one Python file, 10,011 lines, Windows-first.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Microsoft Store: &lt;a href="https://apps.microsoft.com/detail/9P08S539NTLF" rel="noopener noreferrer"&gt;https://apps.microsoft.com/detail/9P08S539NTLF&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Source repo: &lt;a href="https://github.com/Akhouri-Systems/ATLOCK" rel="noopener noreferrer"&gt;https://github.com/Akhouri-Systems/ATLOCK&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Part 0: The five-minute foundation
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Python in one paragraph
&lt;/h3&gt;

&lt;p&gt;Python is a programming language designed to read almost like English. This is a complete program:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Hello, world!'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is the same language ATLOCK is written in. The only difference is scale. Python is used to build websites (Django, Flask), analyse data, train AI models, automate boring office work, write games, and build desktop apps. It is also very good at security tooling, because the heavy lifting is done by fast libraries written in C and Rust while Python glues everything together.&lt;/p&gt;

&lt;p&gt;ATLOCK is a &lt;em&gt;desktop application with a graphical interface&lt;/em&gt; (built with &lt;code&gt;customtkinter&lt;/code&gt;) &lt;strong&gt;and&lt;/strong&gt; a command-line tool, all in one &lt;code&gt;.py&lt;/code&gt; file packed into (.exe) &amp;amp; Shipped as (.zip)&lt;/p&gt;

&lt;h3&gt;
  
  
  What is cryptography?
&lt;/h3&gt;

&lt;p&gt;Cryptography is the craft of making information useless to anyone who is not supposed to have it, and provably unaltered for those who are. Modern cryptography makes three promises:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Promise&lt;/th&gt;
&lt;th&gt;Plain English&lt;/th&gt;
&lt;th&gt;Real-world picture&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Confidentiality&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Outsiders cannot read it&lt;/td&gt;
&lt;td&gt;A locked box&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Integrity&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Nobody changed it without you noticing&lt;/td&gt;
&lt;td&gt;A wax seal on the box&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Authenticity&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;It really came from who it claims&lt;/td&gt;
&lt;td&gt;A signature&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Here is the smallest real example, using the same cipher ATLOCK uses (AES-256-GCM):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;cryptography&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hazmat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;primitives&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ciphers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;aead&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="no"&gt;AESGCM&lt;/span&gt;

&lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;AESGCM&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;generate_key&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bit_length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;256&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# 32 random bytes = the secret&lt;/span&gt;
&lt;span class="n"&gt;nonce&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;urandom&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;                      &lt;span class="c1"&gt;# a one-time number; never reuse with the same key&lt;/span&gt;
&lt;span class="n"&gt;box&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;AESGCM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;sealed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;box&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nonce&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="s1"&gt;'hello'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="s1"&gt;'label'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# b'label' = extra data that must match&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;box&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nonce&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sealed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="s1"&gt;'label'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;       &lt;span class="c1"&gt;# b'hello'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Flip a single bit of &lt;code&gt;sealed&lt;/code&gt; and &lt;code&gt;decrypt&lt;/code&gt; raises &lt;code&gt;InvalidTag&lt;/code&gt; instead of returning garbage. That is &lt;strong&gt;integrity&lt;/strong&gt; built into the cipher. Ciphers with this property are called &lt;strong&gt;AEAD&lt;/strong&gt; (Authenticated Encryption with Associated Data), and nearly every design decision in ATLOCK is about using AEAD correctly.&lt;/p&gt;

&lt;h3&gt;
  
  
  The vocabulary you need (and no more)
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Term&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;th&gt;Why it matters here&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Plaintext / ciphertext&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Readable data / scrambled data&lt;/td&gt;
&lt;td&gt;Your file before and after locking&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Key&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The secret number that locks and unlocks&lt;/td&gt;
&lt;td&gt;32 bytes for AES-256&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Salt&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Random bytes mixed into password hashing&lt;/td&gt;
&lt;td&gt;Stops attackers re-using precomputed tables&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Nonce&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;A number used once per encryption&lt;/td&gt;
&lt;td&gt;Re-using one with the same key breaks GCM&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Hash&lt;/strong&gt; (SHA-256)&lt;/td&gt;
&lt;td&gt;A one-way fingerprint of data&lt;/td&gt;
&lt;td&gt;Detect changes; cannot be reversed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;MAC / HMAC&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;A keyed fingerprint&lt;/td&gt;
&lt;td&gt;Proves someone with the key made it&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;KDF&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Turns a human password into a strong key, slowly on purpose&lt;/td&gt;
&lt;td&gt;Argon2id&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Signature&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Proof made with a private key, checked with a public key&lt;/td&gt;
&lt;td&gt;Ed25519&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;The golden rule: never invent your own cipher.&lt;/strong&gt; ATLOCK does not. It calls vetted primitives from the &lt;code&gt;cryptography&lt;/code&gt; and &lt;code&gt;argon2-cffi&lt;/code&gt; packages: AES-256-GCM, Argon2id, HKDF, HMAC-SHA256, X25519 and Ed25519. The original work is in &lt;em&gt;how they are assembled&lt;/em&gt;, and the rest of this post is about that assembly. (Two things are written by hand, because the specs are small and public: TOTP codes and Shamir secret sharing. We will look at both.)&lt;/p&gt;

&lt;h3&gt;
  
  
  What is a "security suite"?
&lt;/h3&gt;

&lt;p&gt;An antivirus does one job. A &lt;strong&gt;security suite&lt;/strong&gt; bundles many defensive tools behind one front door. ATLOCK's suite covers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;File Guard&lt;/strong&gt;: encrypt files and whole folders in place, with lockout rules.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vault&lt;/strong&gt;: a password manager with import from Bitwarden, Chrome, Firefox, KeePass and 1Password exports.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Security Guard&lt;/strong&gt;: a Windows Defender dashboard, VirusTotal scanning, a startup watchdog, ransomware decoy files, and a device-health check.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Intruder response&lt;/strong&gt;: photo/video capture and Telegram alerts after wrong attempts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Public-key tools&lt;/strong&gt;: encrypt a file &lt;em&gt;to&lt;/em&gt; a friend, sign files, verify releases.&lt;/li&gt;
&lt;li&gt;A big &lt;strong&gt;command line&lt;/strong&gt; (&lt;code&gt;--selftest&lt;/code&gt;, &lt;code&gt;--fuzz&lt;/code&gt;, &lt;code&gt;--shamir-split&lt;/code&gt;, &lt;code&gt;--pk-encrypt&lt;/code&gt; and about forty more flags).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;ATLOCK deliberately does &lt;em&gt;not&lt;/em&gt; reimplement an antivirus engine. Its own comment says it gives Defender's real engine and Windows' audit trails "a cockpit". Knowing what &lt;em&gt;not&lt;/em&gt; to build is a security skill too.&lt;/p&gt;




&lt;h2&gt;
  
  
  Part 1: ATLOCK from 30,000 feet
&lt;/h2&gt;

&lt;p&gt;The file is organised in lettered sections:-- &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Layer&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;th&gt;Key functions / classes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Bootstrap&lt;/td&gt;
&lt;td&gt;DLL-planting defence, crash tracing, dependency check&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;_atl_trace&lt;/code&gt;, &lt;code&gt;_atl_fatal&lt;/code&gt;, &lt;code&gt;check_dependencies&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Crypto core&lt;/td&gt;
&lt;td&gt;Password to key, chunked authenticated container&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;atlock_kdf&lt;/code&gt;, &lt;code&gt;atlock_seal_stream_key&lt;/code&gt;, &lt;code&gt;_v3_chunks&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Safe I/O&lt;/td&gt;
&lt;td&gt;Atomic writes, shred, crash-safe swap&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;atlock_atomic_write&lt;/code&gt;, &lt;code&gt;atlock_shred&lt;/code&gt;, &lt;code&gt;_swap_and_shred&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sealed state&lt;/td&gt;
&lt;td&gt;Encrypted, rollback-proof local database&lt;/td&gt;
&lt;td&gt;&lt;code&gt;SealedStore&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Lockout engine&lt;/td&gt;
&lt;td&gt;Backoff, hard locks, clock-tamper resistance&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;atl_lock_fail&lt;/code&gt;, &lt;code&gt;atl_eff_now&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Factors&lt;/td&gt;
&lt;td&gt;TOTP, FIDO2, Windows Hello, keyfile&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;atlock_totp_verify&lt;/code&gt;, &lt;code&gt;atl_bind_secret&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Recovery&lt;/td&gt;
&lt;td&gt;Recovery keys, codes, Shamir M-of-N&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;atl_shamir_split&lt;/code&gt;, &lt;code&gt;atl_shamir_combine&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Public-key mode&lt;/td&gt;
&lt;td&gt;X25519 encryption, Ed25519 signatures&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;atl_pk_encrypt_file&lt;/code&gt;, &lt;code&gt;atl_pk_sign_file&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Defence tools&lt;/td&gt;
&lt;td&gt;Canary, watchdog, Defender, intruder ops&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;RansomwareCanary&lt;/code&gt;, &lt;code&gt;StartupWatchdog&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;UI&lt;/td&gt;
&lt;td&gt;Panels built on customtkinter&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;FileGuardPanel&lt;/code&gt;, &lt;code&gt;VaultPanel&lt;/code&gt;, &lt;code&gt;ATLockApp&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Self-test&lt;/td&gt;
&lt;td&gt;Dozens of checks plus a fuzzer&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;atl_selftest&lt;/code&gt;, &lt;code&gt;atl_fuzz&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The design philosophy is visible in one sentence from the module docstring: &lt;em&gt;"the cryptographic, storage and anti-tamper core underneath has been rebuilt"&lt;/em&gt; while the UI stayed identical. In other words, v5 is a &lt;strong&gt;secure core transplant&lt;/strong&gt;, not a repaint.&lt;/p&gt;




&lt;h2&gt;
  
  
  Part 2: From password to key
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Why you cannot just hash a password
&lt;/h3&gt;

&lt;p&gt;Suppose your password is &lt;code&gt;sunshine42&lt;/code&gt;. You could run SHA-256 on it and use that as the AES key. This is a famous mistake. SHA-256 is &lt;em&gt;fast&lt;/em&gt;, and fast is the attacker's friend: a GPU can try billions of guesses per second.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;password-based KDF&lt;/strong&gt; is deliberately slow and, in the best designs, deliberately &lt;strong&gt;memory-hungry&lt;/strong&gt;, so that GPUs and custom chips lose their advantage. ATLOCK uses &lt;strong&gt;Argon2id&lt;/strong&gt;, the winner of the Password Hashing Competition and the current standard recommendation.&lt;/p&gt;

&lt;p&gt;The floor parameters in the source:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;_ATL_ARGON2&lt;/span&gt;        &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;time_cost&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;memory_cost&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;65536&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;parallelism&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hash_len&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;32&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# 64 MiB&lt;/span&gt;
&lt;span class="n"&gt;_ATL_ARGON2_STRONG&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;time_cost&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;memory_cost&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;131072&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;parallelism&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hash_len&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;32&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# 128 MiB (vault, recovery)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;atl_argon2_raw&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;secret&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;salt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;hash_secret_raw&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;secret&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;salt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;Type&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;ID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every guess costs an attacker 64 to 128 MiB of RAM and several passes over it. That is the whole point.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tuning to the machine
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;atl_benchmark_argon2()&lt;/code&gt; times one hash on your computer and scales the memory cost &lt;em&gt;up&lt;/em&gt; (never below the floor) until a single hash takes about 0.6 seconds, capped at a fraction of your RAM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;scale&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;4.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;target_seconds&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;dt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'memory_cost'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mem_cap&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;floor&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;scale&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A fast PC gets stronger protection automatically; a weak laptop never gets &lt;em&gt;less&lt;/em&gt; than the floor. The parameters used are written into each file's header, so the file can always be reopened later even if you buy a faster machine.&lt;/p&gt;

&lt;h3&gt;
  
  
  A header you cannot weaponise
&lt;/h3&gt;

&lt;p&gt;Here is a subtle attack. If the file header says how much memory Argon2 should use, an attacker can edit the header to demand 500 GB and freeze your computer, or demand almost nothing to weaken the key derivation. ATLOCK defends in both directions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="no"&gt;KDF_MAX&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;time_cost&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;memory_cost&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;524288&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;parallelism&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# ceilings for UNTRUSTED headers&lt;/span&gt;
&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;kp&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'memory_cost'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="no"&gt;KDF_MAX&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'memory_cost'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;AtlockDamaged&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'This container asks for more Argon2 work than ATLOCK ever produces...'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;kp&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'memory_cost'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_ATL_ARGON2&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'memory_cost'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;kp&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'memory_cost'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# and floors&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Ceiling&lt;/strong&gt; stops denial of service. &lt;strong&gt;Floor&lt;/strong&gt; stops downgrade. Treat every number read from an untrusted file as hostile; this is a recurring theme in ATLOCK.&lt;/p&gt;

&lt;h3&gt;
  
  
  One password, many independent keys (HKDF)
&lt;/h3&gt;

&lt;p&gt;Argon2 yields one 32-byte "master" secret. ATLOCK never uses that directly. It expands it with &lt;strong&gt;HKDF&lt;/strong&gt; using a different &lt;em&gt;label&lt;/em&gt; for every purpose:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;atlock_kdf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;secret&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;salt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;master&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;atl_argon2_raw&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;atl_secret_bytes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;secret&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;salt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;_ATL_ARGON2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="no"&gt;HKDF&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;algorithm&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;hashes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;SHA256&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;32&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;salt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;derive&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;master&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="s1"&gt;'atlock/file-enc/v3'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="s1"&gt;'atlock/file-verify/v3'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# (enc_key, verifier)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is called &lt;strong&gt;domain separation&lt;/strong&gt;. The encryption key and the verifier come from the same master but cannot be converted into each other. The same trick yields separate keys for the vault, recovery wrap, state MAC, audit log and TOTP seed wrap. If one key leaks, the others stay safe.&lt;/p&gt;

&lt;p&gt;One more detail that saves real users from real pain: &lt;code&gt;atl_secret_bytes&lt;/code&gt; runs the password through Unicode &lt;strong&gt;NFC normalisation&lt;/strong&gt;, so &lt;code&gt;é&lt;/code&gt; typed as one character or as &lt;code&gt;e&lt;/code&gt; + accent produces the same key on any keyboard.&lt;/p&gt;




&lt;h2&gt;
  
  
  Part 3: The container, byte by byte
&lt;/h2&gt;

&lt;p&gt;A locked file is not just "ciphertext". It is a structured &lt;strong&gt;container&lt;/strong&gt;. ATLOCK's current format is v3.1, with a fixed 114-byte header:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Bytes&lt;/th&gt;
&lt;th&gt;Field&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;magic &lt;code&gt;ATLOCK\x03\x01&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Identify the format version&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;16&lt;/td&gt;
&lt;td&gt;salt&lt;/td&gt;
&lt;td&gt;Random, for Argon2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;KDF params&lt;/td&gt;
&lt;td&gt;time (1) + parallelism (1) + memory KiB (4)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;chunk size&lt;/td&gt;
&lt;td&gt;Big-endian; default 8 MiB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;nonce base&lt;/td&gt;
&lt;td&gt;Random per seal&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;32&lt;/td&gt;
&lt;td&gt;key commitment&lt;/td&gt;
&lt;td&gt;Proves which key this file belongs to&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;plaintext length&lt;/td&gt;
&lt;td&gt;Detect truncation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;32&lt;/td&gt;
&lt;td&gt;header hash&lt;/td&gt;
&lt;td&gt;SHA-256 of everything above&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;After the header come the chunks: &lt;code&gt;chunk_len (4 bytes) | AES-GCM(chunk)&lt;/code&gt;, repeated.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why chunks?
&lt;/h3&gt;

&lt;p&gt;If you encrypted a 6 GB video in one piece you would need 6 GB of RAM and could not verify anything until the very end. Chunking (8 MiB each) means ATLOCK holds &lt;strong&gt;one chunk in memory at a time&lt;/strong&gt;, can show a progress bar, and can fail fast.&lt;/p&gt;

&lt;p&gt;But chunking creates new attacks. An adversary who cannot read your data could still &lt;strong&gt;reorder, drop, duplicate or truncate chunks&lt;/strong&gt;. Each chunk is individually valid, so a naive design would happily decrypt a scrambled file. ATLOCK's answer is to bind position into every chunk's &lt;em&gt;associated data&lt;/em&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;nonce&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;nonce_base&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;struct&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;gt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;idx&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;                      &lt;span class="c1"&gt;# unique per chunk&lt;/span&gt;
&lt;span class="n"&gt;aad&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;header_hash&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;struct&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;gt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;idx&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="s1"&gt;'\x01'&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;is_final&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="s1"&gt;'\x00'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;ct&lt;/span&gt;    &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;aes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nonce&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;aad&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now chunk 7 only authenticates as "chunk 7 of &lt;em&gt;this&lt;/em&gt; file". Swap two chunks, delete one, or chop the end off and the final-flag no longer matches: &lt;code&gt;InvalidTag&lt;/code&gt;. Because the header hash is inside every AAD, even editing the header invalidates every chunk.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key commitment: a subtle one
&lt;/h3&gt;

&lt;p&gt;AES-GCM has a quirky weakness: in rare, crafted situations one ciphertext can decrypt successfully under &lt;strong&gt;two different keys&lt;/strong&gt;. To be safe, ATLOCK stores a &lt;strong&gt;commitment&lt;/strong&gt; in the header, &lt;code&gt;HMAC-SHA256(enc_key, 'atlock-commit-v3')&lt;/code&gt;, and checks it &lt;em&gt;before releasing a single byte of plaintext&lt;/em&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;hmac&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;compare_digest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;_commit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;enc_key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'commitment'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;AtlockAuthError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Wrong password, or this file was made with a different key.'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two benefits: a wrong password is reported cleanly (not as scary "corruption"), and the key-commitment attack class is closed. Note &lt;code&gt;hmac.compare_digest&lt;/code&gt;: a &lt;strong&gt;constant-time&lt;/strong&gt; comparison, so timing differences cannot leak how many bytes matched.&lt;/p&gt;

&lt;h3&gt;
  
  
  v3.1: a fresh subkey for every seal
&lt;/h3&gt;

&lt;p&gt;GCM's one hard rule is &lt;em&gt;never repeat a (key, nonce) pair&lt;/em&gt;. ATLOCK re-seals working copies of files again and again. With a random 8-byte nonce base this would be &lt;em&gt;probably&lt;/em&gt; fine, but "probably" is not a cryptographic standard. So v3.1 derives a per-seal key:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_v3_subkey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;enc_key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nonce_base&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;hmac&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;enc_key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="s1"&gt;'atlock-chunk-v3.1|'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;nonce_base&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hashlib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sha256&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;digest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every seal encrypts under a brand-new subkey, so a nonce collision across seals cannot hurt.&lt;/p&gt;

&lt;h3&gt;
  
  
  Hiding the size: Padmé padding
&lt;/h3&gt;

&lt;p&gt;Even encrypted, a file's &lt;strong&gt;length&lt;/strong&gt; leaks information (a 3 KB file is probably not a movie). An optional setting pads containers to a &lt;em&gt;Padmé&lt;/em&gt; bucket, which hides the size with at most about 12% overhead, using random filler bytes that are checked on open so padding cannot be abused to smuggle data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;atl_padme&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;e&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bit_length&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bit_length&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;last&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;last&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;
    &lt;span class="n"&gt;mask&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;last&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;mask&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;~&lt;/span&gt;&lt;span class="n"&gt;mask&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three lines of bit twiddling replace "round to the nearest power of two" (which can double your size) with something far cheaper.&lt;/p&gt;




&lt;h2&gt;
  
  
  Part 4: Never lose a file: crash-safe encryption
&lt;/h2&gt;

&lt;p&gt;The scariest moment in any encryption tool is the instant it replaces your original. Power cut, antivirus lock, disk full: any of them could destroy the only copy. ATLOCK's in-place locking (&lt;code&gt;atlock_seal_file&lt;/code&gt;) is a careful little state machine:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Hash&lt;/strong&gt; the original (SHA-256) and remember its size and modification time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Encrypt to a temporary file&lt;/strong&gt; next to the original, then &lt;code&gt;fsync&lt;/code&gt; so it is really on disk.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Read it back from disk&lt;/strong&gt; and decrypt it while hashing. If the hash differs from step 1, abort. The original is untouched.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Check the original did not change&lt;/strong&gt; during encryption (size and &lt;code&gt;mtime_ns&lt;/code&gt;). If you edited it meanwhile, refuse rather than shred your newer edits.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Record the key info first.&lt;/strong&gt; The &lt;code&gt;on_ready&lt;/code&gt; callback writes the database record &lt;em&gt;before&lt;/em&gt; the swap, so there is never ciphertext without a record of how to open it. If the swap fails, &lt;code&gt;on_abort&lt;/code&gt; rolls the record back.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Swap atomically:&lt;/strong&gt; move the original aside to &lt;code&gt;.atlock_old&lt;/code&gt;, move the container into place.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Shred&lt;/strong&gt; the old plaintext.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The swap function's own comment states the invariant best: &lt;em&gt;"A crash between steps leaves BOTH files, never neither."&lt;/em&gt; On the next start, &lt;code&gt;atlock_recover_leftovers()&lt;/code&gt; finishes the job.&lt;/p&gt;

&lt;p&gt;The shredder is intentionally modest and honest:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;passes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;seek&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="s1"&gt;'\x00'&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="n"&gt;secrets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;token_bytes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# zero pass, then random pass&lt;/span&gt;
    &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;flush&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fileno&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'.'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;secrets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;token_hex&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;'.shred'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;               &lt;span class="c1"&gt;# scrub the file name too&lt;/span&gt;
&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It also &lt;strong&gt;refuses to overwrite through a symlink or Windows junction&lt;/strong&gt; (&lt;code&gt;atl_is_reparse&lt;/code&gt;): shredding "through" a link could destroy a file &lt;em&gt;outside&lt;/em&gt; the folder you chose. Even folder walking is careful, because &lt;code&gt;os.walk&lt;/code&gt; happily descends into junctions.&lt;/p&gt;

&lt;p&gt;And the honest caveat from the source: on SSDs, journaling and copy-on-write filesystems, overwriting cannot be guaranteed to destroy old blocks. &lt;em&gt;BitLocker full-disk encryption is the real fix&lt;/em&gt;, and ATLOCK's Device Health check tells you whether it is on.&lt;/p&gt;




&lt;h2&gt;
  
  
  Part 5: A database an attacker cannot rewind
&lt;/h2&gt;

&lt;p&gt;ATLOCK keeps settings, the vault, guard records, lockout counters and an audit log on disk. Everything lives in &lt;strong&gt;&lt;code&gt;SealedStore&lt;/code&gt;&lt;/strong&gt;, and its design answers a question most apps never ask: &lt;em&gt;what if the attacker doesn't break the encryption, but simply puts an old copy of the file back?&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Layer 1: encrypted and name-bound
&lt;/h3&gt;

&lt;p&gt;Each state file is AES-256-GCM encrypted, and the file's &lt;strong&gt;name is bound into the AAD&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="no"&gt;AESGCM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;derive&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'state-enc'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nonce&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="s1"&gt;'ATLOCK-STATE|'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So an attacker cannot rename &lt;code&gt;settings.atl&lt;/code&gt; over &lt;code&gt;vault.atl&lt;/code&gt;: authentication fails.&lt;/p&gt;

&lt;h3&gt;
  
  
  Layer 2: where does the key live?
&lt;/h3&gt;

&lt;p&gt;The state key is generated randomly and wrapped with &lt;strong&gt;Windows DPAPI&lt;/strong&gt;, which ties it to your Windows account. Optionally, a second secret held by the &lt;strong&gt;TPM&lt;/strong&gt; (the chip on your motherboard) is mixed in via &lt;code&gt;_hw_mix&lt;/code&gt;. If the TPM is later cleared, ATLOCK &lt;strong&gt;fails closed&lt;/strong&gt; instead of quietly falling back to weaker protection, and tells you exactly why. The source admits the limit plainly: DPAPI defends against another user account or a stolen disk, but not against other software already running &lt;em&gt;as you&lt;/em&gt;. That is precisely the gap the TPM option narrows.&lt;/p&gt;

&lt;h3&gt;
  
  
  Layer 3: the rollback problem
&lt;/h3&gt;

&lt;p&gt;Imagine you change your vault password because it leaked. An attacker who earlier copied your old &lt;code&gt;vault.atl&lt;/code&gt; can later put it back. Every file is validly encrypted, so the old master password works again. This is a &lt;strong&gt;rollback attack&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;ATLOCK's defence is a monotonic counter:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Every write stores &lt;code&gt;_ctr&lt;/code&gt; inside the encrypted payload and increments it.&lt;/li&gt;
&lt;li&gt;The latest counter per file is stored as an &lt;strong&gt;anchor&lt;/strong&gt; in &lt;em&gt;two independent places&lt;/em&gt;: a DPAPI-sealed &lt;code&gt;anchor.bin&lt;/code&gt; and a DPAPI-sealed &lt;strong&gt;registry value&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;On read, if the file's counter is lower than the anchor, it is a rollback.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;rolled_back&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ctr&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;rolled_back&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;ROLLBACK_FAILCLOSED&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;      &lt;span class="c1"&gt;# ('vault', 'guard', 'settings')&lt;/span&gt;
    &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_quarantine_locked&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;       &lt;span class="c1"&gt;# moved aside, NOT deleted&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="n"&gt;hard&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;lock&lt;/span&gt; &lt;span class="s1"&gt;'global'&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;default&lt;/span&gt;                      &lt;span class="c1"&gt;# never serve the stale copy&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The stale file is &lt;em&gt;quarantined&lt;/em&gt; (so a legitimate restore from backup is still possible via an explicit accept command) and the whole app gets a penalty lock. Deleting a sealed file that is &lt;em&gt;known to have existed&lt;/em&gt; also fails closed, and for the lockout record specifically, deletion triggers a hard lock rather than a convenient reset to "zero failed attempts". The pattern is: &lt;strong&gt;absence of evidence is treated as evidence of tampering.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Cross-process safety
&lt;/h3&gt;

&lt;p&gt;With a GUI, a background agent and a right-click handler all touching the same files, ATLOCK uses a cross-process lock (&lt;code&gt;_XProcRLock&lt;/code&gt;) and a single-instance guard (&lt;code&gt;atl_single_instance&lt;/code&gt;). Atomic writes (&lt;code&gt;atlock_atomic_write&lt;/code&gt;: write temp, &lt;code&gt;fsync&lt;/code&gt;, &lt;code&gt;os.replace&lt;/code&gt;) mean a crash mid-save leaves either the old or the new file, never half of each, and an &lt;code&gt;.atl.bak&lt;/code&gt; copy is kept as a fallback.&lt;/p&gt;




&lt;h2&gt;
  
  
  Part 6: Wrong guesses cost time, and time cannot be cheated
&lt;/h2&gt;

&lt;p&gt;Offline attacks against your files are limited by Argon2. But the &lt;strong&gt;app itself&lt;/strong&gt; can be attacked online (someone sitting at your PC typing guesses), so ATLOCK has a lockout engine with per-subsystem policies:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;#           free, hard_at, hours, delay_base, delay_cap&lt;/span&gt;
&lt;span class="no"&gt;LOCK_POLICIES&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s1"&gt;'vault'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;     &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;VAULT_LOCKOUT_TRIGGER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;LOCK_HOURS&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'file'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;      &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;MAX_FILE_ATTEMPTS&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;     &lt;span class="no"&gt;LOCK_HOURS&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'pin'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;       &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;MAX_FILE_ATTEMPTS&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;     &lt;span class="mi"&gt;24&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;        &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;120&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="c1"&gt;# tiny keyspace =&amp;gt; harsher&lt;/span&gt;
    &lt;span class="s1"&gt;'recovery'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;900&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'totp'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;      &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;120&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The defaults in the file are &lt;code&gt;MAX_FILE_ATTEMPTS = 3&lt;/code&gt;, &lt;code&gt;VAULT_LOCKOUT_TRIGGER = 4&lt;/code&gt; and &lt;code&gt;LOCK_HOURS = 10&lt;/code&gt;. Between free attempts and the hard lock, delay grows &lt;strong&gt;exponentially with random jitter&lt;/strong&gt; (&lt;code&gt;+0..25%&lt;/code&gt;, from &lt;code&gt;secrets.randbelow&lt;/code&gt;). Hard locks double with each repeat strike, capped at 336 hours (two weeks).&lt;/p&gt;

&lt;p&gt;Two design choices deserve applause:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Failures never decay.&lt;/strong&gt; The code comment explains: otherwise a patient attacker could try N guesses, wait, and repeat forever without reaching the hard lock. Only a real authenticated unlock clears the counter.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The clock cannot be used as a weapon.&lt;/strong&gt; The obvious attack on any timed lockout is: set the system clock backwards. ATLOCK defends with several mechanisms at once:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;atl_eff_now()&lt;/code&gt; returns &lt;code&gt;max(wall clock, highest wall time ever seen)&lt;/code&gt;, persisted sealed. Time can only move forward, and a backwards jump is recorded as tamper.&lt;/li&gt;
&lt;li&gt;Lock remaining time is computed as &lt;code&gt;max(remaining by wall clock, remaining by monotonic clock)&lt;/code&gt;. To shorten a wait, an attacker must defeat &lt;em&gt;both&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;A monotonic clock restarts at reboot, which would wrongly revive old locks. So ATLOCK stamps each record with the Windows &lt;strong&gt;boot ID&lt;/strong&gt; (read from the Prefetch &lt;code&gt;BootId&lt;/code&gt; registry counter, no admin rights needed) and only trusts monotonic values from the &lt;em&gt;same boot&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Finally, &lt;strong&gt;tamper tightens the rules&lt;/strong&gt;: if the store has flagged tampering, &lt;code&gt;hard_at&lt;/code&gt; drops by one, so the attacker gets fewer guesses.&lt;/p&gt;




&lt;h2&gt;
  
  
  Part 7: A tamper-evident diary
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;atl_audit&lt;/code&gt; appends events to a log in which every entry carries an HMAC of the previous entry plus its own content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'h'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;hmac&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;derive&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'audit-hmac'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prev&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sort_keys&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hashlib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sha256&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;hexdigest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a tiny cousin of a blockchain: edit, insert or delete any event in the middle and every later hash breaks. &lt;code&gt;--audit-verify&lt;/code&gt; walks the chain and reports the first broken event number. Callers pass masked data only; even a wrong password attempt is stored as &lt;code&gt;•••• (9 chars)&lt;/code&gt;, never the characters, never a hash.&lt;/p&gt;

&lt;p&gt;The same philosophy covers &lt;strong&gt;self-integrity&lt;/strong&gt;: ATLOCK hashes its own source file and compares it to a baseline stored sealed &lt;em&gt;and&lt;/em&gt; in the registry. And the file's docstring is candid: a same-user attacker can edit both, so this "raises the cost" and catches accidents and commodity malware, nothing more.&lt;/p&gt;




&lt;h2&gt;
  
  
  Part 8: Second factors, written from the RFC
&lt;/h2&gt;

&lt;h3&gt;
  
  
  TOTP (the 6-digit codes in your authenticator app)
&lt;/h3&gt;

&lt;p&gt;ATLOCK implements RFC 6238 in about fifteen lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_hotp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;secret&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;counter&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;digits&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;h&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;hmac&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;secret&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;struct&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;gt;Q'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;counter&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hashlib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sha1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;digest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;offset&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="mh"&gt;0x0F&lt;/span&gt;
    &lt;span class="n"&gt;code&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;struct&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;unpack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;gt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;offset&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;offset&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="mh"&gt;0x7FFFFFFF&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="n"&gt;digits&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;zfill&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;digits&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# counter = int(time.time() // 30)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(SHA-1 here is mandated by the spec for compatibility with Google Authenticator and friends; HMAC-SHA1 remains secure for this use.) It accepts one 30-second step either side for clock drift, compares in constant time, and keeps a set of &lt;strong&gt;used counters&lt;/strong&gt; so an intercepted code cannot be replayed inside its validity window. The built-in self-test verifies the official RFC vector: at T=59, 8 digits, the answer must be &lt;code&gt;94287082&lt;/code&gt;. &lt;strong&gt;Testing against published test vectors is how you know hand-written crypto-adjacent code is right.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  FIDO2 hardware keys and Windows Hello
&lt;/h3&gt;

&lt;p&gt;With the optional &lt;code&gt;fido2&lt;/code&gt; package, a YubiKey-style device can act as a second factor, with a 60-second timeout, a cancel dialog, and a cached result so one touch covers verify &lt;em&gt;and&lt;/em&gt; decrypt. Windows Hello (face, fingerprint, PIN) is reached through &lt;code&gt;winrt&lt;/code&gt;. Several &lt;strong&gt;auth policies&lt;/strong&gt; exist (&lt;code&gt;password&lt;/code&gt;, &lt;code&gt;password+hello&lt;/code&gt;, &lt;code&gt;password+totp&lt;/code&gt;, ...), and any second-factor failure &lt;strong&gt;fails closed&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  The extra lock that is part of the &lt;em&gt;key&lt;/em&gt;
&lt;/h3&gt;

&lt;p&gt;Most "2FA" is only a gate: the app checks your code, then opens the file. A gate can be bypassed by anyone who skips the app. ATLOCK's File Guard offers a &lt;strong&gt;keyfile&lt;/strong&gt; or &lt;strong&gt;hardware key&lt;/strong&gt; that is mixed into the cryptographic key itself:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;atl_bind_secret&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;secret&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;factor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;mac&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;hmac&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;factor&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="s1"&gt;'atlock-factor-bind-v1|'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;atl_secret_bytes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;secret&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hashlib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sha512&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;digest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;base64&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;urlsafe_b64encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mac&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'ascii'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;     &lt;span class="c1"&gt;# THIS is what is fed to Argon2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The keyfile's SHA-512 digest (or a FIDO2 &lt;code&gt;hmac-secret&lt;/code&gt; output) keys an HMAC over your password. The result goes into Argon2. Without the factor, a copied container is &lt;strong&gt;mathematically&lt;/strong&gt; unopenable even if the attacker knows your password. This is the difference between a lock on the door and a lock on the vault.&lt;/p&gt;




&lt;h2&gt;
  
  
  Part 9: Shamir's Secret Sharing: split a key so no single paper matters
&lt;/h2&gt;

&lt;p&gt;Your recovery key on one sheet of paper is a single point of failure: lose it and you are locked out, leak it and you are open. &lt;strong&gt;Shamir's Secret Sharing&lt;/strong&gt; splits a secret into &lt;em&gt;N&lt;/em&gt; shares so that any &lt;em&gt;K&lt;/em&gt; of them rebuild it, while &lt;em&gt;K-1&lt;/em&gt; shares reveal &lt;strong&gt;nothing&lt;/strong&gt; (not "little", literally nothing).&lt;/p&gt;

&lt;p&gt;The idea is school algebra. A line is fixed by two points; a parabola by three. Hide the secret as the intercept of a random polynomial of degree K-1, hand out points on it. ATLOCK works byte-by-byte over the finite field &lt;strong&gt;GF(256)&lt;/strong&gt;, the same field AES uses, with the same reduction polynomial &lt;code&gt;0x11B&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# build log/exp tables once, using generator 3&lt;/span&gt;
&lt;span class="n"&gt;x2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;x2&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="mh"&gt;0x100&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;x2&lt;/span&gt; &lt;span class="o"&gt;^=&lt;/span&gt; &lt;span class="mh"&gt;0x11B&lt;/span&gt;
&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x2&lt;/span&gt; &lt;span class="o"&gt;^&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;

&lt;span class="c1"&gt;# share for point x:   evaluate each byte's polynomial with Horner's rule&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;reversed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;coeffs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;_gf_mul&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;^&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Recombination is Lagrange interpolation at zero, again in GF(256). Look at how carefully the shares are built:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Each share looks like &lt;code&gt;ATLS2-3OF5-02-A1B2C3-&amp;lt;base32 data&amp;gt;-&amp;lt;CRC16&amp;gt;&lt;/code&gt;: human-friendly Base32, and a &lt;strong&gt;CRC-16&lt;/strong&gt; that catches a typo and says &lt;em&gt;which&lt;/em&gt; share has the typo.&lt;/li&gt;
&lt;li&gt;A random &lt;strong&gt;set ID&lt;/strong&gt; prevents mixing shares from different splits.&lt;/li&gt;
&lt;li&gt;A 4-byte integrity tag is appended &lt;strong&gt;to the secret before splitting&lt;/strong&gt;, so it is shared too. The source records &lt;em&gt;why&lt;/em&gt;: the older ATLS1 format stored a hash of the secret in every share, which leaked 24 bits to anyone holding shares. The fix is documented in a comment, which is exactly how mature security code should evolve.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The CLI exposes it as &lt;code&gt;--shamir-split&lt;/code&gt; and &lt;code&gt;--shamir-join&lt;/code&gt;, and the garbage-in path is fuzz-tested.&lt;/p&gt;




&lt;h2&gt;
  
  
  Part 10: Public-key mode: encrypt to someone who is not in the room
&lt;/h2&gt;

&lt;p&gt;Passwords need both people to share a secret first. &lt;strong&gt;Public-key cryptography&lt;/strong&gt; removes that: you publish a &lt;em&gt;public&lt;/em&gt; key, keep a &lt;em&gt;private&lt;/em&gt; key, and anyone can encrypt to you, but only you can decrypt. ATLOCK's identity is &lt;strong&gt;two keypairs&lt;/strong&gt;: &lt;strong&gt;X25519&lt;/strong&gt; (for receiving) and &lt;strong&gt;Ed25519&lt;/strong&gt; (for signing). The private halves are stored in &lt;code&gt;identity.atlkey&lt;/code&gt;, wrapped with Argon2id (the strong profile) and AES-GCM under your passphrase. Your shareable key looks like &lt;code&gt;ATLPUB1:...&lt;/code&gt; with a built-in checksum and a short fingerprint you can read aloud over the phone.&lt;/p&gt;

&lt;h3&gt;
  
  
  Encrypting to a public key (the ECIES pattern)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;eph&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x25519&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;X25519PrivateKey&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;generate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;                 &lt;span class="c1"&gt;# throw-away key, one per file&lt;/span&gt;
&lt;span class="n"&gt;shared&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;eph&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exchange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;recipient_public_x25519&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;           &lt;span class="c1"&gt;# Diffie-Hellman&lt;/span&gt;
&lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;HKDF&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;SHA256&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;32&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;salt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;eph_pub&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;recip_x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="s1"&gt;'atlock-pk-v1'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;derive&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;shared&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# then reuse the SAME chunked container as for passwords:&lt;/span&gt;
&lt;span class="nf"&gt;atlock_seal_stream_key&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fout&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The sender and recipient both arrive at the same &lt;code&gt;shared&lt;/code&gt; secret without ever sending it. A &lt;em&gt;fresh ephemeral key per file&lt;/em&gt; means that compromising one file doesn't expose others. And notice the &lt;strong&gt;reuse&lt;/strong&gt;: the public-key mode doesn't invent a new file format. It derives a key a different way and feeds the same battle-tested container.&lt;/p&gt;

&lt;h3&gt;
  
  
  Signing, and the "pinned sender" policy
&lt;/h3&gt;

&lt;p&gt;If you pass &lt;code&gt;--sign&lt;/code&gt;, an Ed25519 signature over the file is embedded. On decrypt you can &lt;strong&gt;pin&lt;/strong&gt; the sender's key. This is a &lt;em&gt;policy&lt;/em&gt;, and it fails closed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;expected_sender_pub&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;signed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;AtlockSenderMismatch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'...Nothing was decrypted.'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;signed&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;matches&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;            &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;AtlockSenderMismatch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'SENDER MISMATCH...Nothing was decrypted.'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The check happens &lt;strong&gt;before any plaintext is produced&lt;/strong&gt;. Standalone &lt;code&gt;--sign FILE&lt;/code&gt; writes a &lt;code&gt;.atlsig&lt;/code&gt; JSON file; &lt;code&gt;--check-sig&lt;/code&gt; verifies it, and distinguishes "mathematically valid but a &lt;em&gt;different&lt;/em&gt; key than you expected" from "invalid". That nuance matters: a valid signature from the wrong person is still an attack.&lt;/p&gt;

&lt;h3&gt;
  
  
  Verifying ATLOCK itself
&lt;/h3&gt;

&lt;p&gt;A security tool you cannot verify is a liability. &lt;code&gt;--verify-self&lt;/code&gt; hashes the script (with the one line that holds the publisher's public key blanked, so the key can be embedded without changing what is signed) and checks an Ed25519 signature against a &lt;strong&gt;pinned publisher key&lt;/strong&gt;. If the signature is valid but the key is not the one you trust, it says so and refuses to claim verification. That is how you stop a perfectly signed malicious copy.&lt;/p&gt;




&lt;h2&gt;
  
  
  Part 11: Passwords, honestly
&lt;/h2&gt;

&lt;p&gt;All that Argon2 cost is wasted if your password is &lt;code&gt;Anmol@123&lt;/code&gt;. So ATLOCK includes its own &lt;strong&gt;pattern-aware strength estimator&lt;/strong&gt; (&lt;code&gt;atlock_password_strength&lt;/code&gt;) instead of the usual "one uppercase, one symbol" rules, which famously rate &lt;code&gt;Passw0rd!&lt;/code&gt; as strong.&lt;/p&gt;

&lt;p&gt;It solves the password as a &lt;strong&gt;minimum-cost decomposition&lt;/strong&gt; (dynamic programming): the cheapest way an attacker's guesser could &lt;em&gt;produce&lt;/em&gt; your string from known building blocks.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;dictionary words, names and leaked passwords, with case and leet-speak (&lt;code&gt;p4ssw0rd&lt;/code&gt;) surcharges,&lt;/li&gt;
&lt;li&gt;sequences (&lt;code&gt;abc&lt;/code&gt;, &lt;code&gt;4321&lt;/code&gt;), repeats (&lt;code&gt;aaaa&lt;/code&gt;, &lt;code&gt;abcabc&lt;/code&gt;), keyboard walks (&lt;code&gt;qwerty&lt;/code&gt;), years and dates,&lt;/li&gt;
&lt;li&gt;pronounceable "text" that Markov guessers rank early,&lt;/li&gt;
&lt;li&gt;and only then, plain brute-force characters.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The score is in &lt;strong&gt;bits of entropy&lt;/strong&gt;, and policy is explicit: file passwords need about 40 bits (&lt;code&gt;MIN_FILE_BITS&lt;/code&gt;), vault master and backup passwords 50 (&lt;code&gt;MIN_VAULT_BITS&lt;/code&gt;). The built-in generator (&lt;code&gt;--gen-passphrase&lt;/code&gt;) draws words from a bundled 2,048-word list using &lt;code&gt;secrets.choice&lt;/code&gt;: &lt;strong&gt;11 bits per word&lt;/strong&gt;, so 5 words give 55 bits and remain typeable by a human.&lt;/p&gt;

&lt;p&gt;Optionally it also checks the &lt;strong&gt;Have I Been Pwned&lt;/strong&gt; database using &lt;strong&gt;k-anonymity&lt;/strong&gt;: only the first 5 hex characters of the password's SHA-1 ever leave your machine; the service returns every suffix in that bucket and the comparison happens locally. You learn if the password is breached without telling anyone what it is.&lt;/p&gt;




&lt;h2&gt;
  
  
  Part 12: The defence tools
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Ransomware canaries
&lt;/h3&gt;

&lt;p&gt;Ransomware encrypts every file it can reach, including files you never open. &lt;code&gt;RansomwareCanary&lt;/code&gt; exploits that. It plants &lt;strong&gt;decoy files&lt;/strong&gt; with random realistic names across Desktop, Documents, Pictures and Downloads, each holding a unique hidden token, and records their SHA-256. A thread polls every 4 seconds. One edited decoy could be you; the alert fires only when &lt;strong&gt;two different decoys&lt;/strong&gt; change inside a 20-second window. Tripped decoys are re-armed with new random names. Cheap, low-noise, and effective against a class of malware that antivirus signatures may not recognise yet.&lt;/p&gt;

&lt;h3&gt;
  
  
  Startup watchdog
&lt;/h3&gt;

&lt;p&gt;Malware needs to survive reboot. &lt;code&gt;StartupWatchdog&lt;/code&gt; baselines every classic persistence location, then reports only what is &lt;strong&gt;new&lt;/strong&gt;: Registry Run/RunOnce (user and machine), Startup folders, auto-start services, scheduled tasks, &lt;code&gt;AppInit_DLLs&lt;/code&gt;, Image File Execution Options debugger hijacks, and Winlogon Shell/Userinit, with SHA-256 and Authenticode signature status where reachable.&lt;/p&gt;

&lt;h3&gt;
  
  
  Intruder response
&lt;/h3&gt;

&lt;p&gt;A wrong attempt can trigger a sound, a camera photo, and, at critical level, a short video plus a &lt;strong&gt;Telegram&lt;/strong&gt; alert (uploads capped at 49 MB to respect Telegram's limit, with captured media then encrypted). There is also a &lt;em&gt;silent duress&lt;/em&gt; path: no alarm sound, so the intruder isn't warned.&lt;/p&gt;

&lt;h3&gt;
  
  
  Hardening the process itself
&lt;/h3&gt;

&lt;p&gt;At the very top of the file, before almost any import, ATLOCK calls &lt;code&gt;SetDllDirectoryW('')&lt;/code&gt; and &lt;code&gt;SetDefaultDllDirectories&lt;/code&gt; to defeat &lt;strong&gt;DLL planting&lt;/strong&gt; (where malware drops a fake DLL next to the program). Later it enables heap-corruption termination and an image-load mitigation policy, and &lt;code&gt;atl_debugger_present()&lt;/code&gt; checks four independent debugger indicators. Secrets can sit in a &lt;code&gt;SecureBuffer&lt;/code&gt;: memory locked with &lt;code&gt;VirtualLock&lt;/code&gt; (not swapped to disk) and zeroed with &lt;code&gt;RtlSecureZeroMemory&lt;/code&gt;. The docstring is again honest: Python may already have copied your password; this is best-effort.&lt;/p&gt;

&lt;h3&gt;
  
  
  Defensive parsing
&lt;/h3&gt;

&lt;p&gt;Folders are locked using a custom streaming format (&lt;strong&gt;AFA1&lt;/strong&gt;): a sequence of records, each file followed by its SHA-256, ending in a manifest, so a 100 GB folder never needs 100 GB of RAM. Opening archives is guarded against &lt;strong&gt;zip bombs&lt;/strong&gt; (a compression ratio cap of 300, a 200,000-entry cap, an 8 GiB cap) and &lt;strong&gt;path traversal&lt;/strong&gt; (&lt;code&gt;_atl_zip_safe_name&lt;/code&gt;). A malicious archive should be rejected before it can hurt you.&lt;/p&gt;




&lt;h2&gt;
  
  
  Part 13: How you know it works: self-test and fuzzing
&lt;/h2&gt;

&lt;p&gt;The most convincing part of ATLOCK is that it ships its own proof. &lt;code&gt;--selftest&lt;/code&gt; runs dozens of checks: round-trip encryption, &lt;strong&gt;wrong key rejected before any plaintext&lt;/strong&gt;, &lt;strong&gt;chunk tampering detected&lt;/strong&gt;, the RFC TOTP vector, recovery-key round trip, DPAPI round trip, zip-slip rejection, and more.&lt;/p&gt;

&lt;p&gt;Then there is &lt;code&gt;--fuzz&lt;/code&gt;. &lt;strong&gt;Fuzzing&lt;/strong&gt; means attacking your own parser with random garbage to see if it ever crashes or, worse, silently returns wrong data:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;kind&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;rnd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;choice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'flip'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'flips'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'trunc'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'extend'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'zero'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'chunkdup'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'swap'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'header'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;atlock_open_stream_key&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;io&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;BytesIO&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mutated&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getvalue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;bad&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'SILENT CORRUPTION'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nc"&gt;AtlockError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;pass&lt;/span&gt;                   &lt;span class="c1"&gt;# clean, expected rejection&lt;/span&gt;
&lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;bad&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;     &lt;span class="c1"&gt;# anything else is a bug&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The rule it enforces is the heart of authenticated encryption: &lt;strong&gt;every mutated container must either decrypt to exactly the original or fail with a clean &lt;code&gt;AtlockError&lt;/code&gt;&lt;/strong&gt;. A crash is a bug; silent corruption would be a vulnerability. The same harness feeds garbage Shamir shares and junk password-manager exports to their parsers, and the RNG is seeded, so any failure is reproducible.&lt;/p&gt;




&lt;h2&gt;
  
  
  What ATLOCK does &lt;em&gt;not&lt;/em&gt; claim (and why that is a strength)
&lt;/h2&gt;

&lt;p&gt;The top of the source lists limits plainly. In my words:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A same-user attacker who can run code as you can modify the script and read process memory.&lt;/li&gt;
&lt;li&gt;Python strings are immutable and copied freely, so wiping secrets from RAM is best-effort.&lt;/li&gt;
&lt;li&gt;Secure deletion on SSDs and snapshotted filesystems cannot be guaranteed; use BitLocker.&lt;/li&gt;
&lt;li&gt;A determined attacker who can reboot, roll the clock back &lt;strong&gt;and&lt;/strong&gt; delete every anchor could still reset a counter. The real defence against offline guessing is Argon2id plus a strong password.&lt;/li&gt;
&lt;li&gt;Nothing is code-signed and there is no kernel driver; it is application-layer.&lt;/li&gt;
&lt;li&gt;Quick Lock is an application-level gate, &lt;strong&gt;not&lt;/strong&gt; password-strength cryptography. For that, use File Guard with a password.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  What you can steal for your own projects
&lt;/h2&gt;

&lt;p&gt;Even if you never run ATLOCK, these patterns generalise:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Derive, don't reuse&lt;/strong&gt;: one master secret, many HKDF-labelled subkeys.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bind context into AAD&lt;/strong&gt;: file name, chunk index, final flag, header hash.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Validate before you decrypt&lt;/strong&gt;: commitments and size ceilings first.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Verify before you destroy&lt;/strong&gt;: read the new file back from disk before touching the original.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fail closed&lt;/strong&gt;: missing or stale state is a signal, not a default.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Treat time as hostile&lt;/strong&gt;: monotonic clock, highest-seen wall clock, boot ID.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test with vectors and fuzz&lt;/strong&gt;: RFC vectors for known answers, mutations for unknown ones.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Write your limits down&lt;/strong&gt;: your users deserve to know them.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Try it yourself in ten lines
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# pip install cryptography argon2-cffi&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;argon2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;low_level&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;hash_secret_raw&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Type&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;cryptography&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hazmat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;primitives&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ciphers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;aead&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="no"&gt;AESGCM&lt;/span&gt;

&lt;span class="n"&gt;salt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;urandom&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;hash_secret_raw&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="s1"&gt;'correct horse battery staple'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;salt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;time_cost&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                      &lt;span class="n"&gt;memory_cost&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;65536&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;parallelism&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hash_len&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;32&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;Type&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;ID&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;nonce&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;urandom&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;blob&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;salt&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;nonce&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="no"&gt;AESGCM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nonce&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="s1"&gt;'my first secret'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="s1"&gt;'v1'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# later: same password + the salt stored at the front of the blob&lt;/span&gt;
&lt;span class="n"&gt;key2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;hash_secret_raw&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="s1"&gt;'correct horse battery staple'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;blob&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;time_cost&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                       &lt;span class="n"&gt;memory_cost&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;65536&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;parallelism&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hash_len&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;32&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;Type&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;ID&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;AESGCM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;blob&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;28&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;blob&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;28&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="s1"&gt;'v1'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# b'my first secret'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is a toy: one chunk, no commitment, no crash safety, no lockout. Now you know exactly what ATLOCK adds on top of it, and why each piece exists.&lt;/p&gt;




&lt;h2&gt;
  
  
  Get ATLOCK
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Microsoft Store:&lt;/strong&gt; &lt;a href="https://apps.microsoft.com/detail/9P08S539NTLF" rel="noopener noreferrer"&gt;https://apps.microsoft.com/detail/9P08S539NTLF&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;(GitHub):&lt;/strong&gt; &lt;a href="https://github.com/Akhouri-Systems/ATLOCK" rel="noopener noreferrer"&gt;https://github.com/Akhouri-Systems/ATLOCK&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>python</category>
      <category>security</category>
      <category>cryptography</category>
      <category>beginners</category>
    </item>
    <item>
      <title>I'm 13 and Built a Private, On-Device Photo Editor: APIC vs Canva, Adobe Express, Photopea &amp; remove.bg</title>
      <dc:creator>Akhouri Anmol Kumar</dc:creator>
      <pubDate>Sun, 08 Nov 2026 11:57:11 +0000</pubDate>
      <link>https://dev.to/akhourianmolkumar/im-13-and-built-a-private-on-device-photo-editor-apic-vs-canva-adobe-express-photopea--5h89</link>
      <guid>https://dev.to/akhourianmolkumar/im-13-and-built-a-private-on-device-photo-editor-apic-vs-canva-adobe-express-photopea--5h89</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;I'm 13, I built APIC, and I tried hard to keep this comparison honest, so you will see where APIC loses.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The 30-second version
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;APIC&lt;/strong&gt; is a free online photo editor, background remover, image converter and compressor that runs &lt;strong&gt;entirely in your browser&lt;/strong&gt;. Your photos are processed on your own device, and the AI runs there too. No upload queue, no server, no credits.&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;Try it:&lt;/strong&gt; &lt;a href="https://apic-studio.vercel.app/" rel="noopener noreferrer"&gt;APIC-STUDIO&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before the "giants" get nervous: I'm not trying to replace Canva, Adobe Express, Photopea or remove.bg. They are great, and they have teams. I built APIC for one very specific question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;"What if the editing tools I use every day didn't need to see my photos at all?"&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This post covers:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What APIC does&lt;/li&gt;
&lt;li&gt;How it works technically (ONNX Runtime Web, model tiers, one HTML file)&lt;/li&gt;
&lt;li&gt;A fair "battle" against four well-known tools&lt;/li&gt;
&lt;li&gt;What APIC is bad at (important!)&lt;/li&gt;
&lt;li&gt;What I'd love feedback on&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  What APIC does
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Edit&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Filters, brightness, contrast, saturation, blur, rotate/flip, plus a "pro colour suite": live histogram, RGB curves, 8-band HSL mixer, 3-way colour grading, sharpen/clarity, vignette, grain, crop, and a downloadable &lt;code&gt;.cube&lt;/code&gt; LUT&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Remove BG&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;On-device AI cut-out with three quality tiers (more on this below)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Remove Object&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Paint over something and an inpainting model fills it in&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;AI upscale&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Real-ESRGAN based upscaling (2x/4x)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Resize&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Pixels or percent, aspect lock, stepwise resampling&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Convert&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;PNG, JPEG, WebP, BMP, ICO and PDF&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Compress&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Searches for the best quality that fits a &lt;strong&gt;target file size&lt;/strong&gt; (e.g. "under 200 KB")&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Social&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Exact-size presets for 15 networks (61 sizes) with safe-zone guides&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Batch studio&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Remove BG, resize, compress and convert many images and download a ZIP&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Design Studio&lt;/strong&gt; &lt;em&gt;(new)&lt;/em&gt;
&lt;/td&gt;
&lt;td&gt;Template-based graphics with real typography controls, contrast/overflow checks and multi-size export&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Editing works without an account. &lt;strong&gt;Exporting needs a Google sign-in&lt;/strong&gt; (more on that in the honest section).&lt;/p&gt;




&lt;h2&gt;
  
  
  How it works (the technical part)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. One file, no backend
&lt;/h3&gt;

&lt;p&gt;APIC is a static page hosted on GitHub Pages. There is no server of mine that receives your images, because there is no server-side image pipeline at all. That is the whole privacy model: you cannot leak what you never receive.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. AI in the browser with ONNX Runtime Web
&lt;/h3&gt;

&lt;p&gt;The AI tools run models through &lt;a href="https://onnxruntime.ai/" rel="noopener noreferrer"&gt;ONNX Runtime Web&lt;/a&gt;, using WebAssembly (and WebGPU where the browser supports it). The models are downloaded to your browser on first use and cached, so the very first AI run is slower than the next ones.&lt;/p&gt;

&lt;p&gt;Background removal has three tiers so a phone and a gaming PC both get something that works:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tier&lt;/th&gt;
&lt;th&gt;Model size&lt;/th&gt;
&lt;th&gt;Meant for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Light&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;~5 MB&lt;/td&gt;
&lt;td&gt;Phones and slow connections&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Fast&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;~44 MB&lt;/td&gt;
&lt;td&gt;Most laptops&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Maximum&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;~176 MB&lt;/td&gt;
&lt;td&gt;Desktops, best edge detail&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Object removal offers a lighter model (~28 MB) and a heavy "Ultra" model (~208 MB), and upscaling has a 5 MB and a 64 MB option.&lt;/p&gt;

&lt;p&gt;A simplified version of the pattern (this is an illustration, not APIC's exact code):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;ort&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"onnxruntime-web"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Everything below runs on the user's device.&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;ort&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;InferenceSession&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;modelUrl&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;executionProviders&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"webgpu"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"wasm"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// fastest available wins&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;input&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;ort&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Tensor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"float32"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pixels&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1024&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1024&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;output&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;input&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// ...turn the mask into alpha, refine the edges, draw to a &amp;lt;canvas&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Better edges than "just apply the mask"
&lt;/h3&gt;

&lt;p&gt;A raw segmentation mask gives you a cut-out with a visible halo. APIC runs an edge-refinement step based on &lt;strong&gt;Blur-Fusion foreground estimation&lt;/strong&gt; (the same idea used by larger models) which aims to stop hair and soft edges from carrying the old background colour.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. The "fit this file size" compressor
&lt;/h3&gt;

&lt;p&gt;Instead of a quality slider that you guess at, Compress does a &lt;strong&gt;binary search over quality&lt;/strong&gt; and encodes repeatedly until the output is as large as possible while still under your target size. Same idea for the Design Studio's "fit under limit" export.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. What "private" means here (and what it does not)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;✅ Your &lt;strong&gt;images&lt;/strong&gt; are processed locally and are not uploaded.&lt;/li&gt;
&lt;li&gt;⚠️ The &lt;strong&gt;AI model files&lt;/strong&gt; are downloaded from public hosts (for example Hugging Face and jsDelivr). Downloading a model is not uploading your photo, but it is network traffic, and I want to be clear about it.&lt;/li&gt;
&lt;li&gt;⚠️ If you &lt;strong&gt;sign in&lt;/strong&gt;, Google Sign-In/Firebase receive your name, email and profile photo for the account. That is described in the Privacy page.&lt;/li&gt;
&lt;li&gt;⚠️ The site shows one small banner ad to cover running costs.(Lol 😂 till now 0 $ revenue bruh)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I'd rather you hear the limits from me than discover them yourself.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Battle: APIC vs 4 giants
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Facts below come from each tool's own pages where I could read them (linked at the bottom) and were checked in November 2026. Pricing and limits change, so please verify before you decide.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Round 1: Where do my photos go?
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Short answer&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;APIC&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Edited on your device; images are not uploaded&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Photopea&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Its privacy page says files "never leave your device" and are processed by your own hardware&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Canva&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Cloud editor; your designs live in your account&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Adobe Express&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Cloud editor; your work lives in your Adobe account (its free plan lists 5 GB storage)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;remove.bg&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Built around cloud processing of the image you send it&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; a tie between &lt;strong&gt;APIC and Photopea&lt;/strong&gt; for local processing. The cloud tools trade privacy for convenience, collaboration and sync, which is a fair trade for a lot of people.&lt;/p&gt;

&lt;h3&gt;
  
  
  Round 2: Price of the thing I actually need
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Background removal&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;APIC&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Free, no credits, no paid tier&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;remove.bg&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Its help page says free for low-resolution images up to &lt;strong&gt;0.25 megapixels&lt;/strong&gt;; higher resolutions (up to 50 MP) and commercial use need paid options&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Canva&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Third-party plan summaries list Background Remover and Magic Resize as &lt;strong&gt;paid-only&lt;/strong&gt;. Check Canva's pricing page for the current picture&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Adobe Express&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Free plan is £0; Premium is listed at &lt;strong&gt;£9.98/month&lt;/strong&gt; (UK page) with a 30-day trial, and Adobe's FAQ lists remove background among premium editing features&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Photopea&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Free to use, with an optional paid Premium plan&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; APIC wins on &lt;em&gt;price for this one job&lt;/em&gt;. That is not the same as "better quality than a funded cloud service", which I cannot claim.&lt;/p&gt;

&lt;h3&gt;
  
  
  Round 3: Design &amp;amp; templates (where APIC is the underdog)
&lt;/h3&gt;

&lt;p&gt;Adobe's own pricing page lists &lt;strong&gt;100,000+ to 268,000+ templates&lt;/strong&gt; and &lt;strong&gt;4,000+ fonts&lt;/strong&gt; on the &lt;em&gt;free&lt;/em&gt; plan. APIC's Design Studio has &lt;strong&gt;35 original templates&lt;/strong&gt; and &lt;strong&gt;9 open-licence font families&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; Canva and Adobe Express win by a mile. If you need a huge template library, stock photos, brand kits or team collaboration, use them. APIC's Design Studio is for quick, private, offline-capable graphics with real typography controls and checks.&lt;/p&gt;

&lt;h3&gt;
  
  
  Round 4: Power editing (layers, PSD, plugins)
&lt;/h3&gt;

&lt;p&gt;Photopea is a full Photoshop-style editor with a deep feature set. APIC is not. APIC's edge is a &lt;strong&gt;focused toolbox&lt;/strong&gt; (cut-out, object removal, resize, convert, compress, batch) that opens fast and does one job per tab.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; Photopea wins on depth. APIC wins on "I need this one thing in 10 seconds".&lt;/p&gt;

&lt;h3&gt;
  
  
  Round 5: Bulk and utility work
&lt;/h3&gt;

&lt;p&gt;Converting 40 images to WebP under 200 KB each, or exporting one design in 61 social sizes as a ZIP, is where APIC's Compress, Convert, Batch and Social tabs are made to shine. The giants focus on design (Canva, Adobe Express), full editing (Photopea) or one task (remove.bg).&lt;/p&gt;

&lt;h3&gt;
  
  
  Scoreboard
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Category&lt;/th&gt;
&lt;th&gt;Best pick&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Private local processing&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;APIC / Photopea&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Free background removal&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;APIC&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Template &amp;amp; stock library&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Canva / Adobe Express&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Deep, pro-style editing&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Photopea&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Quick utility jobs (convert, compress, resize, batch)&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;APIC&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Team collaboration&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Canva / Adobe Express&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Honest conclusion:&lt;/strong&gt; this isn't a fight with a single winner. It's different tools for different jobs. APIC fills a gap: &lt;em&gt;free, private and fast for everyday image jobs&lt;/em&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;📝 &lt;strong&gt;Side note:&lt;/strong&gt; remove.bg's help page says its standalone website will no longer be available from &lt;strong&gt;1 December 2026&lt;/strong&gt;. If you were relying on it, that's another reason to have a private, on-device option bookmarked.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  What APIC is bad at (read this before you try it)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Export needs Google sign-in.&lt;/strong&gt; Editing is open, downloads are not. I use it to keep the service running and to understand real usage, and the Privacy page explains what is stored.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A banner ad&lt;/strong&gt; appears on the page.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;First AI run is slow.&lt;/strong&gt; Big models (up to ~176 MB) download once. Use the Light tier on phones.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Smaller design library.&lt;/strong&gt; 35 templates and 9 font families, no stock photos.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No real-time collaboration&lt;/strong&gt; and no cloud sync.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Translations still need review.&lt;/strong&gt; APIC can suggest Hindi, Tamil, Bengali, Odia or Telugu from your browser language, and my translations still need native-speaker review.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Solo, young project.&lt;/strong&gt; Expect rough edges. Please report them.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Is APIC really free?&lt;/strong&gt;&lt;br&gt;
Yes. There are no credits or paid tiers. A banner ad and a Google sign-in for exporting keep the project running.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Does APIC upload my photos?&lt;/strong&gt;&lt;br&gt;
No. Editing, conversion, compression, resizing, background removal and object removal run on your device. Only AI model files are downloaded.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can I remove a background without uploading the image?&lt;/strong&gt;&lt;br&gt;
Yes. APIC's AI runs in your browser using ONNX Runtime Web.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Does it work offline?&lt;/strong&gt;&lt;br&gt;
There is a Windows desktop app (APIC for PC) that works offline. The web version needs a connection the first time it downloads an AI model.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why am I asked to sign in?&lt;/strong&gt;&lt;br&gt;
To download your result. Editing and previewing don't need it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How old do I need to be to use it?&lt;/strong&gt;&lt;br&gt;
13 or older (see the Terms).(because I'm 13 🥲)&lt;/p&gt;




&lt;h2&gt;
  
  
  Help me make it better
&lt;/h2&gt;

&lt;p&gt;If you try APIC, I'd love to hear:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What &lt;strong&gt;one tool&lt;/strong&gt; would make you use it every week?&lt;/li&gt;
&lt;li&gt;Which &lt;strong&gt;language&lt;/strong&gt; should I translate properly next?&lt;/li&gt;
&lt;li&gt;Where did it feel &lt;strong&gt;slow or confusing&lt;/strong&gt;?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Drop a comment here, or open an issue on the &lt;a href="https://github.com/Akhouri-Anmol-Kumar/APIC-WEB" rel="noopener noreferrer"&gt;GitHub repo&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And if you build things at 13 (or 30), the lesson I'd share is simple: &lt;strong&gt;ship the small, honest version, then improve it with real feedback.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;&lt;a href="https://apic-studio.vercel.app/" rel="noopener noreferrer"&gt;Try APIC free&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Sources (checked November 2026)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://apic-studio.vercel.app/" rel="noopener noreferrer"&gt;APIC STUDIO&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.photopea.com/privacy.html" rel="noopener noreferrer"&gt;Photopea privacy / terms&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://remove.bg/help/a/is-remove-bg-free-" rel="noopener noreferrer"&gt;remove.bg: is remove.bg free?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.adobe.com/uk/express/pricing" rel="noopener noreferrer"&gt;Adobe Express pricing (UK)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://costbench.com/software/design/canva/free-plan/" rel="noopener noreferrer"&gt;Canva free plan summary (third-party)&lt;/a&gt; and &lt;a href="https://www.canva.com/pricing/" rel="noopener noreferrer"&gt;Canva pricing&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://onnxruntime.ai/" rel="noopener noreferrer"&gt;ONNX Runtime Web&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;SPECIAL THANKS 💖 TO &lt;a class="mentioned-user" href="https://dev.to/effessdev"&gt;@effessdev&lt;/a&gt; &lt;br&gt;
Because he has helped a lot to find bugs in APIC STUDIO.&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>html</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Windows won't let you own Win+Shift+S. So I hooked the keyboard in Python.</title>
      <dc:creator>Akhouri Anmol Kumar</dc:creator>
      <pubDate>Sat, 07 Nov 2026 04:51:12 +0000</pubDate>
      <link>https://dev.to/akhourianmolkumar/windows-wont-let-you-own-winshifts-so-i-hooked-the-keyboard-in-python-248c</link>
      <guid>https://dev.to/akhourianmolkumar/windows-wont-let-you-own-winshifts-so-i-hooked-the-keyboard-in-python-248c</guid>
      <description>&lt;p&gt;I wanted one small thing: press &lt;code&gt;Win+Shift+S&lt;/code&gt; and get &lt;em&gt;my own&lt;/em&gt; screenshot tool instead of Snipping Tool.&lt;/p&gt;

&lt;p&gt;That turned into a 7,600-line Python project, and a pile of Windows internals that I couldn't find explained in one place. Here are the four that cost me the most hair.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. &lt;code&gt;RegisterHotKey&lt;/code&gt; can't claim &lt;code&gt;Win+Shift+S&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Every tutorial says to use &lt;code&gt;RegisterHotKey&lt;/code&gt;. It works for &lt;code&gt;Ctrl+Alt+D&lt;/code&gt;. It silently fails for &lt;code&gt;Win+Shift+S&lt;/code&gt;, because the shell reserves that combo.&lt;/p&gt;

&lt;p&gt;The way around it is a &lt;strong&gt;low-level keyboard hook&lt;/strong&gt; (&lt;code&gt;WH_KEYBOARD_LL&lt;/code&gt;, id &lt;code&gt;13&lt;/code&gt;), which sees the key before the shell does:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="no"&gt;HOOKPROC&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ctypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;WINFUNCTYPE&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;c_ssize_t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ctypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;c_int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                              &lt;span class="n"&gt;ctypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;c_size_t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ctypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;c_ssize_t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;cb&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nCode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wParam&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lParam&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;nCode&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;wParam&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mh"&gt;0x100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x101&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x104&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x105&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;kb&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ctypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cast&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lParam&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ctypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;POINTER&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;KBDLLHOOKSTRUCT&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;contents&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;kb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;vkCode&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mh"&gt;0x53&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="nf"&gt;win_down&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="nf"&gt;shift_down&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="c1"&gt;# S&lt;/span&gt;
            &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;keybd_event&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mh"&gt;0xE8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# see below&lt;/span&gt;
            &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;keybd_event&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mh"&gt;0xE8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="nc"&gt;QTimer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;singleShot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;on_trigger&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# hop back to the Qt thread&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;                           &lt;span class="c1"&gt;# swallow the key&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;CallNextHookEx&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nCode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wParam&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lParam&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_proc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;HOOKPROC&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cb&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# keep a reference!&lt;/span&gt;
&lt;span class="n"&gt;hook&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;SetWindowsHookExW&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_proc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GetModuleHandleW&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three gotchas worth knowing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Keep a reference to the callback.&lt;/strong&gt; If &lt;code&gt;HOOKPROC(cb)&lt;/code&gt; gets garbage-collected, your app crashes on the next keypress. There's no traceback, it just dies.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Swallowing &lt;code&gt;S&lt;/code&gt; isn't enough.&lt;/strong&gt; If you eat the keypress and the user then releases &lt;code&gt;Win&lt;/code&gt;, Windows opens the Start menu. The fix is to inject an &lt;em&gt;unassigned&lt;/em&gt; virtual key (&lt;code&gt;0xE8&lt;/code&gt;) so Windows thinks &lt;code&gt;Win&lt;/code&gt; was used in a combo.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Track the key-up too.&lt;/strong&gt; If you swallow the key-down, you have to swallow its matching key-up, or apps see an orphaned release. I pulled this into a pure function (&lt;code&gt;snip_hook_decision(...)&lt;/code&gt;) with no ctypes in it, so it's unit-testable.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The hook only looks at the specific keys it cares about while &lt;code&gt;Win+Shift&lt;/code&gt; are held. Nothing is logged or stored. If you ship a keyboard hook, say that in your README.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Keeping your own UI out of your own recording
&lt;/h2&gt;

&lt;p&gt;My screen recorder has a floating control bar. Early on, every video started with the recorder recording itself, which looks amateur.&lt;/p&gt;

&lt;p&gt;Windows 10 (2004+) has a one-line fix:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="no"&gt;WDA_EXCLUDEFROMCAPTURE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mh"&gt;0x11&lt;/span&gt;
&lt;span class="n"&gt;ctypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;windll&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;user32&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;SetWindowDisplayAffinity&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;widget&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;winId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                                              &lt;span class="no"&gt;WDA_EXCLUDEFROMCAPTURE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The window stays visible to the user but is invisible to capture APIs. It's best-effort on older builds, so wrap it in &lt;code&gt;try/except&lt;/code&gt; and move on.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. System audio in Python: &lt;code&gt;sounddevice&lt;/code&gt; can't do it
&lt;/h2&gt;

&lt;p&gt;Recording the microphone is easy. Recording &lt;em&gt;what the PC is playing&lt;/em&gt; is not. &lt;code&gt;sounddevice&lt;/code&gt; can't do WASAPI loopback.&lt;/p&gt;

&lt;p&gt;What worked:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Source&lt;/th&gt;
&lt;th&gt;Library&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Microphone&lt;/td&gt;
&lt;td&gt;&lt;code&gt;sounddevice&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;System audio (loopback)&lt;/td&gt;
&lt;td&gt;&lt;code&gt;PyAudioWPatch&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mixing + muxing into MP4&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;imageio-ffmpeg&lt;/code&gt; (bundles an ffmpeg binary)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The part that matters: &lt;strong&gt;don't mix in real time.&lt;/strong&gt; I record each source to its own WAV on disk, then mix once after the take with ffmpeg's &lt;code&gt;amix&lt;/code&gt;. Real-time mixing means two clocks drifting against each other. Post-mixing means a dropped buffer in one stream can't corrupt the other.&lt;/p&gt;

&lt;p&gt;I also pad or trim each track to exactly the video duration before mixing, because mic and loopback streams never end at the same millisecond.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. OCR with zero extra installs
&lt;/h2&gt;

&lt;p&gt;I wanted "select text from a screenshot" without telling users to install Tesseract.&lt;/p&gt;

&lt;p&gt;Windows 10/11 already ships an OCR engine: &lt;code&gt;Windows.Media.Ocr&lt;/code&gt;. You can reach it from PowerShell, so Python just shells out:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;subprocess&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"powershell"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"-NoProfile"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"-ExecutionPolicy"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Bypass"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"-File"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ps1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;capture_output&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;120&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;creationflags&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mh"&gt;0x08000000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="c1"&gt;# CREATE_NO_WINDOW, no console flash&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The PowerShell script tries the user's language packs first and falls back to whatever recognizer is available. It runs in a &lt;code&gt;QThread&lt;/code&gt;, so the UI never freezes. The result: no models to download, no 200 MB dependency, and it works offline.&lt;/p&gt;

&lt;h2&gt;
  
  
  Small things that made it feel finished
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Recycle Bin, not delete.&lt;/strong&gt; &lt;code&gt;os.remove&lt;/code&gt; is permanent. &lt;code&gt;SHFileOperationW&lt;/code&gt; with &lt;code&gt;FOF_ALLOWUNDO&lt;/code&gt; sends files to the Recycle Bin, so "delete capture" is never scary.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Atomic settings.&lt;/strong&gt; Write to &lt;code&gt;settings.json.tmp&lt;/code&gt;, then &lt;code&gt;os.replace()&lt;/code&gt;. A crash mid-write can't corrupt your config.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Single instance.&lt;/strong&gt; A named mutex (&lt;code&gt;CreateMutexW&lt;/code&gt; + check for error &lt;code&gt;183&lt;/code&gt;) stops two copies fighting over the same global hotkeys.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Autostart&lt;/strong&gt; is one registry value under &lt;code&gt;HKCU\...\Run&lt;/code&gt;. No installer needed.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Where all this ended up
&lt;/h2&gt;

&lt;p&gt;All of the above lives in &lt;strong&gt;ASNIPP&lt;/strong&gt;, a screenshot tool, screen recorder and editor that sits as a small "Dynamic Island" pill at the top of your screen. The parts I'm proudest of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Screenshots with pen, highlighter, arrows, shapes, text and pixelate (for hiding sensitive info)&lt;/li&gt;
&lt;li&gt;A color picker with a magnifier loupe, and a pixel ruler&lt;/li&gt;
&lt;li&gt;Pin-to-screen floating captures&lt;/li&gt;
&lt;li&gt;Screen recording with system audio and mic, plus &lt;strong&gt;live drawing that gets recorded into the video&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;A built-in video editor: trim, speed, reverse, color looks, fades, rotate and GIF export&lt;/li&gt;
&lt;li&gt;OCR on any capture&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's one 7600+ lines of python code packed into .exe, PyQt6, &lt;code&gt;mss&lt;/code&gt; for capture and OpenCV for video. If you've ever wondered how far a python desktop app can go, it's a decent case study.&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;[&lt;a href="https://github.com/Akhouri-Systems/ASNIPP/releases/download/v1.0.0/ASNIPP_v1.zip" rel="noopener noreferrer"&gt;https://github.com/Akhouri-Systems/ASNIPP/releases/download/v1.0.0/ASNIPP_v1.zip&lt;/a&gt;]&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;If you've built something with &lt;code&gt;ctypes&lt;/code&gt; and Win32, I'd love to hear what bit you. Drop it in the comments.&lt;/p&gt;

</description>
      <category>python</category>
      <category>pyqt</category>
      <category>opensource</category>
      <category>windows</category>
    </item>
    <item>
      <title>HTML's Real Ceiling: What's the Most You Can Build With a Single .html File?</title>
      <dc:creator>Akhouri Anmol Kumar</dc:creator>
      <pubDate>Thu, 05 Nov 2026 16:04:19 +0000</pubDate>
      <link>https://dev.to/akhourianmolkumar/htmls-real-ceiling-whats-the-most-you-can-build-with-a-single-html-file-1l0j</link>
      <guid>https://dev.to/akhourianmolkumar/htmls-real-ceiling-whats-the-most-you-can-build-with-a-single-html-file-1l0j</guid>
      <description>&lt;p&gt;Ask a developer what Python can build and you'll get a confident list: ML models, backends, automation, data pipelines, scripts that run your life.&lt;/p&gt;

&lt;p&gt;Now ask what &lt;strong&gt;HTML&lt;/strong&gt; can build.&lt;/p&gt;

&lt;p&gt;Watch the silence. Then: &lt;em&gt;"Uh... websites?"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I want to push on that, because I think the honest answer is far more interesting than "websites", and it'll change how you look at that humble &lt;code&gt;index.html&lt;/code&gt; file.&lt;/p&gt;

&lt;h2&gt;
  
  
  First, an honest confession 🎭
&lt;/h2&gt;

&lt;p&gt;HTML is a &lt;strong&gt;markup language&lt;/strong&gt;. Strictly speaking, it doesn't &lt;em&gt;compute&lt;/em&gt; anything. It can't add &lt;code&gt;2 + 2&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So the real question isn't &lt;em&gt;"what can HTML do?"&lt;/em&gt; It's:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;What can a single &lt;code&gt;.html&lt;/code&gt; file, opened in a modern browser, do?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Because that file is a &lt;strong&gt;launch pad&lt;/strong&gt;. It's the one format every device on Earth already knows how to run, with no install, no build step, no Docker, no "works on my machine".&lt;/p&gt;

&lt;p&gt;Think of HTML as the &lt;strong&gt;ignition key&lt;/strong&gt;. The engine is the browser. Let's see how fast this car goes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Level 1: The Document 📄
&lt;/h2&gt;

&lt;p&gt;Headings, links, forms, tables. This is where everyone's mental model stops.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"email"&lt;/span&gt; &lt;span class="na"&gt;required&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;button&amp;gt;&lt;/span&gt;Subscribe&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Native validation, accessibility, and semantics, and you haven't written a line of JS yet. Underrated, but it's the &lt;em&gt;floor&lt;/em&gt;, not the ceiling.&lt;/p&gt;

&lt;h2&gt;
  
  
  Level 2: The Interactive App 🎮
&lt;/h2&gt;

&lt;p&gt;Add &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; and suddenly the file is alive: calculators, kanban boards, games, dashboards. Entire products live here, in a single file, with state, events, and animation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Level 3: The Creative Studio 🎨
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;canvas&amp;gt;&lt;/code&gt; gives you a raw pixel grid. Draw, filter, composite, export. Anything you can do to pixels, you can do here:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;ctx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'2d'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;img&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getImageData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// every pixel is yours: [R, G, B, A, R, G, B, A, ...]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Brightness, curves, histograms, colour grading, even exporting &lt;strong&gt;3D LUT (&lt;code&gt;.cube&lt;/code&gt;) files&lt;/strong&gt;. This is the kind of thing people assume needs Photoshop.&lt;/p&gt;

&lt;h2&gt;
  
  
  Level 4: The Local-First Powerhouse 💾
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;localStorage&lt;/code&gt;, &lt;code&gt;IndexedDB&lt;/code&gt;, the Cache API, drag-and-drop, the File API. Your app can remember, store gigabytes, and work with the user's real files, &lt;strong&gt;without a server&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Level 5: The Multithreaded Machine ⚙️
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Web Workers&lt;/strong&gt; let you run heavy work off the main thread. The UI stays smooth while something big crunches in the background.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;A frozen UI isn't a "slow app". It's a broken promise.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Level 6: The AI Level 🤖 (this is where jaws drop)
&lt;/h2&gt;

&lt;p&gt;Here's the part most people don't know:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You can run real neural networks inside a plain HTML page.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ONNX Runtime Web&lt;/strong&gt; + &lt;strong&gt;WebAssembly&lt;/strong&gt; (and increasingly WebGPU) means a model can be downloaded once, cached, and executed &lt;em&gt;on the user's device&lt;/em&gt;. That unlocks things people assume are "Python-only":&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🧠 &lt;strong&gt;Background removal&lt;/strong&gt; (segmentation models like ISNet / U²-Net)&lt;/li&gt;
&lt;li&gt;🪄 &lt;strong&gt;Object removal&lt;/strong&gt; (inpainting models like LaMa)&lt;/li&gt;
&lt;li&gt;🔍 &lt;strong&gt;AI upscaling&lt;/strong&gt; (Real-ESRGAN)&lt;/li&gt;
&lt;li&gt;🔤 &lt;strong&gt;OCR&lt;/strong&gt; (Tesseract compiled to WASM)&lt;/li&gt;
&lt;li&gt;🖐 &lt;strong&gt;Vision tasks&lt;/strong&gt; (MediaPipe)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;No GPU server. No API bill. No upload.&lt;/p&gt;

&lt;p&gt;And the privacy angle is the real kicker: &lt;strong&gt;if the model runs in the browser, the photo never has to leave the device.&lt;/strong&gt; That isn't a policy promise. It's an architecture fact.&lt;/p&gt;

&lt;h2&gt;
  
  
  So... what's HTML's actual max?
&lt;/h2&gt;

&lt;p&gt;Here's my honest ranking of what a browser-delivered HTML app can realistically be:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Python's famous strengths&lt;/th&gt;
&lt;th&gt;HTML's counterpart&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Data / ML experiments&lt;/td&gt;
&lt;td&gt;In-browser inference with ONNX/WASM&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Desktop-style tools&lt;/td&gt;
&lt;td&gt;Canvas + Workers + File API&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Offline scripts&lt;/td&gt;
&lt;td&gt;Local-first apps with IndexedDB/Cache&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Quick distribution&lt;/td&gt;
&lt;td&gt;A URL. That's it. That's the install.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Where HTML still hits a wall:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🧱 Heavy server-side logic, secure secrets, big databases (you still need a backend for those)&lt;/li&gt;
&lt;li&gt;🧱 Very large models (a 176 MB model is a lot for a mobile connection)&lt;/li&gt;
&lt;li&gt;🧱 Truly low-level system access (the browser sandbox is a feature &lt;em&gt;and&lt;/em&gt; a limit)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So HTML's ceiling isn't "everything". It's something sneakier:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;HTML's superpower isn't power. It's &lt;em&gt;reach&lt;/em&gt;.&lt;/strong&gt;&lt;br&gt;
Python needs an interpreter. HTML needs a link.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  I tested this claim on myself 🧪
&lt;/h2&gt;

&lt;p&gt;I kept saying &lt;em&gt;"a browser tab can be a real tool"&lt;/em&gt;, so I built one to find out if I was lying.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://apic-studio.vercel.app/" rel="noopener noreferrer"&gt;&lt;strong&gt;APIC STUDIO&lt;/strong&gt;&lt;/a&gt; is a photo toolkit that ships as essentially &lt;strong&gt;one HTML file&lt;/strong&gt;, around 600 KB of source. Inside it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🎨 an editor with live histogram, RGB curves, HSL mixer, 3-way colour grading, and &lt;code&gt;.cube&lt;/code&gt; LUT export&lt;/li&gt;
&lt;li&gt;✂️ AI background removal running via ONNX Runtime + WebAssembly&lt;/li&gt;
&lt;li&gt;🪄 AI object removal (LaMa-style inpainting)&lt;/li&gt;
&lt;li&gt;🔍 upscaling and OCR, all client-side&lt;/li&gt;
&lt;li&gt;🗜 compression to a &lt;em&gt;target file size&lt;/em&gt; (it searches for the best quality that fits)&lt;/li&gt;
&lt;li&gt;📐 resize, format conversion (PNG, JPEG, WebP, BMP, ICO, PDF), and social media presets&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The thing that surprised me most while building it: &lt;strong&gt;the hard part wasn't capability. It was restraint.&lt;/strong&gt; The browser could already do almost everything. My job was mostly to stay out of its way.&lt;/p&gt;

&lt;p&gt;It's the best answer I have to &lt;em&gt;"how far can HTML go?"&lt;/em&gt;: far enough that I use it for my own images now.&lt;/p&gt;

&lt;p&gt;You can edit with every tool without an account, and you only sign in (one tap, Google) when you export. If you want to poke at what "HTML at Level 6" feels like, open it, drop in a photo, and watch your own DevTools Network tab. You'll see the model download once and then... nothing leaving your machine.&lt;/p&gt;

&lt;h2&gt;
  
  
  The takeaway
&lt;/h2&gt;

&lt;p&gt;Next time someone says &lt;em&gt;"HTML is just markup"&lt;/em&gt;, you can smile and say:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"So is a score sheet. Then an orchestra shows up."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The browser is the orchestra. HTML is just where you hand over the sheet music.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So, your turn:&lt;/strong&gt; what's the most unexpected thing you've seen (or built) inside a single HTML file? Drop it below. I'm collecting ceilings. 👇&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>html</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Are You a Python Developer or a Python Expert? 8 Tests I Failed Hijacking Win+Shift+S in One 7,600-Line File</title>
      <dc:creator>Akhouri Anmol Kumar</dc:creator>
      <pubDate>Wed, 04 Nov 2026 05:14:56 +0000</pubDate>
      <link>https://dev.to/akhourianmolkumar/are-you-a-python-developer-or-a-python-expert-8-tests-i-failed-hijacking-winshifts-in-one-30dg</link>
      <guid>https://dev.to/akhourianmolkumar/are-you-a-python-developer-or-a-python-expert-8-tests-i-failed-hijacking-winshifts-in-one-30dg</guid>
      <description>&lt;p&gt;Most Python developers can parse a CSV, write a decorator and &lt;code&gt;pip install&lt;/code&gt; their way out of a problem.&lt;/p&gt;

&lt;p&gt;Python experts know what happens when &lt;strong&gt;the operating system doesn't want you to do the thing&lt;/strong&gt;: when a hotkey is reserved, when an audio device goes quiet, when a screen grab is slower than your frame rate, and when &lt;code&gt;ctypes&lt;/code&gt; quietly cuts your pointers in half.&lt;/p&gt;

&lt;p&gt;I found out which one I was while building &lt;strong&gt;ASNIPP&lt;/strong&gt;: a screenshot tool, screen recorder, live-drawing overlay, colour picker and video editor for Windows. It is &lt;strong&gt;one Python file, about 7,600 lines&lt;/strong&gt;, with no ads, no analytics and no network calls. Everything runs on your machine.&lt;/p&gt;

&lt;p&gt;Every test below is a real bug or design decision from that file. The code is trimmed for reading, but the ideas are exactly what ships. Score yourself honestly. 👇&lt;/p&gt;




&lt;h2&gt;
  
  
  Test 1: Can you take a hotkey that Windows says is &lt;em&gt;reserved&lt;/em&gt;?
&lt;/h2&gt;

&lt;p&gt;I wanted &lt;code&gt;Win+Shift+S&lt;/code&gt; to open ASNIPP instead of the Snipping Tool. The obvious tool is &lt;code&gt;RegisterHotKey&lt;/code&gt;. It fails: that combo belongs to the shell.&lt;/p&gt;

&lt;p&gt;The way in is a &lt;strong&gt;low-level keyboard hook&lt;/strong&gt; (&lt;code&gt;WH_KEYBOARD_LL&lt;/code&gt;) through &lt;code&gt;ctypes&lt;/code&gt;. It sees the keystroke &lt;em&gt;before&lt;/em&gt; anyone else, and if your callback returns &lt;code&gt;1&lt;/code&gt;, the key never reaches Windows.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;cb&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nCode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wParam&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lParam&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;nCode&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;wParam&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mh"&gt;0x100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x101&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x104&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x105&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="c1"&gt;# key down / up&lt;/span&gt;
        &lt;span class="n"&gt;kb&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ctypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cast&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lParam&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ctypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;POINTER&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_KBDLLHOOKSTRUCT&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;contents&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;kb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;vkCode&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="no"&gt;SNIP_HOOK_KEYS&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                         &lt;span class="c1"&gt;# only S and R, nothing else&lt;/span&gt;
            &lt;span class="n"&gt;action&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_pending&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;kb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;vkCode&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;snip_hook_decision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                &lt;span class="n"&gt;kb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;vkCode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wParam&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mh"&gt;0x100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x104&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;kb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;flags&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="mh"&gt;0x10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="nf"&gt;pressed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mh"&gt;0x5B&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x5C&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;pressed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mh"&gt;0x10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;pressed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mh"&gt;0x11&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;pressed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mh"&gt;0x12&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_pending&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;kb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;vkCode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;action&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"trigger"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;keybd_event&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mh"&gt;0xE8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;    &lt;span class="c1"&gt;# inject an unassigned key...&lt;/span&gt;
                &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;keybd_event&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mh"&gt;0xE8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;    &lt;span class="c1"&gt;# ...so releasing Win doesn't open Start&lt;/span&gt;
                &lt;span class="nc"&gt;QTimer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;singleShot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on_trigger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"photo"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;                        &lt;span class="c1"&gt;# swallowed&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;action&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"swallow"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;CallNextHookEx&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nCode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wParam&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lParam&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_proc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;HOOKPROC&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cb&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;    &lt;span class="c1"&gt;# keep a reference or it gets garbage-collected&lt;/span&gt;
&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hook&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;SetWindowsHookExW&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_proc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GetModuleHandleW&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Four details separate "it works once" from "it works":&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Swallow the key-up too.&lt;/strong&gt; If you eat the &lt;code&gt;S&lt;/code&gt; press but let the release through, apps see a stray key-up. ASNIPP remembers it ate the press and eats exactly one release.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Inject a dummy key (&lt;code&gt;0xE8&lt;/code&gt;).&lt;/strong&gt; Press and release &lt;code&gt;Win&lt;/code&gt; alone and Windows opens Start. A harmless unassigned keystroke in between cancels that.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ignore injected events&lt;/strong&gt; (&lt;code&gt;flags &amp;amp; 0x10&lt;/code&gt;), or your own &lt;code&gt;keybd_event&lt;/code&gt; call will trigger you again.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The decision logic is a pure function&lt;/strong&gt; with no &lt;code&gt;ctypes&lt;/code&gt; in it, so it can be tested without a keyboard:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;snip_hook_decision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vk&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;down&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;injected&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;win&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;shift&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ctrl&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;alt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pending_up&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;injected&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;vk&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="no"&gt;SNIP_HOOK_KEYS&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"pass"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pending_up&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;down&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;win&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;shift&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;ctrl&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;alt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"trigger"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"pass"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pending_up&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;pending_up&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"swallow"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"pass"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pending_up&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It only looks at &lt;code&gt;S&lt;/code&gt; and &lt;code&gt;R&lt;/code&gt; while &lt;code&gt;Win+Shift&lt;/code&gt; are held. Nothing is logged or stored, and the source says so at the top of the class, because a keyboard hook should always be honest about what it reads.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Developer:&lt;/strong&gt; &lt;code&gt;pip install keyboard&lt;/code&gt;.&lt;br&gt;
&lt;strong&gt;Expert:&lt;/strong&gt; knows where the hook sits in the input chain, and writes the state machine as a pure function.&lt;/p&gt;


&lt;h2&gt;
  
  
  Test 2: Why is my recording's audio 40 seconds shorter than the video?
&lt;/h2&gt;

&lt;p&gt;ASNIPP records system audio with WASAPI loopback. The first test recording looked fine, until I played a video with long silent parts: the sound drifted further and further ahead of the picture.&lt;/p&gt;

&lt;p&gt;The cause: &lt;strong&gt;loopback delivers no data at all while nothing is playing.&lt;/strong&gt; No callbacks, no zeros, nothing. If you just append whatever arrives, silence disappears from the file and everything after it slides earlier.&lt;/p&gt;

&lt;p&gt;The fix is to treat the wall clock as the truth and &lt;strong&gt;pad the gaps yourself&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                      &lt;span class="c1"&gt;# called from the audio thread&lt;/span&gt;
    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lock&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fill&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                      &lt;span class="c1"&gt;# only for loopback, not the mic&lt;/span&gt;
            &lt;span class="n"&gt;now&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;rec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;active_time&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;        &lt;span class="c1"&gt;# seconds of *unpaused* recording&lt;/span&gt;
            &lt;span class="n"&gt;gap&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;now&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;frames&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;gap&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rate&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.12&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;     &lt;span class="c1"&gt;# ignore jitter under 120 ms&lt;/span&gt;
                &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_zeros&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;gap&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;           &lt;span class="c1"&gt;# write real silence&lt;/span&gt;
        &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;tobytes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;frames&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;active_time()&lt;/code&gt; is &lt;code&gt;perf_counter()&lt;/code&gt; minus the start time minus every second spent paused. So pausing the recording pauses the audio clock too.&lt;/p&gt;

&lt;p&gt;Bonus trap: &lt;code&gt;sounddevice&lt;/code&gt; has &lt;strong&gt;no&lt;/strong&gt; WASAPI loopback. System audio needs &lt;code&gt;PyAudioWPatch&lt;/code&gt;, with a "Stereo Mix" device as the fallback. ASNIPP tries both and tells the user which one is missing instead of silently recording nothing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Developer:&lt;/strong&gt; appends the bytes it receives.&lt;br&gt;
&lt;strong&gt;Expert:&lt;/strong&gt; asks "what does this API do when there is nothing to say?"&lt;/p&gt;


&lt;h2&gt;
  
  
  Test 3: What happens when &lt;code&gt;grab()&lt;/code&gt; can't keep up with 30 FPS?
&lt;/h2&gt;

&lt;p&gt;The recorder is a loop of &lt;code&gt;mss.grab()&lt;/code&gt; → &lt;code&gt;cv2.VideoWriter.write()&lt;/code&gt;. On a busy 4K screen a grab can take longer than 33 ms. If you write one frame per grab, a 10-second recording is stored as 6 seconds of video, and it plays back too fast.&lt;/p&gt;

&lt;p&gt;The loop doesn't count frames. It counts &lt;strong&gt;time&lt;/strong&gt;, and writes as many frames as the clock says are owed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;active&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;dt&lt;/span&gt;                                    &lt;span class="c1"&gt;# unpaused seconds so far&lt;/span&gt;
&lt;span class="n"&gt;img&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sct&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;grab&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;monitor&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;fr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ascontiguousarray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;asarray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;img&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# BGRA -&amp;gt; BGR&lt;/span&gt;

&lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;active&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;fps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;                  &lt;span class="c1"&gt;# frames that SHOULD exist by now&lt;/span&gt;
&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;written&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;          &lt;span class="c1"&gt;# catch up, but never more than 1 s at once&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;written&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;

&lt;span class="n"&gt;wait&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;written&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;fps&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;active&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;perf_counter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;last&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;wait&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;wait&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.05&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;                 &lt;span class="c1"&gt;# too fast? sleep. Too slow? duplicate.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A slow machine gets a few repeated frames. A fast machine gets a sleep. &lt;strong&gt;Either way the video is exactly as long as the real recording&lt;/strong&gt;, which is what keeps the audio from Test 2 in sync.&lt;/p&gt;

&lt;p&gt;Two small things make it production-grade: the &lt;code&gt;min(..., fps)&lt;/code&gt; cap stops a long stall from dumping thousands of frames, and the audio clock starts from an &lt;code&gt;on_ready&lt;/code&gt; callback fired right before the first frame, so both streams share the same zero.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Developer:&lt;/strong&gt; &lt;code&gt;time.sleep(1/30)&lt;/code&gt; in a loop.&lt;br&gt;
&lt;strong&gt;Expert:&lt;/strong&gt; knows &lt;code&gt;sleep&lt;/code&gt; is a request, not a guarantee, and schedules against a clock.&lt;/p&gt;


&lt;h2&gt;
  
  
  Test 4: Why did my mic get &lt;em&gt;quieter&lt;/em&gt; when I turned on system audio?
&lt;/h2&gt;

&lt;p&gt;After recording, ASNIPP mixes the system track and the mic track into the MP4 with ffmpeg. Turn on both and the voice sounded half as loud.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;amix&lt;/code&gt; &lt;strong&gt;divides each input by the number of inputs&lt;/strong&gt; by default. Two tracks, so each is halved. The fix is &lt;code&gt;normalize=0&lt;/code&gt;, but not every ffmpeg build knows that option, so the mixer tries variants in order and moves on when one fails:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;variants&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="n"&gt;chains&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"[a0][a1]amix=inputs=2:duration=longest:normalize=0,apad,atrim=0:{d}[m]"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;chains&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"[a0][a1]amix=inputs=2:duration=longest,volume=2,apad,atrim=0:{d}[m]"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c1"&gt;# older builds&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;fc&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;variants&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;run_ffmpeg&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"-filter_complex"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;";"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fc&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Look at the tail too: &lt;code&gt;apad,atrim=0:{d}&lt;/code&gt;. If the audio is a hair shorter than the video, ffmpeg's &lt;code&gt;-shortest&lt;/code&gt; would &lt;strong&gt;cut the video&lt;/strong&gt;. Padding the audio and then trimming to the exact video length means a short track can never shorten the video.&lt;/p&gt;

&lt;p&gt;And if ffmpeg is missing entirely? ASNIPP mixes the tracks in pure NumPy and saves a &lt;code&gt;.wav&lt;/code&gt; next to the video, with a note saying what to install. It degrades, it doesn't crash.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Developer:&lt;/strong&gt; &lt;code&gt;ffmpeg -i a -i b out.mp4&lt;/code&gt;.&lt;br&gt;
&lt;strong&gt;Expert:&lt;/strong&gt; reads what each filter &lt;em&gt;assumes&lt;/em&gt;, and keeps a plan B.&lt;/p&gt;


&lt;h2&gt;
  
  
  Test 5: Why does &lt;code&gt;GetWindowLongPtrW&lt;/code&gt; return garbage in Python?
&lt;/h2&gt;

&lt;p&gt;Live drawing mode puts a transparent overlay over your whole screen. Sometimes you want to &lt;em&gt;click through&lt;/em&gt; it to the app underneath. That is the &lt;code&gt;WS_EX_TRANSPARENT&lt;/code&gt; window style, set through &lt;code&gt;ctypes&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;u&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ctypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;windll&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;user32&lt;/span&gt;
&lt;span class="n"&gt;get_l&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;set_l&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GetWindowLongPtrW&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;SetWindowLongPtrW&lt;/span&gt;

&lt;span class="n"&gt;get_l&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;restype&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ctypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;c_ssize_t&lt;/span&gt;                       &lt;span class="c1"&gt;# &amp;lt;- the whole point&lt;/span&gt;
&lt;span class="n"&gt;get_l&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;argtypes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;ctypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;c_void_p&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ctypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;c_int&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;set_l&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;restype&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ctypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;c_ssize_t&lt;/span&gt;
&lt;span class="n"&gt;set_l&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;argtypes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;ctypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;c_void_p&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ctypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;c_int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ctypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;c_ssize_t&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;hwnd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;widget&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;winId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;st&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;get_l&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hwnd&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;                                    &lt;span class="c1"&gt;# GWL_EXSTYLE&lt;/span&gt;
&lt;span class="n"&gt;st&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;st&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="mh"&gt;0x20&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="mh"&gt;0x80000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;on&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;st&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;~&lt;/span&gt;&lt;span class="mh"&gt;0x20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;       &lt;span class="c1"&gt;# TRANSPARENT | LAYERED&lt;/span&gt;
&lt;span class="nf"&gt;set_l&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hwnd&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;ctypes&lt;/code&gt; assumes every foreign function returns a 32-bit &lt;code&gt;int&lt;/code&gt; and takes 32-bit arguments. On 64-bit Windows, handles and pointer-sized values are &lt;strong&gt;64 bits&lt;/strong&gt;, so without &lt;code&gt;restype&lt;/code&gt; and &lt;code&gt;argtypes&lt;/code&gt; you get truncated values, sign errors and crashes that only appear on some machines. Declare every signature, every time.&lt;/p&gt;

&lt;p&gt;The function also falls back to Qt's own &lt;code&gt;WA_TransparentForMouseEvents&lt;/code&gt; if the Win32 route fails, and a 32-bit Python gets &lt;code&gt;GetWindowLongW&lt;/code&gt; instead. Same idea as Test 4: the ideal path first, and an honest fallback after.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Developer:&lt;/strong&gt; copies the snippet from Stack Overflow.&lt;br&gt;
&lt;strong&gt;Expert:&lt;/strong&gt; writes down the C signature before calling the C function.&lt;/p&gt;


&lt;h2&gt;
  
  
  Test 6: Does "delete" actually mean &lt;em&gt;delete&lt;/em&gt;?
&lt;/h2&gt;

&lt;p&gt;ASNIPP's library has a delete button. &lt;code&gt;os.remove()&lt;/code&gt; is permanent, and nobody forgives a tool that permanently deletes their screenshot after one misclick. So deleting sends the file to the &lt;strong&gt;Recycle Bin&lt;/strong&gt;, using &lt;code&gt;SHFileOperationW&lt;/code&gt; and no third-party package:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SHFILEOPSTRUCTW&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Structure&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;_pack_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;ctypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sizeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;c_void_p&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;     &lt;span class="c1"&gt;# 32 vs 64-bit layout&lt;/span&gt;
    &lt;span class="n"&gt;_fields_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"hwnd"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;HWND&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"wFunc"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;UINT&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"pFrom"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;LPCWSTR&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"pTo"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;LPCWSTR&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"fFlags"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ctypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;c_ushort&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"fAnyOperationsAborted"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;BOOL&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"hNameMappings"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ctypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;c_void_p&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"lpszProgressTitle"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;LPCWSTR&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;op&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;SHFILEOPSTRUCTW&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;op&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wFunc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;                                       &lt;span class="c1"&gt;# FO_DELETE&lt;/span&gt;
&lt;span class="n"&gt;op&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pFrom&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;abspath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"\0"&lt;/span&gt;            &lt;span class="c1"&gt;# must end in TWO nulls (Python adds one)&lt;/span&gt;
&lt;span class="n"&gt;op&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fFlags&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mh"&gt;0x40&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="mh"&gt;0x10&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="mh"&gt;0x4&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="mh"&gt;0x400&lt;/span&gt;              &lt;span class="c1"&gt;# ALLOWUNDO | NOCONFIRM | SILENT | NOERRORUI&lt;/span&gt;
&lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ctypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;windll&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shell32&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;SHFileOperationW&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;byref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;op&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;op&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fAnyOperationsAborted&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exists&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The last line matters most. The function returns &lt;code&gt;True&lt;/code&gt; &lt;strong&gt;only if the file is really gone&lt;/strong&gt;. Not "the call returned 0". Not "no exception". The API said yes &lt;em&gt;and&lt;/em&gt; the filesystem agrees.&lt;/p&gt;

&lt;p&gt;If it can't reach the Recycle Bin (some network drives), the UI can say so rather than claim a delete that didn't happen.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Developer:&lt;/strong&gt; trusts the return code.&lt;br&gt;
&lt;strong&gt;Expert:&lt;/strong&gt; verifies the world changed.&lt;/p&gt;


&lt;h2&gt;
  
  
  Test 7: Is your eyedropper accurate to the &lt;em&gt;pixel&lt;/em&gt; on a scaled display?
&lt;/h2&gt;

&lt;p&gt;ASNIPP has a colour picker with a magnifier and a pixel ruler. The first version was off by one pixel on my laptop, and by several on my friend's 150% display.&lt;/p&gt;

&lt;p&gt;Two decisions fixed it:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Freeze the screen first.&lt;/strong&gt; The picker doesn't read live pixels. It hides ASNIPP's own island, waits 160 ms for the compositor, grabs the screen once, and works on that frozen image. Menus, tooltips and hover states stay exactly as they were when you pressed the key.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_grab_prepare&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;island&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;hide&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nc"&gt;QTimer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;singleShot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;160&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_grab&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# let the window really disappear&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_grab&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;pix&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;screen&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;grabWindow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;pix&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setDevicePixelRatio&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;                        &lt;span class="c1"&gt;# work in true device pixels&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Never assume widget size equals image size.&lt;/strong&gt; Convert with a ratio, clamp, and put the point back at the &lt;em&gt;centre&lt;/em&gt; of its pixel:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_sx&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;img&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;width&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;width&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_to_img&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                                  &lt;span class="c1"&gt;# widget -&amp;gt; image pixel&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;QPoint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;x&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_sx&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;img&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;width&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                  &lt;span class="nb"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;y&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_sy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;img&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;height&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_to_view&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ip&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                                 &lt;span class="c1"&gt;# image pixel -&amp;gt; widget&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;QPointF&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ip&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;x&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_sx&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ip&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;y&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;_sy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That &lt;code&gt;+ 0.5&lt;/code&gt; is the trick. A pixel is a square, not a point. Draw the crosshair on its corner and everything looks half a pixel off. The ruler also snaps to 45° steps with one line of &lt;code&gt;atan2&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;ang&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;atan2&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dy&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dx&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pi&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pi&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Developer:&lt;/strong&gt; &lt;code&gt;int(event.x())&lt;/code&gt; and hope.&lt;br&gt;
&lt;strong&gt;Expert:&lt;/strong&gt; knows a pixel has a centre, and that screens have scale factors.&lt;/p&gt;


&lt;h2&gt;
  
  
  Test 8: Can your app leave the PC exactly how it found it?
&lt;/h2&gt;

&lt;p&gt;To own &lt;code&gt;PrintScreen&lt;/code&gt;, ASNIPP has to turn off a Windows setting (&lt;code&gt;PrintScreenKeyForSnippingEnabled&lt;/code&gt;) in the registry. That is the user's setting, not mine. So the takeover is a reversible transaction:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;cur&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;read_prtscn_setting&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;cur&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;settings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"prev_prtscn"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;      &lt;span class="c1"&gt;# remember it ONCE&lt;/span&gt;
        &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;settings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kt"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"prev_prtscn"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cur&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;write_prtscn_setting&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;span class="c1"&gt;# turning ASNIPP's takeover off again:&lt;/span&gt;
&lt;span class="n"&gt;prev&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;settings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"prev_prtscn"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;prev&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;write_prtscn_setting&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prev&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;                      &lt;span class="c1"&gt;# put it back&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Around that sit a handful of unglamorous habits that make software feel trustworthy:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Settings are written atomically.&lt;/strong&gt; Write &lt;code&gt;settings.json.tmp&lt;/code&gt;, then &lt;code&gt;os.replace()&lt;/code&gt; over the real file. A crash mid-write can't leave half a file.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Settings are type-checked on load.&lt;/strong&gt; A value is only accepted if &lt;code&gt;isinstance(raw[k], type(default))&lt;/code&gt;. A hand-edited &lt;code&gt;"autostart": "yes"&lt;/code&gt; can't break startup.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Apply first, explain second.&lt;/strong&gt; On first run the takeover is applied &lt;em&gt;before&lt;/em&gt; the dialog appears, so closing the box can't undo it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Never show a dialog during a silent login start&lt;/strong&gt; (&lt;code&gt;--background&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;One instance only.&lt;/strong&gt; A named mutex, and &lt;code&gt;GetLastError() == 183&lt;/code&gt; (&lt;code&gt;ERROR_ALREADY_EXISTS&lt;/code&gt;) means "someone is already holding the hotkeys, so exit quietly".&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;"Start with Windows" is opt-in&lt;/strong&gt;, and the command it writes handles Nuitka builds, PyInstaller builds and plain &lt;code&gt;pythonw.exe&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Developer:&lt;/strong&gt; ships features.&lt;br&gt;
&lt;strong&gt;Expert:&lt;/strong&gt; ships an undo button for every side effect.&lt;/p&gt;


&lt;h2&gt;
  
  
  Bonus: OCR with zero pip packages
&lt;/h2&gt;

&lt;p&gt;ASNIPP can copy text out of any screenshot. No Tesseract, no model download. Windows already ships an OCR engine (&lt;code&gt;Windows.Media.Ocr&lt;/code&gt;), and Python can drive it through PowerShell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ps1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"w"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;encoding&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"utf-8-sig"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;        &lt;span class="c1"&gt;# BOM so PowerShell reads Unicode correctly&lt;/span&gt;
    &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;script&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;subprocess&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"powershell"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"-NoProfile"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"-ExecutionPolicy"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Bypass"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"-File"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ps1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
               &lt;span class="n"&gt;capture_output&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;120&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;creationflags&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mh"&gt;0x08000000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# no console flash&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;utf-8-sig&lt;/code&gt; is the whole lesson: without the BOM, Windows PowerShell 5 reads the script as the legacy code page and non-English text turns to mush. And &lt;code&gt;0x08000000&lt;/code&gt; (&lt;code&gt;CREATE_NO_WINDOW&lt;/code&gt;) stops a black console from flashing on screen every time you press the button.&lt;/p&gt;

&lt;p&gt;Also from the file: ffmpeg's &lt;code&gt;atempo&lt;/code&gt; only accepts 0.5x to 2x, so a 4x speed-up has to be &lt;strong&gt;chained&lt;/strong&gt; (&lt;code&gt;atempo=2.0,atempo=2.0&lt;/code&gt;). A tiny &lt;code&gt;while&lt;/code&gt; loop in &lt;code&gt;atempo_chain()&lt;/code&gt; does it.&lt;/p&gt;




&lt;h2&gt;
  
  
  Try the code yourself
&lt;/h2&gt;

&lt;p&gt;All of this lives in &lt;strong&gt;ASNIPP&lt;/strong&gt;, built by &lt;strong&gt;Akhouri Systems&lt;/strong&gt;: a pure-Python Windows app with a "Dynamic Island" style capture bar. It has no ads, no analytics and no network calls. It does exactly what's on the tin, and the hook in Test 1 only ever looks at the keys it needs.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;What you get&lt;/th&gt;
&lt;th&gt;Details&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;📸 &lt;strong&gt;Photo capture&lt;/strong&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;Win+Shift+S&lt;/code&gt;, &lt;code&gt;Ctrl+Shift+S&lt;/code&gt; or &lt;code&gt;PrintScreen&lt;/code&gt;. Region, window or full screen, copied to clipboard and saved&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;🎥 &lt;strong&gt;Screen recorder&lt;/strong&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;Win+Shift+R&lt;/code&gt;, with system audio + mic, pause and a recording border that never appears in the video&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;✏️ &lt;strong&gt;Live drawing&lt;/strong&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;Ctrl+Alt+D&lt;/code&gt;. Pen, shapes, laser pointer and auto-fade, over any app, and it can be recorded&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;🎯 &lt;strong&gt;Colour picker + ruler&lt;/strong&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;Ctrl+Alt+P&lt;/code&gt;. Magnifier, HEX/RGB copy, pixel distances and angles&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;🎞️ &lt;strong&gt;Video editor&lt;/strong&gt;
&lt;/td&gt;
&lt;td&gt;Trim, split, join, speed, reverse, rotate, looks, GIF export&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;🔤 &lt;strong&gt;OCR + pins&lt;/strong&gt;
&lt;/td&gt;
&lt;td&gt;Copy text from any screenshot, pin an image on top of every window&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;👉 &lt;a href="https://github.com/Akhouri-Systems/ASNIPP/releases/download/v1.0.0/ASNIPP_v1.zip" rel="noopener noreferrer"&gt;&lt;strong&gt;Download ASNIPP v1 (zip)&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you're learning how Python behaves &lt;em&gt;outside&lt;/em&gt; a notebook, run it, press &lt;code&gt;Win+Shift+S&lt;/code&gt;, and then ask yourself what is happening between your keypress and the screen. That is the fastest way I know to level up.&lt;/p&gt;




&lt;p&gt;Try ASNIPP_v1:&lt;a href="https://github.com/Akhouri-Systems/ASNIPP/releases/download/v1.0.0/ASNIPP_v1.zip" rel="noopener noreferrer"&gt;https://github.com/Akhouri-Systems/ASNIPP/releases/download/v1.0.0/ASNIPP_v1.zip&lt;/a&gt;&lt;br&gt;
not just try it, break it too.&lt;br&gt;
I want feedbacks because feedbacks would make ASNIPP_v2 better.&lt;/p&gt;

&lt;h2&gt;
  
  
  Your score
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;0-2 tests known:&lt;/strong&gt; You're a Python &lt;em&gt;developer&lt;/em&gt;. Great start. Now write something that has to talk to the OS.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;3-5:&lt;/strong&gt; Solid. You've shipped something real.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;6-8:&lt;/strong&gt; You're a Python &lt;em&gt;expert&lt;/em&gt;. Come argue with me in the comments.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Which test did you fail first?&lt;/strong&gt; Mine was Test 2: a recording that looked perfect until the first long silence, then slowly drifted out of sync. I lost two evenings to it. Tell me yours below 👇&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
