Urgent.News

What's breaking now, across thousands of outlets.

Tech

My screenshots were smaller as PNG-8 than JPEG, and my photos were 3.8x bigger

For my final-year project I added a small "compress before upload" step, and I gave it exactly one setting: re-encode everything as JPEG at quality 80. Photos came out fine. Screenshots did not. Text picked up a grey haze around every character, and the files were bigger than I expected for such simple images. So I flipped it and tried saving photos as 256-colour PNG instead, which made them…

For my final-year project, I added a compression step before uploading, encoding everything as JPEG at quality 80. Photos came out fine, but screenshots did not. Text became hazy around every character, and the files were larger than expected. So, I switched to 256-colour PNG, which made the images much larger. By measuring four images, I discovered why these discrepancies occurred.

First, screenshots fail the idea that lossy means smaller. A Chinese meeting-notes page with 174 distinct colours was 313,983 bytes as a lossless PNG, 123,658 bytes as JPEG quality 60, and 164,265 bytes at quality 80. As a palette PNG, it was only 116,231 bytes, smaller than both JPEGs and identical pixel for pixel. The palette PNG stores up to 256 colours, then one index per pixel, compressing those indices losslessly.

If the image only has 174 colours, nothing needs approximation. Large white areas and text colours also result in long runs of the same index, making it good for lossless compression. With 87.9% of pixels having the same colour as their right-hand neighbour, the table screenshot was 58,317 bytes as a palette PNG versus 111,650 bytes as JPEG quality 80.

However, JPEG works by splitting images into 8x8 blocks and storing each block as frequency components. Sharp black-on-white edges result in high-frequency components, leaving ripples around the text. JPEG also stores colour at half resolution, causing halos around coloured status badges. WebP at quality 80 performed better, with less noise and slightly soft glyph edges, but it's still lossy.

For photos, the palette runs out quickly. The lake photo has 119,846 distinct colours, making the 256-colour palette PNG 447,369 bytes, while JPEG quality 80 was 117,320 bytes, making it 3.8 times larger. The fruit stall was 2.5 times larger as a palette PNG. Only 7.4% of the lake's pixels matched their right neighbour, so the lossless stage had little repetition to work with.

Size was not the only issue; without dithering, the smooth cloud gradient turned into visible bands, while with dithering, the bands broke up into fine grain that appeared fuzzy up close. JPEG quality 80 did not show these banding issues.

In conclusion, photos with many colours and large smooth gradients band when compressed. Tools like ImgIng (https://imging.ai/) use heuristics to guess image types and apply appropriate compression. My project now counts colours before deciding: 256 or fewer go to palette PNG, everything else to WebP. However, this cutoff threshold is crude, and a better one may be needed.

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

This story

This is one outlet's version. Read the fullest account.

Read the original at dev.to →

More in Tech

Understanding XML Namespaces and How to Remove Them Safely

XML namespaces are a mess to remove. One wrong regex and you break the entire document structure. You leave orphaned colons. You accidentally strip actual data.

  • XML namespaces prevent naming conflicts by adding unique prefixes to elements with the same name.
  • Namespaces can become cumbersome, introducing long prefixed tags that hinder data processing.

I Stopped Telling Users to "Just Convert It" — Now the Browser Does It

Every developer who has ever built an upload form knows this support ticket: "I uploaded my photo but your site says it's broken." Nine times out of ten, the file is fine — it's the format .

  • Users often submit unsupported file formats like HEIC, WebP, or large PNGs.
  • Browser-based ConvertTool handles various file types without installation.
  • Browser converters update server-side, ensuring latest format support.

How we ship a native macOS client for classic MU Online Season 6 (Zenaria x40)

MU Online is a Windows-only game from the early 2000s. On a Mac people have usually tried CrossOver (CodeWeavers lists MU as "Installs, Will Not Run") or a Windows VM in Parallels, which tends to lag…

  • Native macOS client developed for Zenaria Season 6 (MU Online)
  • Rendering system uses SDL GPU with Metal on macOS
  • Client app is 14 MB .dmg, downloads game data separately

Endpoint Incident Response & Forensics Playbook

You see a high-severity EDR detection, an elevated account used off-hours, or rapid file modifications on a user laptop. The SOC is noisy, the desktop owner is anxious, and the evidence you need…

  • Follow repeatable remote-triage loop to confirm alerts and scope incident
  • Preserve blast radius by stopping lateral movement vectors first
  • Use surgical containment over binary in Windows/Linux environments

More from Saturday 17 October →