Open saschanaz opened 7 years ago
The current metadata does not contain this information. There have been proposals to add a metadata chunk specifically for this purpose (see https://github.com/FLIF-hub/FLIF/blob/master/doc/metadata#L36), but unless we make it obligatory, it will only work if people actually add that chunk.
The problem with the above approach is that it requires an extra request just to load the information on how many bytes to request. The only way to avoid that is to put that information in the HTML in some way. One way to do it (theoretically) with currently available mechanisms is as follows:
<img src="image.flif" srcset="image.flif?truncate=12345 300w, image.flif?truncate=34567 600w">
where you would need a web server that parses these ?truncate=NNN
query strings and simply returns a truncated version of the requested file. If some convention can be agreed upon, it could also be the browser who parses that, so they can request the indicated number of bytes (and if a resize/zoom in happens, it could be smart enough to see it's the same file so it doesn't need to request the first part again when loading the higher res image). This would be a nice way to add the functionality with graceful degradation. CDNs could also be made smart enough to understand the truncation offsets so they only have to cache one file.
Of course you would need some automated way to inject these truncation offsets into the HTML --
this is why I added the --breakpoints
option to the flif utility, since that would be the main thing you need for that.
This approach would also be useful for progressive JPEGs by the way.
I have been thought that FLIF can introduce
<picture>
-like behavior on traditional<img>
element if a browser can access byte offset information of a FLIF image.My expectation:
I need a way to get byte offsets to do this, is this a possible scenario?