SPIF – Streaming Progressive Image Format
fhtr.org
fhtr.org
There's a version of this using a directory of images and loads in a bigger picture if you zoom in: http://fhtr.org/multires/ (Note that, yes, it'd be better to have a tile map for large resolutions and load in just the visible part of the image. And dump the hi-res tiles when zoomed out.)
SPIF's intention was to throw out a "it'd be cool if browsers supported something like this natively"-proposal, as the browser knows best what pixels of an image are needed for sharp rendering. For the webdev, the experience would be to just put the image on a page, rest assured that it looks good. Like with SVG.
Yes, loading JPEG2000 / progressive JPEG with stream truncation would be nice.
Images don't load on iOS? Probably some silly bug in my code.
Images can't be saved with right-click? That's probably due to using revokeObjectURL after loading the image from a blob.
[1]: http://flif.info/
So you can cram lossy 20x compression ratio JPEGs into Multires, optimized for each resolution. Or you could put a simplified SVG for low-res use, and detailed one for zoomed-in detail. Or hack it a bit and use Multires for loading the right-resolution video for your page. The format is just a container that tells the browser where to find the assets for each resolution.
FLIF is a lossless bitmap image encoder with progressive resolution enhancement.
TL;DR FLIF is PNG++, Multires is automatic srcset.
The problem is in software/hardware support, particularly in browsers. JPEG has a lot of momentum. WebP is only supported in Chrome/Opera (https://caniuse.com/#feat=webp) and IE/Android don't even support animated PNG yet (https://caniuse.com/#feat=apng).
I did loads of research on this for a web app dev book, which I'm currently updating for the second edition. Browser image support hasn't changed much since it was originally published.
> The SPIF format starts with a header that tells the offsets and sizes of the images in the SPIF. The images are stored smallest first, but there are no image size restrictions apart from that.
So... two HTTP requests per image load? That is probably going to hurt more than it helps. Also, that probably means a Range request, which don't have great support. (For example, the builtin Python http server SimpleHTTPServer doesn't support them.)
https://imageoptim.com/progressiveblurdemo.html
it's only a limitation of libjpeg that smoothing of early progressive scans is weak and incomplete, and thus looks very blocky. I wish browsers improved implementation of this.
Partially loaded DCT coefficients correspond quite well to maximum possible image resolution, so it is known how much cross-block smoothing needs to be applied to get nearly-optimal smooth preview. There's even an implementation of that idea:
- Right click -> View Image, Save Image, or Copy Link doesn't seem to work. This might be an issue with Firefox, because the blob is stored somewhere.
- No direct linking is possible, so I can't drop a link to the image into a chatroom.
- Zooming in page with Ctrl+Plus doesn't increase the resolution of the downsized image.
I'd rather download the original image, even if it takes more time/bandwidth, if these issues aren't fixed. And the CPU usage scares me a bit, if you multiply this by ~100 images, which is very common on news websites.
However, this method is better than embedding the full 7360 x 4912 image at least. It took 0.8s for the page to load in my browser and 6.0s to download the test.spif image.
I wonder if there is a way to use a progressive JPEG in a normal <img> tag (so it displays progressively rather than once it has finished loading) and use Javascript to halt the download once a certain amount has downloaded.
I wonder if it would be a good idea to revive plugins - back in the day we used object tags with links to the plugin to install to render the media. Maybe something similar can be done today with a link to some js that does the rendering. So you can have an img tag with mime type image/x-spif and a link to a js (or in the future, web assembly) handler in case there is no native support.
Web browsers are basically operating systems now. We should be working towards letting people safely install extensions.
And does it work with current browsers? https://ericportis.com/posts/2014/resolution-progressive-jpe...
It's a shame JPEG2000 never took off, probably due to the patent issues. It has a niche in medical imaging though.
I wrote my thesis on this topic, over a decade ago now. When doing image recognition you only need to read the first small part of a JPEG2000 file to get good results, which has obvious advantages. You can ignore the high detail bits at the end.
Why not go a step further and have a server dynamically scale the image based on the size the image will be displayed at, so it's always displayed pixel for pixel and there's no waste? Anyone tried that?
However, the approach given in the linked project is actually much better, because
- It works with only a single file, not one for every resolution. The latter makes CDNs useless with increasing number of possible resolutions
- On-the-fly-resizing is slow
- A streaming solution could just continue to read at the point it previously stopped if anything changes, such as the user clicking on a thumbnail to see the full image
- It also allows to make the stopping decision at a later point. Currently, a browser may have only loaded the first few lines of a html page when it has to decide which of the available sizes for the image it wants to load. If it can wait a bit longer, it has better data about, for example, the network speed to the server and the layout of the page.
This solves the abuse issue while providing the same freedom for image sizes.
Edit: Also we use aws lambda for image resizing so scaling is not an issue and generated images are cached on s3. Storage is cheap.
it would be for me, anyways