Hadn't heard of JPEG XL until you mentioned it. The format looks really cool! Support for lossless and lossy compression, animation, and tons of other new features
Preliminary support in Firefox and Chromium nightly/testing builds already. I share your hope that we can start to use it in the next couple years. Looking at you, Safari ;)
One thing I've wondered about are size savings for DEM tiles. Typically elevation values are encoded in RGB values giving a resolution down to fractions of an inch [1]. This seems like overkill. With an elevation range from 0 - 8848 meters (Mt everest), you can use just 2 bytes and get an accuracy down to .2 meters. That seems plenty for many uses. Does anybody know if there's a PNG16 format where you can reduce the file size by only using 2 bytes per pixel, instead of the typical 3-byte RGB or 4-byte RGBA?
Not my area of expertise, but in my limited experience DEM tiles are usually GeoTIFF. This can be 16bit greyscale. The catch is that these are actually signed... Elevation doesn't start at 0meters bc you have locations below sea level and you need to handle those corner cases somehow
What's funny is that you can parse a GeoTIFF as a .tiff most of the time but not always. I had fun debugging that :). Java's BufferedImage understandably doesn't directly support negative pixel values haha
The PNG format already allows grayscale 16bits / channel images. I regularly use this when rendering out depth maps from blender and ffmpeg seems to handle reading from these PNGs just fine (detecting the gray16 pixel format).
However I don’t know of any DEM tile apis that provide these sorts of PNGs but it sounds like a fun project!
Not exactly the same, but I did some work a while back retrofitting 8bit pngs as DEMs with non-linear elevation profiles (in the days when Mapbox only supported 8bit dem uploads). This allowed for fine detail in the range I was most interested in and coarser detail elsewhere. I was also working below sea level, so the standard models weren't suitable. I used gdal and node for the encode to PNG (from high res geotiffs) and then leant on mapbox expressions for the custom decode on the front end. Looked cool and file size was reasonable. Tho I'm certain much cooler things are now possible with 16 bit encode and the new terrain API.
If file size is your worry and accuracy not, maybe use a lossy format for tiles like JPG or JP2 rather than PNG?
Worth noting DEMs are moving away from tiled formats recently. Mainly to COG (Cloud Optimised Geotiff) which isn't the most efficient but is a simple tweak to a file format already broadly adopted. There's a few others out there aiming for efficency at scale too - ESRI has CRF and MRF for instance, but nothing has become industry standard other than COG yet.
> Instead of serving a 256x256px image, you can serve a 1px image and tell the browser to scale it up. Of course, if you have to put width= "256px" height= "256px" into your HTML that adds 30 bytes to your HTML!
CSS is a thing as well, could just use CSS to force all tiles to the same size, regardless of the image data in them. Something like:
Was new to me, but it seems "slippy map" is open-streetmap's terminology for a generic zoomable-pannable web map view, here used to refer to any such UI - whether backed by OSM or google or bing or whoever's map data.
Feels like a weird word choice to me, when 'map' was right there, but who are we to judge.
This is a very old term used to try to describe the Google Maps interface to people who never used an octree multidirectional scrolling and zooming image collection.
View the map a single tile at a time, no dragging the map, no moving by less than a tile, no zooming with the mousewheel, every move and zoom a full pageload.
(You'll also notice the older maps are much higher contrast than Google Maps - the older maps being modelled on printed paper maps)
I love image formats and data packing, but was disappointed that the reveal was that maps use raster tiles. The map data is vector, why not render it as such?
A lot of rendering is vector based these days and uses webgl to do it but there are still a lot of tile servers using images as well. This article is from 2015. Vector maps were less common then and webgl was a lot less mature.
For example maplibre is a great option for rendering vector based openstreet maps from e.g. maptiler or mapbox. They can tilt the maps, render buildings in 3D, have step less zooming, etc.
Some of the newer map tile formats are vectors instead of raster. But technology hasn't quite caught up with that yet. And some things are still better are rasters (like overlaying satellite/aerial imagery).
I mean, you could. Not a browser author or map maker but thinking it out loud.
This would be a 'rectangle color' specific. Probably 24 bytes to represent height, width, color? It seems like a Herculean effort to attempt to get browser support for such a thing, for a phenomenally rare use case. It would need to be an image format probably and not a browser implementation, since they're usually arranged around other images. And all for saving some 60 bytes per square.
To be clear I'm not saying it's a bad idea - I'm all for it. It just seems like a pretty edge use case(large blobs of single color images such as oceans in cartoon maps).
i thought so too, but is it actually the case? it's a bit more js code but if pack all your js files there's one less http header. then it's cached. for the image you got the initial size + header (roughly 500 bytes), then it's cached all the same. so, if the additional js gz'd is smaller than 100 bytes of png + gz(400 bytes for the header) it might pay off.
Yeah I wonder why that isn't used... I can even remove the src from the image and add "background-color: #aad3de" and it looks exactly the same. I'd imagine it's also slightly faster and less memory intensive to render a static background color than to copy the data from an image.
I'm actually surprised they even use DOM nodes for this. Last I checked Google Maps uses a totally custom WebGL based renderer (since it supports 3D and such).
I think they don’t want the tile server API have to think about what planet it’s on and where said planet has its oceans. So every tile has to have a valid image associated with it.
This is one example where "zopfli" or other optimized zlib compressors don't help, the input data is too simple.
"oxipng" (my current preferred png optimizer) bring a plain 256x256 image created with imagemagick down to 179 bytes, as long as you tell it to strip all metadata objects.
Interlacing doesn't make any difference, it's the same size with it on or off.
The png is only 103 bytes though. Btw your svg can be decreased by changing viewBox to 0 0 1 1, and also by changing the path to a circle (implicitly positioned at 0, 0)
<svg xmlns="dear user agent, if you happen to run into a problem resolving ambiguities with any of the following tags, please use the namespace for Scalable Vector Graphics and not, say, one of the zero other contexts that xml ninjas will no doubt create over the next two decades of what I can only surmise will be a glorious outpouring of richness and complexity. I mean, we went to the trouble of creating a dang URL for the thing, so it's the least you could do. That is, aside from doing nothing, in which case Hixie will probably write a parser to just handle it. Best wishes, W3C. P.S. Cannot wait to see all the Javascript-driven SVG content that users will upload to social media. Look out, animated gif-- your days are numbered!"><path d="animateYourSVGArcFlagsFTW" /></svg>
gzip compressed (binary) pbm is only 56 bytes; 32 bytes for zstd compressed data. PBMs have a very simple header and no footer, so the file is almost entirely all zeroes.
Web browsers do not support pbm, last time I checked. On the other hand, the JPEG-XL rollout is well underway (e.g. Chrome supports it behind a feature flag).
Retr0id|3 years ago
https://cdn.discordapp.com/attachments/286612533757083648/96...
Although technically invalid, it still renders fine in Firefox, Chrome, and Safari.Edit: 87 -> 83 bytes
Edit2: Maybe in a couple of years time, we can use JPEG-XL instead (only 22 bytes, without any hacks!):
doomlaser|3 years ago
https://en.wikipedia.org/wiki/JPEG_XL
Preliminary support in Firefox and Chromium nightly/testing builds already. I share your hope that we can start to use it in the next couple years. Looking at you, Safari ;)
dchest|3 years ago
WebP is 38 bytes, and is already supported by browsers.
Maybe can be made smaller, I just used cwebp -z 9.vmception|3 years ago
When I learned HTML the syntax was sooo particular.
Now (our pretty much since then) anything goes and I love it
Natural evolution of protocols
yread|3 years ago
47 49 46 38 39 61 01 00 01 00
00 ff 00 2c 00 00 00 00 01 00
01 00 00 02 00 3b
http://probablyprogramming.com/2009/03/15/the-tiniest-gif-ev...
thrdbndndn|3 years ago
unknown|3 years ago
[deleted]
tppiotrowski|3 years ago
[1] https://docs.mapbox.com/data/tilesets/guides/access-elevatio...
geokon|3 years ago
What's funny is that you can parse a GeoTIFF as a .tiff most of the time but not always. I had fun debugging that :). Java's BufferedImage understandably doesn't directly support negative pixel values haha
tristanc|3 years ago
However I don’t know of any DEM tile apis that provide these sorts of PNGs but it sounds like a fun project!
Edit: I found this StackExchange post which shows how to generate 16-bit PNGs with gdal https://gis.stackexchange.com/questions/246934/translating-g...
somishere|3 years ago
Edit: a link to a mapbox-gl-js discussion on the use of custom dems/encodings (after which anything is possible): https://github.com/mapbox/mapbox-gl-js/issues/10775
twelvechairs|3 years ago
Worth noting DEMs are moving away from tiled formats recently. Mainly to COG (Cloud Optimised Geotiff) which isn't the most efficient but is a simple tweak to a file format already broadly adopted. There's a few others out there aiming for efficency at scale too - ESRI has CRF and MRF for instance, but nothing has become industry standard other than COG yet.
danielheath|3 years ago
Retr0id|3 years ago
rekoil|3 years ago
CSS is a thing as well, could just use CSS to force all tiles to the same size, regardless of the image data in them. Something like:
jameshart|3 years ago
Feels like a weird word choice to me, when 'map' was right there, but who are we to judge.
th0ma5|3 years ago
michaelt|3 years ago
View the map a single tile at a time, no dragging the map, no moving by less than a tile, no zooming with the mousewheel, every move and zoom a full pageload.
(You'll also notice the older maps are much higher contrast than Google Maps - the older maps being modelled on printed paper maps)
willis936|3 years ago
WesolyKubeczek|3 years ago
There’s another challenge: you need to provide more and more data as you zoom in, wonder how that should work with vector stuff.
jillesvangurp|3 years ago
For example maplibre is a great option for rendering vector based openstreet maps from e.g. maptiler or mapbox. They can tilt the maps, render buildings in 3D, have step less zooming, etc.
jleedev|3 years ago
And produces this geometry before reprojecting to the tile coordinates:
But of course, this doesn't specify a color, just "the ocean is a rectangle".tecleandor|3 years ago
Android application OsmAnd is notoriously slow because of this: https://github.com/osmandapp/OsmAnd/discussions/11961
chipsa|3 years ago
adam_arthur|3 years ago
Assuming this level of optimization is actually warranted
silisili|3 years ago
This would be a 'rectangle color' specific. Probably 24 bytes to represent height, width, color? It seems like a Herculean effort to attempt to get browser support for such a thing, for a phenomenally rare use case. It would need to be an image format probably and not a browser implementation, since they're usually arranged around other images. And all for saving some 60 bytes per square.
To be clear I'm not saying it's a bad idea - I'm all for it. It just seems like a pretty edge use case(large blobs of single color images such as oceans in cartoon maps).
stefs|3 years ago
blenderdt|3 years ago
OSM needs 54TB for all tiles but only around 1.8% are viewed. So you need at least 1TB of cache.
I am curious if this micro optimalization really makes a difference.
carstenhag|3 years ago
3OCSzk|3 years ago
moron4hire|3 years ago
cyral|3 years ago
I'm actually surprised they even use DOM nodes for this. Last I checked Google Maps uses a totally custom WebGL based renderer (since it supports 3D and such).
Tabular-Iceberg|3 years ago
Lammy|3 years ago
LeoPanthera|3 years ago
"oxipng" (my current preferred png optimizer) bring a plain 256x256 image created with imagemagick down to 179 bytes, as long as you tell it to strip all metadata objects.
Interlacing doesn't make any difference, it's the same size with it on or off.
edflsafoiewq|3 years ago
softgrow|3 years ago
For OpenStreetMap 136 bytes
<svg xmlns="http://www.w3.org/2000/svg" width="256" height="256" viewBox="0 0 256 256"><path d="M0 0h256v256H0z" fill="#aad3df"/></svg>
im3w1l|3 years ago
lostgame|3 years ago
Also - pardon my ignorance, this may be a dumb question, is SVG universally supported in browsers these days? I’m not big up on image standards.
softgrow|3 years ago
<svg width="256" height="256"><rect width="100%" height="100%" fill="#aad3df" /></svg>
jancsika|3 years ago
validuser|3 years ago
creativenolo|3 years ago
dingdingdang|3 years ago
unknown|3 years ago
[deleted]
aidenn0|3 years ago
Retr0id|3 years ago
The image is only 22 bytes as a jxl:
https://cdn.discordapp.com/attachments/286612533757083648/96...
base64 data uri version:
meerita|3 years ago
schappim|3 years ago
[1] https://files.littlebird.com.au/Shared-Image-2022-04-22-17-5...