Urgent.News

What's breaking now, across thousands of outlets.

Tech

Hitting an image size ceiling with Rust and WebAssembly

Many image tools expose a quality slider. Forms and government portals usually expose a different requirement: “the file must be under 100 KB.” Those are not the same problem. A quality value is an encoder input. A byte ceiling is a constraint on the output, and the relationship between the two depends on the pixels, dimensions, color profile, output format, and encoder. I wanted a HEIC converter…

Hitting an image size ceiling with Rust and WebAssembly involves finding a balance between image quality and file size. Many image tools offer a quality slider, while forms and government portals require the file to be under a certain size, such as 100 KB. These are different problems that need to be addressed separately. The relationship between quality and byte size depends on various factors like pixels, dimensions, color profile, output format, and encoder.

The goal is to create a HEIC converter that meets a simple invariant: output_bytes = target_kb * 1024. The implementation is performed in the browser using Rust compiled to WebAssembly. The design choices that matter include decoding the HEIC image once and keeping a bounded image object, defining a precise size as a ceiling, and adjusting the search quality for JPEG images based on quality before dimensions.

JPEG encoding is more straightforward since the encoded size is ordered by quality, allowing for binary search within a protected quality interval. If the initial quality doesn't meet the target, the algorithm can skip further probes and resize the image instead. For PNG, the compression level and filter choices do not provide a clean monotonic control over output size, so dimensions are used as the practical lever instead.

The conversion path is kept separate from compression, ensuring that the output size is not mistakenly labeled as "convert" when shrinking a photo to meet a size constraint.

The final WebAssembly contract provides metadata about the output, including bytes, MIME type, extension, input and output dimensions, JPEG quality or null for PNG, encoding and resize passes. This keeps the UI code out of the compression algorithm, allowing for a cleaner and more focused implementation. The test suite includes a repository-owned phone photo and checks several targets for both JPEG and PNG, ensuring that the output bytes never exceed the target, JPEG quality never falls below the floor, dimensions are positive and preserve orientation, ICC data survives, and encoding and resize pass counts remain bounded.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Also reported by 1 other outlet

Read the original at dev.to →

More in Tech

Moving image work into the browser took that bill to zero

For about two months last year I had a habit: check the API usage graph before anything else in the morning. Not because traffic was flattering — because every time that line went up I had to work out…

  • Moved image processing to users' browsers to eliminate API costs
  • Services like background removal, AI upscaling, and PDF processing ran locally
  • Site became free, unmetered, but limited by free service constraints

I sell social media automation. My survey says people want the opposite.

I work at Publora — an API and MCP for publishing to social networks from one place, including through an AI agent. So, in a sense, my job is selling automation for posting.

  • Survey reveals people want control over final posting step in social media automation
  • AI use limited to ideation or time constraints, not for publishing
  • Human involvement valued for security, personal touch, and content approval

OAuth Consent Phishing: The Attack a Password Change Does Not Fix

The FBI's Internet Crime Complaint Center published PSA I-090126 on September 1, 2026, and it describes an attack that quietly defeats the two things most people rely on: changing your password, and…

  • Phishing attack bypasses password changes and MFA
  • Users unknowingly grant app permission during OAuth flow
  • Damage undone by removing consent grant, not password

How I Run 114 Posts, 98 Tools and 32 Games on Firebase Blaze for $0 a Month

Firebase's Blaze plan has a reputation problem. People hear "pay as you go", picture the horror stories — the recursive Cloud Function that wrote back into the collection that triggered it, the…

  • Site runs on Firebase Blaze plan with $0 monthly bill
  • Powers 114 blog posts, 98 tools, and 32 games
  • Utilizes Firestore and Cloud Storage for functionality

More from Thursday 3 September →