<?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: whyym</title>
    <description>The latest articles on DEV Community by whyym (@whyym).</description>
    <link>https://dev.to/whyym</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%2F4271981%2F7ed15390-704f-4233-812c-c9a81785baf1.png</url>
      <title>DEV Community: whyym</title>
      <link>https://dev.to/whyym</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/whyym"/>
    <language>en</language>
    <item>
      <title>Running image compression entirely in the browser: what actually breaks</title>
      <dc:creator>whyym</dc:creator>
      <pubDate>Sun, 29 Nov 2026 08:52:59 +0000</pubDate>
      <link>https://dev.to/whyym/running-image-compression-entirely-in-the-browser-what-actually-breaks-4117</link>
      <guid>https://dev.to/whyym/running-image-compression-entirely-in-the-browser-what-actually-breaks-4117</guid>
      <description>&lt;p&gt;Every "compress image" page asks you to upload a file. That is a strange default: the file is already on the device that has to display the result. So when we built Pane Tools, image compression had to run in the tab, with no server in the loop.This is what we learned, mostly from the failures.1. Canvas is the encoder, and it has a hard area ceilingThe whole pipeline is: decode → draw to canvas →canvas.toBlob('image/jpeg', quality)→ download the blob. On desktop this behaves predictably up to a few megapixels. On iOS Safari it does not: the canvas has anarea limit of roughly 16.7 million pixels(equivalent to 4096×4096). A 4032×3024 iPhone photo is 12.2 M pixels and survives. A 6000×4000 image is 24 M pixels and the canvas silently fails — you get a blank or truncated result, not an error.So "max dimension" is not a nice-to-have, it is the guard rail. We clamp the longest side before drawing, defaulting to 1600px for web use. That keeps a normal photo inside the limit without the user ever seeing a failure.2. Dimension beats quality for file size, but quality decides legibilityOur own copy says the max dimension is the stronger lever, and the numbers agree: halving the longest side cuts pixel count by 4×, while moving JPEG quality from 0.9 to 0.7 typically saves 30–50%. But for screenshots and text, quality is what keeps glyph edges from smearing. A 2 MB iPhone screenshot usually lands around 180 KB at 1600px and quality 0.8 with the text still crisp; drop quality to 0.5 and the text turns to mush while the file only shrinks a bit more.That is why the UI exposes both and reports the actual before/after sizes, rather than promising a number.3. Orientation metadata is a trapPhone photos carry EXIF orientation. Draw the raw bitmap and sideways photos come out sideways — the classic "I compressed it and now it is rotated" bug. We read orientation and rotate during decode. It costs almost nothing and removes an entire class of complaints.4. Memory, not CPU, is the real limitCompression itself is fast (a 12 M pixel JPEG re-encode is well under a second on a mid-range phone). What kills the tab is holding three copies of the bitmap: the decoded source, the canvas buffer, and the output blob. On a 512 MB Android device, doing three photos in parallel triggers the tab-killer. So we process files sequentially, revoke the object URL after download, and cap batch sizes rather than fan out.5. No upload means no server cost, which changes the productThere is no queue, no per-minute limit, no account. The trade-off is that we cannot fix a user's file after the fact — everything has to work in one pass on hardware we cannot see.We shipped it as one of 24 tools on the site, all with the same rule: the file never leaves the browser.If you want to see the behaviour rather than read about it:&lt;a href="https://pane.tools/tools/compress-image" rel="noopener noreferrer"&gt;https://pane.tools/tools/compress-image&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>performance</category>
      <category>compression</category>
    </item>
  </channel>
</rss>
