The global image optimization settings apply. You can apply them retroactively by optimizing attachments (gallery images are stored as attachments internally).
Arguably, we could have talked about this in our bumper Boosting performance entry but it wasn't quite ready to be shown at that point. (I started working on it this week and I haven't yet mastered the art of time travel).
Initially the scope of our WebP support in XenForo 2.3 was to merely allow users to upload WebP files and have them correctly displayed inline. This would have been a positive change on its own as the format becomes more prevalent across the web, but it doesn't really do much on its own to solve the issue of disk usage...
The short of it is you enable the "Optimize images" setting, and then go to Tools > Rebuild caches (admin.php?tools/rebuild) and use the "Optimize attachments" tool. If you have a lot of attachments, it can take a while to spin through all of them. It's worth being on the latest version of PHP as there were some GD bugs in PHP prior to 8.3.10 and 8.2.22.