I have a little “do it once and then forget” project where I create (currently only) page-bundle based image tags with “all the formats modern browsers love”, as in webp and such. Now currently it outputs webp preferred and if the browser supports webp then it displays this image. There are cases though, where the webp version is larger than the jpeg or png version of an image. Let’s not discuss the underlying issues here, let’s concentrate on the other problem:
How can I know the file size of a processed image in my partial or shortcode? After resizing, filtering, type-assigning. Is there a way to get the amount of bytes that this image requires and decide some form of order based on all image versions and their file sizes?
I am pretty sure I saw this happening somewhere, but I can’t find it in the documentation.