# Imagesize (bits and bytes) after processing

**URL:** <https://discourse.gohugo.io/t/imagesize-bits-and-bytes-after-processing/33575>\
**Category:** support\
**Created:** [June 27, 2021, 12:26pm UTC](https://discourse.gohugo.io/t/imagesize-bits-and-bytes-after-processing/33575 "2021-06-27T12:26:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [June 27, 2021, 12:26pm UTC](https://discourse.gohugo.io/t/imagesize-bits-and-bytes-after-processing/33575/1 "2021-06-27T12:26:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pointyfar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pointyfar/32/5797_2.png) [@pointyfar](https://discourse.gohugo.io/u/pointyfar)\
**Post date:** [June 27, 2021, 12:44pm UTC](https://discourse.gohugo.io/t/imagesize-bits-and-bytes-after-processing/33575/2 "2021-06-27T12:44:25Z")

</div>

Would `len` work? [Image processing: get size in MB](https://discourse.gohugo.io/t/image-processing-get-size-in-mb/28522)

---

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [June 27, 2021, 12:54pm UTC](https://discourse.gohugo.io/t/imagesize-bits-and-bytes-after-processing/33575/3 "2021-06-27T12:54:23Z")

</div>

The knowledge of `img.Content` would have helped already. Let me check where the documentation hides this parameter 🙂

---

<div class="post-metadata">

**Author:** ![regis](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/regis/32/4958_2.png) [@regis](https://discourse.gohugo.io/u/regis)\
**Post date:** [June 27, 2021, 2:18pm UTC](https://discourse.gohugo.io/t/imagesize-bits-and-bytes-after-processing/33575/4 "2021-06-27T14:18:29Z")

</div>

I would be very curious to knwo if you found an answer. We’re playing a lot with Hugo transformations on [GitHub - theNewDynamic/hugo-module-tnd-media: A catch-all solution for handling media in your Hugo project](https://github.com/theNewDynamic/hugo-module-tnd-media) and the more we know about the final transformed asset the better.
