There are several compression algorithms out there some achieve better results than others in different images. I am not sure exactly what your question wants to know as you mix Java and C# with image compression.
Recently enough google developers have released a new format called WebP. They claim this format can deliver 26% smaller lossless images when compared with PNG's and lossy even better when compared to JPEG however the support for WebP is still quite limited.
What you can do is make use of the picture HTML element and deliver an alternative WebP with a fallback to a PNG or JPEF file.
here's an example:
<picture>
<source srcset="img/awesomeWebPImage.webp" type="image/webp">
<source srcset="img/creakyOldJPEG.jpg" type="image/jpeg">
<img src="img/creakyOldJPEG.jpg" alt="Alt Text!">
</picture>
Here's a good article on using WebP: https://css-tricks.com/using-webp-images/