# Image processing: get size in MB

**URL:** <https://discourse.gohugo.io/t/image-processing-get-size-in-mb/28522>\
**Category:** support\
**Created:** [September 26, 2020, 11:15pm UTC](https://discourse.gohugo.io/t/image-processing-get-size-in-mb/28522 "2020-09-26T23:15:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dr\_narval](https://avatars.discourse-cdn.com/v4/letter/d/90db22/32.png) [@dr\_narval](https://discourse.gohugo.io/u/dr_narval)\
**Post date:** [September 26, 2020, 11:15pm UTC](https://discourse.gohugo.io/t/image-processing-get-size-in-mb/28522/1 "2020-09-26T23:15:48Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [September 27, 2020, 6:27pm UTC](https://discourse.gohugo.io/t/image-processing-get-size-in-mb/28522/3 "2020-09-27T18:27:21Z")

</div>

> [@dr\_narval](#):
>
> Is there some way to query the size of the resized images?

The best I can think of is:

```auto
{{ sizeInBytes := len $img.Content }}

```

---

<div class="post-metadata">

**Author:** ![dr\_narval](https://avatars.discourse-cdn.com/v4/letter/d/90db22/32.png) [@dr\_narval](https://discourse.gohugo.io/u/dr_narval)\
**Post date:** [September 27, 2020, 11:52pm UTC](https://discourse.gohugo.io/t/image-processing-get-size-in-mb/28522/4 "2020-09-27T23:52:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dr\_narval](https://avatars.discourse-cdn.com/v4/letter/d/90db22/32.png) [@dr\_narval](https://discourse.gohugo.io/u/dr_narval)\
**Post date:** [October 1, 2020, 4:49pm UTC](https://discourse.gohugo.io/t/image-processing-get-size-in-mb/28522/5 "2020-10-01T16:49:32Z")

</div>

This ended up working very nicely. Thanks again!

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [October 3, 2020, 4:49pm UTC](https://discourse.gohugo.io/t/image-processing-get-size-in-mb/28522/6 "2020-10-03T16:49:33Z")

</div>

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