<?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: key</title>
    <description>The latest articles on DEV Community by key (@key_50873f70444a287c83617).</description>
    <link>https://dev.to/key_50873f70444a287c83617</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%2F4264472%2F3c40ff0c-5a7b-40b0-819b-07c637279d63.png</url>
      <title>DEV Community: key</title>
      <link>https://dev.to/key_50873f70444a287c83617</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/key_50873f70444a287c83617"/>
    <language>en</language>
    <item>
      <title>Browser-Local Image Compression Without Uploading: Alpha-Safe PNG Quantization, Exact KB Targeting, and When to Split into PSD</title>
      <dc:creator>key</dc:creator>
      <pubDate>Sat, 05 Dec 2026 08:16:18 +0000</pubDate>
      <link>https://dev.to/key_50873f70444a287c83617/browser-local-image-compression-without-uploading-alpha-safe-png-quantization-exact-kb-targeting-2kbi</link>
      <guid>https://dev.to/key_50873f70444a287c83617/browser-local-image-compression-without-uploading-alpha-safe-png-quantization-exact-kb-targeting-2kbi</guid>
      <description>&lt;p&gt;Most web workflows that touch images end up bouncing between three fragile steps: editing a flat graphic you lost the source file for, fixing a typo baked into a poster or screenshot, and squeezing the final PNG/WebP under an upload or Core Web Vitals budget.&lt;/p&gt;

&lt;p&gt;When we added a client-side compression tool to &lt;a href="https://free-ai-image-editor.com/" rel="noopener noreferrer"&gt;Free AI Image Editor&lt;/a&gt;, we noticed three recurring bugs in typical "free online image compressors":&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Silent server uploads&lt;/strong&gt; — many tools upload client assets, invoices, or unreleased UI mockups to remote servers just to run basic canvas encoding.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Broken PNG transparency&lt;/strong&gt; — some compressors quietly convert transparent PNGs into opaque JPEGs or fail to shrink alpha graphics at all.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;File size inflation&lt;/strong&gt; — re-encoding an already optimized PNG or JPEG at a default quality slider often produces a &lt;em&gt;larger&lt;/em&gt; file than the original.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here is how we structured a 100% browser-local compression pipeline—and where local pixel processing ends and layered PSD decomposition begins.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjbo6411z80m3toc6zbg7.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjbo6411z80m3toc6zbg7.webp" alt="Before and after browser-local image compression comparison" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Keeping Transparent PNGs Actually Transparent (and Smaller)
&lt;/h2&gt;

&lt;p&gt;Browser &lt;code&gt;&amp;lt;canvas&amp;gt;.toBlob("image/png")&lt;/code&gt; only writes full 32-bit lossless PNGs. If you drop a 1.2 MB transparent UI screenshot or logo into a naive canvas compressor, the output is frequently 1.2 MB–1.8 MB—zero savings or even bigger.&lt;/p&gt;

&lt;p&gt;To genuinely shrink PNGs locally without stripping transparency:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Use true indexed-color quantization&lt;/strong&gt; (such as &lt;code&gt;UPNG.js&lt;/code&gt;) that preserves the full alpha channel instead of flattening onto a white background.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep a strict "Original kept" guard&lt;/strong&gt;: compare &lt;code&gt;outputBlob.size&lt;/code&gt; against &lt;code&gt;originalFile.size&lt;/code&gt; before accepting the result. If the original is already tighter at the chosen format and dimensions, return the original untouched rather than shipping a bloated re-encode.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Check byte signatures carefully for modern formats&lt;/strong&gt;: iPhone HEIC files and AVIF files share ISO BMFF containers (&lt;code&gt;ftyp&lt;/code&gt; brands like &lt;code&gt;mif1&lt;/code&gt;). Always check AVIF vs. HEIC container brands in the right order before handing off to a local WASM/JS HEIC decoder so AVIF inputs aren't misrouted.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  2. Hitting an Exact Max File Size (KB) Without Guessing Sliders
&lt;/h2&gt;

&lt;p&gt;Real-world forms (job portals, app stores, marketplaces, CMS upload caps) rarely ask for "75% quality"—they ask for &lt;strong&gt;"under 100 KB"&lt;/strong&gt; or &lt;strong&gt;"under 500 KB"&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A naive binary search over quality &lt;code&gt;1..100&lt;/code&gt; works smoothly for JPEG and WebP, where output size rises monotonically with quality. Lossless/quantized PNGs break that assumption at the top edge (&lt;code&gt;q = 100&lt;/code&gt;), so a reliable client-side target-size loop needs three details:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Probe &lt;code&gt;q = 100&lt;/code&gt; first&lt;/strong&gt;: if the max-quality output already fits inside the KB cap, return immediately—no unnecessary quality loss.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Binary search &lt;code&gt;[1, 99]&lt;/code&gt;&lt;/strong&gt;: find the highest quality that still fits under the byte limit.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Optional dimension fallback ("Shrink dimensions if needed")&lt;/strong&gt;: if even &lt;code&gt;q = 1&lt;/code&gt; at full resolution (say, a &lt;code&gt;4000 × 3000&lt;/code&gt; photo targeting &lt;code&gt;100 KB&lt;/code&gt;) exceeds the cap, step down max dimensions cleanly (e.g., up to 4 passes down to a safe floor like &lt;code&gt;256 px&lt;/code&gt;) and re-run the quality search. If the cap is physically unreachable, surface the closest achieved size transparently instead of failing silently.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  3. Preventing Browser Tab Crashes on Batch Runs
&lt;/h2&gt;

&lt;p&gt;Mobile Safari and low-RAM laptops crash fast if a user drops 20 high-res photos and the app decodes all 20 bitmaps concurrently.&lt;/p&gt;

&lt;p&gt;Two simple rules keep batch compression rock-solid:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Cap concurrency to 2 active jobs&lt;/strong&gt; across batches via a shared coordinator queue, invalidating stale jobs immediately when a user drags a slider.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Revoke &lt;code&gt;blob:&lt;/code&gt; object URLs deterministically&lt;/strong&gt; after React/DOM commits, and package batch downloads locally with &lt;code&gt;fflate&lt;/code&gt; into a single ZIP without ever touching a backend server.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Honest Limits of Browser-Local Compression
&lt;/h3&gt;

&lt;p&gt;Local browser execution isn't magic—it comes with clear boundaries worth knowing upfront:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Browser decode ceilings&lt;/strong&gt;: Canvas implementations cap total pixels (typically around &lt;code&gt;100 MP&lt;/code&gt; or &lt;code&gt;30,000 px&lt;/code&gt; on one edge).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;EXIF stripping on re-encode&lt;/strong&gt;: Canvas re-encoding strips camera EXIF metadata (which is actually good for privacy, though photographers who need embedded EXIF should keep originals).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No semantic edits&lt;/strong&gt;: Local encoders can resize and quantize pixels, but they cannot change printed copy or separate foreground objects from a flat background.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can test the full zero-upload pipeline (including interactive 1x/2x/4x split-screen comparison and batch ZIP export) directly in your browser on &lt;a href="https://free-ai-image-editor.com/image-compressor" rel="noopener noreferrer"&gt;Free AI Image Compressor&lt;/a&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. When You Need to Edit Before You Compress
&lt;/h2&gt;

&lt;p&gt;In practice, compression is the &lt;em&gt;last&lt;/em&gt; mile of an asset workflow. When someone hands you a flat PNG or JPG poster that needs changes before shipping to web, we split the upstream work by how much structural change is needed:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftc0nefx0ud8te3csmim8.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftc0nefx0ud8te3csmim8.webp" alt="Flat graphic split into 3D editable Photoshop layers" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Quick typo or price/date update on flat graphics&lt;/strong&gt;: Start with &lt;a href="https://free-ai-image-editor.com/edit-text-in-image" rel="noopener noreferrer"&gt;Edit Text in Image&lt;/a&gt;—client-side OCR locates printed text so you can edit copy, font style, and sampled ink colors locally for free, with an optional AI Style Match pass when lighting or warped perspectives need seamless blending.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Moving objects, hiding elements, or handing off to Photoshop&lt;/strong&gt;: Run the flat graphic through &lt;a href="https://free-ai-image-editor.com/image-to-psd" rel="noopener noreferrer"&gt;Image to PSD&lt;/a&gt; to separate foreground objects, reconstruct the background, reorder layers via drag-and-drop, and export a layered &lt;code&gt;.psd&lt;/code&gt; (or layer PNG ZIP) with native editable text layers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Targeted object swaps or background cleanups&lt;/strong&gt;: Use prompt-based local repainting and numbered region marks on the main &lt;a href="https://free-ai-image-editor.com/" rel="noopener noreferrer"&gt;Free AI Image Editor&lt;/a&gt; canvas (no sign-up or watermark for daily free standard edits).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once the graphic itself is right, a 2-second pass through the local &lt;a href="https://free-ai-image-editor.com/image-compressor" rel="noopener noreferrer"&gt;Image Compressor&lt;/a&gt; brings a 4 MB PNG down to a clean ~120 KB WebP or quantized transparent PNG—ready to deploy without leaking unpublished assets to a random upload server.&lt;/p&gt;

</description>
      <category>productivity</category>
    </item>
    <item>
      <title>How to Edit Printed Text and Split Flat Graphics into Layered Photoshop PSDs in the Browser</title>
      <dc:creator>key</dc:creator>
      <pubDate>Wed, 25 Nov 2026 10:11:11 +0000</pubDate>
      <link>https://dev.to/key_50873f70444a287c83617/how-to-edit-printed-text-and-split-flat-graphics-into-layered-photoshop-psds-in-the-browser-ef3</link>
      <guid>https://dev.to/key_50873f70444a287c83617/how-to-edit-printed-text-and-split-flat-graphics-into-layered-photoshop-psds-in-the-browser-ef3</guid>
      <description>&lt;p&gt;Most browser-based AI image editors treat every edit the same way: upload a PNG or JPG, type a prompt, and let a diffusion model regenerate the whole canvas. That works well for mood changes or background swaps, but it breaks down fast when you are working on posters, product banners, or UI mockups that contain readable text and structured layouts.&lt;/p&gt;

&lt;p&gt;When you ask a general image model to fix a single typo or swap a price tag on a poster, two things usually happen:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Unrelated faces, logos, or product edges subtly drift.&lt;/li&gt;
&lt;li&gt;Small text gets smeared or misspelled, forcing you to reopen Photoshop and rebuild the layout from scratch.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Over the past few months while building &lt;a href="https://free-ai-image-editor.com/" rel="noopener noreferrer"&gt;Free AI Image Editor&lt;/a&gt;, we split practical browser image editing into three distinct workflows instead of forcing every task through one prompt box.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. When On-Device Text Replacement Beats Generative AI
&lt;/h3&gt;

&lt;p&gt;If you only need to change horizontal printed text—such as updating a date, price, heading, or label on an existing graphic—you rarely want a generative model touching the pixels outside that text box.&lt;/p&gt;

&lt;p&gt;In our &lt;a href="https://free-ai-image-editor.com/edit-text-in-image" rel="noopener noreferrer"&gt;Edit Text in Image&lt;/a&gt; workflow:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Horizontal printed text regions are detected directly on-device in the browser.&lt;/li&gt;
&lt;li&gt;Only the target wording is replaced in place, leaving surrounding graphics untouched.&lt;/li&gt;
&lt;li&gt;You can export either a flat updated PNG or a layered &lt;code&gt;.psd&lt;/code&gt; with native editable text layers, completely free with no account required.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Honest limitations to keep in mind&lt;/strong&gt;: on-device detection works reliably on clean horizontal print and UI typography, while stylized curved calligraphy, heavy perspective warp, or tiny vertical labels still need manual cleanup in Photoshop.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Splitting Flat Graphics into Layered PSDs (Image to PSD)
&lt;/h3&gt;

&lt;p&gt;Sometimes you receive a flat JPG or PNG—an ad creative, event poster, or ecommerce hero image—and need to move objects independently, replace the background, or adjust typography inside Adobe Photoshop or Photopea.&lt;/p&gt;

&lt;p&gt;Our &lt;a href="https://free-ai-image-editor.com/image-to-psd" rel="noopener noreferrer"&gt;Image to PSD&lt;/a&gt; pipeline breaks a flat image into usable design layers:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Object &amp;amp; Foreground Separation&lt;/strong&gt;: isolates key subjects and graphic elements onto independent transparent layers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Background Reconstruction&lt;/strong&gt;: fills in occluded areas behind foreground elements so moving an object does not leave a blank cutout.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Native Editable Photoshop Text Layers&lt;/strong&gt;: converts recognised printed text into editable Photoshop type layers (plus in-browser inline text editing before download).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dual Export&lt;/strong&gt;: downloads both a layered &lt;code&gt;.psd&lt;/code&gt; file and a matching transparent PNG layer ZIP so teams without Photoshop can still use individual assets.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;What works well vs. what still needs a designer's touch&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Works well for clean product visuals, social banners, and standard marketing posters (5–20 layers).&lt;/li&gt;
&lt;li&gt;Complex overlapping limbs, heavy semi-transparent shadows, or custom brand fonts may still require quick mask touch-ups and font matching once opened in Photoshop.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Local Repaint and Numbered Marks for Targeted AI Edits
&lt;/h3&gt;

&lt;p&gt;When you actually &lt;em&gt;do&lt;/em&gt; want generative AI—removing an object, changing clothing colors, relighting a scene, or swapping a background—constraining the edit region prevents global drift:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Local Repaint&lt;/strong&gt;: brush over only the area that should change so the rest of the photo stays intact.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Numbered Mark Regions&lt;/strong&gt;: place numbered regions on the image and reference them directly in your prompt (e.g., change item 1 while removing item 2) instead of hoping the model guesses which object you meant.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Trying the Workflow Without a Login Wall
&lt;/h3&gt;

&lt;p&gt;If you want to test these three paths on your own files:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Homepage AI Editor&lt;/strong&gt; (&lt;a href="https://free-ai-image-editor.com/" rel="noopener noreferrer"&gt;free-ai-image-editor.com&lt;/a&gt;): 3 free standard 1K edits per UTC day, no sign-up required, no watermark on downloads.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;On-Device Text Editor&lt;/strong&gt; (&lt;a href="https://free-ai-image-editor.com/edit-text-in-image" rel="noopener noreferrer"&gt;/edit-text-in-image&lt;/a&gt;): 100% free in the browser, exports PNG or layered PSD.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Image to PSD&lt;/strong&gt; (&lt;a href="https://free-ai-image-editor.com/image-to-psd" rel="noopener noreferrer"&gt;/image-to-psd&lt;/a&gt;): every Google account includes one free 5-layer 1K split to inspect layer quality before deciding whether to use one-time credit packs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you've built similar browser-side PSD or OCR-to-layer pipelines—especially around handling complex fonts or alpha masks—I'd love to compare notes in the comments.&lt;/p&gt;

</description>
      <category>webdev</category>
    </item>
  </channel>
</rss>
