SShortSingh.
Back to feed

Why Browser AVIF Converters Inflate File Size and How Binary Search with PNG-8 Fixes It

0
·2 views

Developers building client-side image converters with canvas.toBlob() often find that converting a small AVIF file to JPG or PNG produces a much larger output. AVIF uses AV1 compression, which is far more space-efficient than JPEG or uncompressed PNG, so re-encoding the decoded pixels in a legacy format expands the data considerably. A 60 KB AVIF photo can become roughly 160 KB as a JPG or over 280 KB as a PNG, which leads users to assume the converter is malfunctioning. The author describes a two-part TypeScript solution that uses a binary search over quality settings and switches to PNG-8 palette output to curb this bloat. The approach runs entirely in the browser, so no images are uploaded to a server.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Kleinanzeigen's Internal AI Assistant Kara Teaches Lessons in Context Engineering

Kleinanzeigen.de's Developer Experience team built Kara, an internal AI knowledge assistant in Slack powered by Retrieval-Augmented Generation, to help staff find information scattered across repositories, wikis, and documents. The tool reached about 150 monthly active users, with operational content such as the incident management process being among the most referenced. The team found that using AI to summarize documents before indexing reduced retrieval quality because it discarded details people later needed, so they switched to preserving source material and chunking it carefully. They also learned that a user's natural-language question often needs rewriting into a separate retrieval query, since phrasing can noticeably affect results. The experience showed that a correct retrieval step does not guarantee a correct final answer.

0
ProgrammingDEV Community ·

Separating Job, Run, and Worker Claim Identities in a Requeue Design

A follow-up tutorial revisits a job queue example whose completion table treated job_id as a primary key, which blocked requeueing. Reproducing the issue showed that manually reopening a completed job let a worker claim it, but the second completion insert collided and rolled back. The author proposes modeling three distinct identities: the job, a run requested for that job, and the worker claim within a run. Retrying an existing run is treated as different from requesting a new run, even when the inputs look similar. The code therefore persists a new run ID, records its parent run, and only advances the job's current run if the expected predecessor is completed.

0
ProgrammingDEV Community ·

OpenAI and Cisco open-source Shirudo, an eBPF tool for live Linux exploit mitigation

OpenAI and Cisco have released Shirudo as open source, a Linux runtime that loads small, cryptographically signed eBPF programs, called shields, to block vulnerable code paths without restarting a host or service. In a public test, a shield generated with Codex stopped a Java4Shell exploit against a live Elasticsearch instance. Shields are distributed as signed files from an OCI registry, checked by the eBPF verifier and TPM-backed measurements, and can run in observe-only mode before enforcement. The project is a rewrite of Tetragon aimed at faster, agent-driven response, and it remains pre-release, requiring a patched kernel and TPM 2.0.

0
ProgrammingDEV Community ·

Kubernetes Events: How to Read, Retain and Alert on Them

Kubernetes events act as the cluster's logbook, recording causes such as failed image pulls, failed probes and memory shortages, but they disappear quickly. Each event carries an involved object, a machine-readable reason, a message, and a Normal or Warning type, and the documentation warns that new types may appear. By default the kube-apiserver keeps events for only one hour, controlled by the --event-ttl flag, which managed services may not let users change. Teams that need to diagnose overnight incidents must therefore export events elsewhere, starting from the filtering they already do manually, such as keeping Warning events. The article points to the OpenTelemetry Collector's k8s_events receiver, which is still in alpha stability, as one way to ship them as logs.