How to reduce the file size of large background images by over 93%
peterhrynkow.com
peterhrynkow.com
Why is this on the front page?
There is also a way to have a size reduction for somewhat intricate backgrounds: background-repeat.
Don't repost too much, read the part of the FAQ about reposts https://news.ycombinator.com/newsfaq.html
If you repost too much the mods may notice and ban your account, your site and other nasty stuff.
Also, try to stick to the original title https://news.ycombinator.com/newsguidelines.html
---
About this post: I think it would have been better to use another title like "How to use browser interpolation to reduce smooth mage size by 93%". The current title is misleading.
I think the general idea is safe enough -- images of gradients are probably going to look fine upscaled in any algo that would actually get shipped. But there's no guarantee that tomorrow Mozilla won't decide their new mission statement is to spread the gospel of nearest neighbor.
Mesh gradients were slotted for SVG 2.0 but the feature has since been removed from the roadmap.
http://libregraphicsworld.org/blog/entry/gradient-meshes-and...
That said: Sorry if you only found this out in 2019.
Which is great if you have an astoundingly blurry image, and useless if you don't.
1. use only smooth gradients for your background (LOL)
2. remove most of your pixels
3. assume that the browser will interpolate for you (Also LOL)
If this had been called "pictures of smooth gradients don't need to be high res if your viewer interpolates them sufficiently well" then it would be accurate and sound a lot less noobish.
- Simple horizontal, vertical, or radial gradients can rarely capture the "organic" look that most designers want (the gradients of real materials and scenes are highly uneven so perfect symmetry has a distinctly artificial appearance).
- I'm not sure if it's actually an aspect of the spec, but all implementations I've seen interpolate the colors in RGB or an RGB-like colorspace. This can have the effect of creating dramatic jumps or ridges. With a lot of trial and error (or color math) you can overcome this by using custom stop values, but it's much simpler and more in-line with a designer's toolset to be using colorspaces whose linear interpolations are more perceptually uniform.
Of course there's also the "standard drawback" of modern webdev too: it's often easier to just throw assets at the problem. :/
(Thoughts from a design-adjacent dev.)
Embedded gradient images for use in emails for clients without CSS gradient support, possibly.
In this specific case I can see why layered CSS gradients would be non-trivial to assemble, but it’s a trade off.
Example: https://stackoverflow.com/questions/14926189/creating-a-grad...
about 3: most browsers have a good interpolation method for smooth images. It's a safe assumption if you have time to read all the documentation and you drop the support for IE6. (Perhaps IE6 can also interpolate correctly. I don't know and I'm not going to try to find the docs. IIRC I once had problems with the autostretching of the background image in IE6.)
In practice, I receive one of those from clients. Of course there are more options
This person also knows very little about web browsers. Warning: Do not follow their advice when making your website.
> When the small image is enlarged, the browser uses an interpolation algorithm to fill in the missing image data.
"the browser". Hah. As if there's just one.