index.rst 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. .. _webp_wms_output_format:
  2. WMS WebP output format
  3. ============================
  4. This module adds the `WebP <https://developers.google.com/speed/webp>`_ WMS output format.
  5. WMS GetMap Request: *FORMAT=image/webp*
  6. Advantages of the WebP image format compared to other formats:
  7. * | WebP lossy images are about 30% smaller than comparable JPEG images.
  8. * | WebP supports transparency, typically providing 3x smaller file sizes compared to PNG.
  9. * | WebP supports :ref:`paletted images <tutorials_palettedimages>`, typically providing 20% smaller file sizes compared to PNG.
  10. **Attention! Unfortunately, all the advantages of the WebP format regarding file size are negated by
  11. a more complex, time and energy-consuming processing.**
  12. **However, the WebP format could serve as an input format for the GWC and then play out the advantages again.
  13. Work is in progress.**
  14. **Read more about it here:** :ref:`WebP processing <webp_processing>`
  15. Only in exceptional cases where a slow internet connection is given (e.g. G3) this format makes sense.
  16. WebP is supported by all modern browsers (`caniuse <https://caniuse.com/webp>`_).
  17. However, backwards compatibility can be built in on the client side.
  18. Use `Google's recommended function <https://developers.google.com/speed/webp/faq#how_can_i_detect_browser_support_for_webp>`_ to detect with Javascript if the browser supports WebP.
  19. Be aware that the used image-loading is non-blocking and asynchronous. Any code that depends should preferably be put in the callback function.
  20. Example for `OpenLayers v7 <https://openlayers.org/>`_ WebP browser support check via javascript:
  21. .. code-block:: javascript
  22. ...
  23. import ImageLayer from 'ol/layer/Image';
  24. import ImageWMS from 'ol/source/ImageWMS';
  25. ...
  26. function check_webp_feature(feature, callback) {
  27. ... // code from google link above
  28. }
  29. check_webp_feature('lossless', function (feature, isSupported) {
  30. let wmsoutputformat = 'image/webp'
  31. if (!isSupported) {
  32. wmsoutputformat = 'image/png'
  33. }
  34. var wmsLayerSource = new ImageWMS({
  35. params: {'LAYERS': 'yourLayerName','FORMAT': wmsoutputformat},
  36. ...
  37. });
  38. ... // your OL code
  39. });
  40. Because native libraries are used, not all platforms are supported. For those supported, no additional native library needs to be installed though.
  41. The plugin is based on `Java ImageIO WebP support <https://github.com/gotson/webp-imageio>`_, here you can find further information.
  42. If your platform is not supported, there are `instructions for compiling the native library <https://github.com/gotson/webp-imageio#compiling>`_.
  43. In this case, do not forget to contribute.
  44. .. toctree::
  45. :maxdepth: 1
  46. installing
  47. webp_processing