Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Canvas toBlob Explained: Exporting Images Without a Server Round-Trip

Canvas toBlob Explained: Exporting Images Without a Server Round-Trip In browser image processing, the moment that decides whether your tool is private or not is the export. You can load, crop and filter an image entirely on the client — but if you then POST the result to a server to be encoded, the file leaves the user's device anyway. canvas.toBlob() is the standard way to avoid that. It turns…

The "canvas.toBlob()" method is a powerful browser API that allows image processing to occur entirely on the user's device without sending the image to a server. This eliminates network latency and potential privacy concerns associated with uploading the image to a remote server. The method works by converting the canvas element containing the processed image into a Blob object, which can then be used to create a download link, write to the user's file system, or perform other local operations.

To use canvas.toBlob(), you first need to transform an image into a canvas context using `createImageBitmap()` after loading it with `FileReader` or similar methods. The quality parameter of toBlob() affects only lossy formats like JPEG and WebP, where a value between 0.7 and 0.9 usually yields the best results without noticeable artifacts. PNG images, being lossless, do not benefit from a quality parameter.

However, developers should be aware of the limitations. The memory usage is the main constraint, as the entire image is decoded into memory for processing. Browser-specific maximum canvas sizes may also impose practical limits on image dimensions. Metadata such as EXIF data is lost when drawing to the canvas, so it needs to be handled separately if needed. Lastly, not all browsers support AVIF encoding via toBlob(), so feature detection is essential when providing export options.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

Same product, two bios. Which one belongs on the project page?

“I'm building PasteCharm, a tool for making profile bios.” That line makes sense under my name. Move it to the PasteCharm project page and it sounds like I forgot whose profile I was editing.

  • "PasteCharm" is a tool for editing profile bios
  • Project page headline should read "PasteCharm - A tool for making profile bios"
  • Intro paragraph should highlight key actions: pick a template, edit, copy

Drizzle D1 Workflow: Local Migrations That Match Prod

The same SQLite schema, three apply paths, and a seed command that silently picks production when you forget one variable. The Problem You want to reset staging with fresh roles.

  • Drizzle D1 workflow aims to match production migrations for local staging databases.
  • Three initial attempts to fix the issue fail due to misconfiguration and ownership conflicts.
  • Proposed solution checks SEEDREMOTE and target, requiring SEEDENV for remote seeds.

11,932 WordPress plugin vulnerabilities in 12 months. One in six has no fix

“Keep your plugins updated” is the advice every WordPress site owner has heard. We counted what that advice actually covers, and what it does not.

  • 11,932 WordPress plugin vulnerabilities documented in 12 months
  • One in six vulnerabilities lack a fix, 2,026 plugins vulnerable
  • 44% of vulnerabilities exploitable without any account

Your Logistics Data Pipeline Is Already Built — In 2027, Buyers Will Pay to License What It Produces

Your logistics data pipeline — the one joining dispatch records to ELD/telematics logs, maintenance history, and safety events — is producing a licensable dataset every day, whether anyone at your…

  • Logistics data pipeline generates licensable dataset without buyer acknowledgment.
  • Companies licensed dispatch, ELD, maintenance, and safety records for $355k-$1.23M.
  • Buyers seek relationship between dispatch, vehicle data, maintenance, and safety events.

More from Tuesday 24 November →