[Geoserver-devel] How to commit a new WMS image output format - WebP?

Hi, I’m Martin and I’m new to Geoserver.

I have written a class to support WebP as a new WMS image output format. This works as expected and reduces the file size by about one third compared to a JPEG. Since an alpha channel is also supported, the reduction compared to a PNG is about two thirds.

All modern browsers now support WebP, for older browsers a fallback mechanism would have to be implemented on the client side.

The implementation is based on com.github.nintha webp-imageio-core which is not part of the GeoServer Maven repository. What is the right way to include the dependency?

Unfortunately not all platforms are supported as native DLLs are used.

What is the right way to include the code in this case? Would an extension be better then?

Best regards,

Martin

Hi,
thanks a lot for reaching out and contributing to the GeoServer development. A WebP addition is quite interesting.

Can you elaborate a bit more of how the webp support is provided? That IMHO is going to be a driver to decide where to put the webp support.
We have a precedent for native code embedded in GeoServer: both OSHI and the SQLite drivers rely on native code, and they are part of core, but with a few good features:

  • Widely used, normally rock solid (I haven’t heard of reports of GeoServer segfaulting due to bugs in the native parts of those libraries)
  • The native portion is embedded in the jars (no extra installation needed) and covers a wide variety of operating systems and architectures, making them basically as cross platform as Java is
    If the WebP libraries provide any reason to doubt either stability, or are limited to a small number of platforms, or require manual installations of native libraries, then I’d start with a community module, which you can then graduate to extension later down the road.

Cheers
Andrea

···

Regards,

Andrea Aime

==
GeoServer Professional Services from the experts!

Visit http://bit.ly/gs-services-us for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions Group
phone: +39 0584 962313

fax: +39 0584 1660272

mob: +39 339 8844549

https://www.geosolutionsgroup.com/

http://twitter.com/geosolutions_it


Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia.

This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail

Hi Andrea,

Thanks for the quick answer.

Unfortunately, I don’t think this meets the criteria.
Definitely this is not widespread.

I will have a look at the community modules.

Best regards,

Martin

···

Am 20.12.2022 um 18:10 schrieb Andrea Aime:

Hi,
thanks a lot for reaching out and contributing to the GeoServer development. A WebP addition is quite interesting.

Can you elaborate a bit more of how the webp support is provided? That IMHO is going to be a driver to decide where to put the webp support.
We have a precedent for native code embedded in GeoServer: both OSHI and the SQLite drivers rely on native code, and they are part of core, but with a few good features:

  • Widely used, normally rock solid (I haven’t heard of reports of GeoServer segfaulting due to bugs in the native parts of those libraries)
  • The native portion is embedded in the jars (no extra installation needed) and covers a wide variety of operating systems and architectures, making them basically as cross platform as Java is
    If the WebP libraries provide any reason to doubt either stability, or are limited to a small number of platforms, or require manual installations of native libraries, then I’d start with a community module, which you can then graduate to extension later down the road.

Cheers
Andrea

On Tue, Dec 20, 2022 at 4:27 PM OpenDEM <contact@anonymised.com> wrote:

Hi, I’m Martin and I’m new to Geoserver.

I have written a class to support WebP as a new WMS image output format. This works as expected and reduces the file size by about one third compared to a JPEG. Since an alpha channel is also supported, the reduction compared to a PNG is about two thirds.

All modern browsers now support WebP, for older browsers a fallback mechanism would have to be implemented on the client side.

The implementation is based on com.github.nintha webp-imageio-core which is not part of the GeoServer Maven repository. What is the right way to include the dependency?

Unfortunately not all platforms are supported as native DLLs are used.

What is the right way to include the code in this case? Would an extension be better then?

Best regards,

Martin


Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

Regards,

Andrea Aime

== GeoServer Professional Services from the experts!

Visit http://bit.ly/gs-services-us for more information. == Ing. Andrea Aime @geowolf Technical Lead

GeoSolutions Group phone: +39 0584 962313

fax: +39 0584 1660272

mob: +39 339 8844549

https://www.geosolutionsgroup.com/

http://twitter.com/geosolutions_it


Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia. This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail

Hi,
the developer guide has some indication about what to do for a community module:
https://docs.geoserver.org/latest/en/developer/policies/community-modules.html

If you want something more practical, see this PR, it’s a simple new community module being added:
https://github.com/geoserver/geoserver/commit/5576a457b30e1570a03be81f1b52239e2e9b6635

And oh, here is my +1 on adding the module, so you’re out of the initial red tape and can get on coding.

Cheers
Andrea

···

Regards,

Andrea Aime

==
GeoServer Professional Services from the experts!

Visit http://bit.ly/gs-services-us for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions Group
phone: +39 0584 962313

fax: +39 0584 1660272

mob: +39 339 8844549

https://www.geosolutionsgroup.com/

http://twitter.com/geosolutions_it


Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia.

This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail

Hi Andrea,

Unfortunately, all the advantages of the WebP format regarding file size are negated by slow and energy-consuming processing.
Only in exceptional cases where a slow internet connection < 500 kbit is given (e.g. slow G3) this format makes sense.
The increased processing time correlates with increased energy consumption.

Measured with a commercial power meter on a local PC for one hour (multiple times).

Stack: Windows10, Java11, Tomcat9, Chrome Browser, OpenLayers Client, random WMS GetMap requests every 0.5 seconds

PNG 0.067 kWh vs. 0.071 kWh WebP vs. NoRequests 0.047 kWh.

This also applies to the JPEG format in a weakened way.
I will add this to the doc and readme files.
However, the WebP format could serve as an input format for the GWC and then play out the advantages again. I would like to tackle this next.

Best regards,

Martin

···

Am 21.01.2023 um 13:38 schrieb Andrea Aime:

Hi Martin,
you don’t need commit access, make a Pull Request instead:
https://github.com/geoserver/geoserver/pulls

For a community module, the review for the PR will be minimal, basically just checking it’s not breaking anything else.
Commit access will be proposed down the line, but basically no one makes direct code changes, outside of emergency
situations: the write access is nowadays basically the same as a right to review and merge a PR.

Cheers
Andrea

Il sab 21 gen 2023, 09:05 OpenDEM <contact@anonymised.com> ha scritto:

Hi Andrea,

I just signed the agreement.

Can you please give me write permissions?

Thanks,

Martin

Am 21.12.2022 um 10:49 schrieb Andrea Aime:

Hi,
the developer guide has some indication about what to do for a community module:
https://docs.geoserver.org/latest/en/developer/policies/community-modules.html

If you want something more practical, see this PR, it’s a simple new community module being added:
https://github.com/geoserver/geoserver/commit/5576a457b30e1570a03be81f1b52239e2e9b6635

And oh, here is my +1 on adding the module, so you’re out of the initial red tape and can get on coding.

Cheers
Andrea

On Tue, Dec 20, 2022 at 8:16 PM OpenDEM <contact@anonymised.com> wrote:

Hi Andrea,

Thanks for the quick answer.

Unfortunately, I don’t think this meets the criteria.
Definitely this is not widespread.

I will have a look at the community modules.

Best regards,

Martin

Am 20.12.2022 um 18:10 schrieb Andrea Aime:

Hi,
thanks a lot for reaching out and contributing to the GeoServer development. A WebP addition is quite interesting.

Can you elaborate a bit more of how the webp support is provided? That IMHO is going to be a driver to decide where to put the webp support.
We have a precedent for native code embedded in GeoServer: both OSHI and the SQLite drivers rely on native code, and they are part of core, but with a few good features:

  • Widely used, normally rock solid (I haven’t heard of reports of GeoServer segfaulting due to bugs in the native parts of those libraries)
  • The native portion is embedded in the jars (no extra installation needed) and covers a wide variety of operating systems and architectures, making them basically as cross platform as Java is
    If the WebP libraries provide any reason to doubt either stability, or are limited to a small number of platforms, or require manual installations of native libraries, then I’d start with a community module, which you can then graduate to extension later down the road.

Cheers
Andrea

On Tue, Dec 20, 2022 at 4:27 PM OpenDEM <contact@anonymised.com> wrote:

Hi, I’m Martin and I’m new to Geoserver.

I have written a class to support WebP as a new WMS image output format. This works as expected and reduces the file size by about one third compared to a JPEG. Since an alpha channel is also supported, the reduction compared to a PNG is about two thirds.

All modern browsers now support WebP, for older browsers a fallback mechanism would have to be implemented on the client side.

The implementation is based on com.github.nintha webp-imageio-core which is not part of the GeoServer Maven repository. What is the right way to include the dependency?

Unfortunately not all platforms are supported as native DLLs are used.

What is the right way to include the code in this case? Would an extension be better then?

Best regards,

Martin


Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

Regards,

Andrea Aime

== GeoServer Professional Services from the experts!

Visit http://bit.ly/gs-services-us for more information. == Ing. Andrea Aime @geowolf Technical Lead

GeoSolutions Group phone: +39 0584 962313

fax: +39 0584 1660272

mob: +39 339 8844549

https://www.geosolutionsgroup.com/

http://twitter.com/geosolutions_it


Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia. This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail

Regards,

Andrea Aime

== GeoServer Professional Services from the experts!

Visit http://bit.ly/gs-services-us for more information. == Ing. Andrea Aime @geowolf Technical Lead

GeoSolutions Group phone: +39 0584 962313

fax: +39 0584 1660272

mob: +39 339 8844549

https://www.geosolutionsgroup.com/

http://twitter.com/geosolutions_it


Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia. This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail

Hi Andrea,

Unfortunately, all the advantages of the WebP format regarding file size are negated by slow and energy-consuming processing.
Only in exceptional cases where a slow internet connection < 500 kbit is given (e.g. slow G3) this format makes sense.
The increased processing time correlates with increased energy consumption.

Measured with a commercial power meter on a local PC for one hour (multiple times).

Stack: Windows10, Java11, Tomcat9, Chrome Browser, OpenLayers Client, random WMS GetMap requests every 0.5 seconds

PNG 0.067 kWh vs. 0.071 kWh WebP vs. NoRequests 0.047 kWh.

The difference is small enough that you might overcome PNG by adopting the data extraction tricks
I pointed at in the PR, which we are currently using for the PNGJ output. In particular, check if the input image
is a BufferedImage, and if so, use getRaster() method instead of getData(): the latter is forced, by contract,
to return a deep copy of all the pixel values, while getRaster() provides the actual data buffer used by the image.
Also, try to identify cases where you can just do a System.arrayCopy or simply use the original byte, rather
than copying values around.
This will require changes into the Java webp library.

However, the WebP format could serve as an input format for the GWC and then play out the advantages again. I would like to tackle this next.

Makes sense, cached images are produced once and sent over the network multiple times, so the higher
energy cost of production is offsetted by the lower network transmission cost.

Cheers
Andrea

···

Regards,

Andrea Aime

==
GeoServer Professional Services from the experts!

Visit http://bit.ly/gs-services-us for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions Group
phone: +39 0584 962313

fax: +39 0584 1660272

mob: +39 339 8844549

https://www.geosolutionsgroup.com/

http://twitter.com/geosolutions_it


Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia.

This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail

Hi Andrea,

Here is an answer from the Google WebP team:

That’s a very good question actually! The short answer is that WebP achieves better compression rates than jpeg/png by being more complex, and the cost of this complexity is that it’s slower, particularly at encoding.

https://groups.google.com/a/webmproject.org/g/webp-discuss/c/Ad6rXupeWZ4

Disadvantages of the WebP format had been added to the documentation.

I have not been able to achieve any improvement.

I think GWC would be the right way.

Best regards,

Martin

···

Am 06.02.2023 um 10:41 schrieb Andrea Aime:

On Sat, Feb 4, 2023 at 4:15 PM OpenDEM <contact@anonymised.com> wrote:

Hi Andrea,

Unfortunately, all the advantages of the WebP format regarding file size are negated by slow and energy-consuming processing.
Only in exceptional cases where a slow internet connection < 500 kbit is given (e.g. slow G3) this format makes sense.
The increased processing time correlates with increased energy consumption.

Measured with a commercial power meter on a local PC for one hour (multiple times).

Stack: Windows10, Java11, Tomcat9, Chrome Browser, OpenLayers Client, random WMS GetMap requests every 0.5 seconds

PNG 0.067 kWh vs. 0.071 kWh WebP vs. NoRequests 0.047 kWh.

The difference is small enough that you might overcome PNG by adopting the data extraction tricks
I pointed at in the PR, which we are currently using for the PNGJ output. In particular, check if the input image
is a BufferedImage, and if so, use getRaster() method instead of getData(): the latter is forced, by contract,
to return a deep copy of all the pixel values, while getRaster() provides the actual data buffer used by the image.
Also, try to identify cases where you can just do a System.arrayCopy or simply use the original byte, rather
than copying values around.
This will require changes into the Java webp library.

However, the WebP format could serve as an input format for the GWC and then play out the advantages again. I would like to tackle this next.

Makes sense, cached images are produced once and sent over the network multiple times, so the higher
energy cost of production is offsetted by the lower network transmission cost.

Cheers
Andrea

Regards,

Andrea Aime

== GeoServer Professional Services from the experts!

Visit http://bit.ly/gs-services-us for more information. == Ing. Andrea Aime @geowolf Technical Lead

GeoSolutions Group phone: +39 0584 962313

fax: +39 0584 1660272

mob: +39 339 8844549

https://www.geosolutionsgroup.com/

http://twitter.com/geosolutions_it


Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia. This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail