Image processing: get size in MB

Dear experts,

Sometimes when I shrink an image I end up increasing it’s size (that is in MBs). This is probably due to the quality factor of the image being worse then the one the resizer uses. I know I can lower this, but I do not want to.

Is there some way to query the size of the resized images? I am thinking of simply not using the resized version if it is not smaller than the original.

Thank you!

The best I can think of is:

{{ sizeInBytes := len $img.Content }}
2 Likes

Thank you bep! This looks like an interesting idea. I wonder about the efficiency however. Hopefully it wont kill my nice build times :slight_smile:

This ended up working very nicely. Thanks again!

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.