# A faster way of getting image size from jpg files?

**URL:** <https://discourse.julialang.org/t/a-faster-way-of-getting-image-size-from-jpg-files/65760>\
**Category:** New to Julia\
**Tags:** images, performance\
**Created:** [August 3, 2021, 8:31pm UTC](https://discourse.julialang.org/t/a-faster-way-of-getting-image-size-from-jpg-files/65760 "2021-08-03T20:31:16Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![stillyslalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stillyslalom/32/45687_2.png) [@stillyslalom](https://discourse.julialang.org/u/stillyslalom)\
**Post date:** [August 3, 2021, 9:05pm UTC](https://discourse.julialang.org/t/a-faster-way-of-getting-image-size-from-jpg-files/65760/4 "2021-08-03T21:05:49Z")

</div>

I think PIL is loading the images lazily ([ref](https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.open)):

> This is a lazy operation; this function identifies the file, but the file remains open and the actual image data is not read from the file until you try to process the data (or call the [`load()`](https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.load) method).

PIL is probably identifying the image size from the jpeg header, avoiding the need to load the entire image. You could probably do the same thing via LibJpeg along the lines of this post: [Get DCT coefficients of jpeg image - #5 by stevengj](https://discourse.julialang.org/t/get-dct-coefficients-of-jpeg-image/64640/5)

---

_[View the full topic](https://discourse.julialang.org/t/a-faster-way-of-getting-image-size-from-jpg-files/65760)._
