# Get File Size of a Image

**URL:** <https://community.glideapps.com/t/get-file-size-of-a-image/74684>\
**Category:** Ask for Help\
**Created:** [July 7, 2024, 10:14pm UTC](https://community.glideapps.com/t/get-file-size-of-a-image/74684 "2024-07-07T22:14:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![miogamer](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/miogamer/32/62928_2.png) [@miogamer](https://community.glideapps.com/u/miogamer)\
**Post date:** [July 7, 2024, 10:14pm UTC](https://community.glideapps.com/t/get-file-size-of-a-image/74684/1 "2024-07-07T22:14:54Z")

</div>

Hey i wanted to know if there is a way or a column to get the file size of a Image inside a table?

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [July 7, 2024, 11:18pm UTC](https://community.glideapps.com/t/get-file-size-of-a-image/74684/2 "2024-07-07T23:18:44Z")

</div>

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/d/a/dad7e567b7578ea6edb69946c81ba4e29d671236.png)

I have it working here with a close number to what I see on my Macbook.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/8/5/851cca43be123a22b894621770de9bad40523d70.png)

```auto
async function getImageFileSize(imageUrl) {
  try {
    const fileImg = await fetch(imageUrl).then(r => r.blob());
    const sizeInMB = fileImg.size / (1024 * 1024);
    
    if (sizeInMB < 1) {
      // If less than 1 MB, represent in KB
      const sizeInKB = fileImg.size / 1024;
      return sizeInKB.toFixed(2) + " KB";
    } else {
      // If 1 MB or larger, represent in MB
      return sizeInMB.toFixed(2) + " MB";
    }
  } catch (error) {
    console.error('Error fetching image:', error);
    throw error;
  }
}

return getImageFileSize(p1)

```

---

<div class="post-metadata">

**Author:** ![miogamer](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/miogamer/32/62928_2.png) [@miogamer](https://community.glideapps.com/u/miogamer)\
**Post date:** [July 11, 2024, 10:07pm UTC](https://community.glideapps.com/t/get-file-size-of-a-image/74684/3 "2024-07-11T22:07:13Z")

</div>

Thank you

---

<div class="post-metadata">

**Author:** ![vras\_dinand](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/vras_dinand/32/64071_2.png) [@vras\_dinand](https://community.glideapps.com/u/vras_dinand)\
**Post date:** [July 12, 2024, 3:36am UTC](https://community.glideapps.com/t/get-file-size-of-a-image/74684/4 "2024-07-12T03:36:39Z")

</div>

Awesome For Thiss

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/system/32/53398_2.png) [@system](https://community.glideapps.com/u/system)\
**Post date:** [July 19, 2024, 3:36am UTC](https://community.glideapps.com/t/get-file-size-of-a-image/74684/5 "2024-07-19T03:36:58Z")

</div>

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