# Extract image dimensions automatically

**URL:** <https://talk.jekyllrb.com/t/extract-image-dimensions-automatically/1296>\
**Category:** Help\
**Created:** [December 26, 2017, 2:44am UTC](https://talk.jekyllrb.com/t/extract-image-dimensions-automatically/1296 "2017-12-26T02:44:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdelarioja](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/mdelarioja/32/619_2.png) [@mdelarioja](https://talk.jekyllrb.com/u/mdelarioja)\
**Post date:** [December 26, 2017, 2:44am UTC](https://talk.jekyllrb.com/t/extract-image-dimensions-automatically/1296/1 "2017-12-26T02:44:20Z")

</div>

Is there a way to get an image’s width and height automatically in jekyll? I’m using photoswipe, which requires declaring the images dimensions to work. Closest solution I have found so far is [this](http://benwilhelm.com/the-website/nerd-stuff/2014/12/21/building-an-image-heavy-jekyll-site/), but was wondering if there is another/better way.

---

<div class="post-metadata">

**Author:** ![mmistakes](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/mmistakes/32/2169_2.png) [@mmistakes](https://talk.jekyllrb.com/u/mmistakes)\
**Post date:** [December 26, 2017, 4:22am UTC](https://talk.jekyllrb.com/t/extract-image-dimensions-automatically/1296/2 "2017-12-26T04:22:42Z")

</div>

If you can install Jekyll plugins, I believe [jekyll-assets](https://github.com/envygeeks/jekyll-assets) can spit out the width/height of an image.

---

<div class="post-metadata">

**Author:** ![mdelarioja](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/mdelarioja/32/619_2.png) [@mdelarioja](https://talk.jekyllrb.com/u/mdelarioja)\
**Post date:** [December 26, 2017, 4:32am UTC](https://talk.jekyllrb.com/t/extract-image-dimensions-automatically/1296/3 "2017-12-26T04:32:22Z")

</div>

Yes, I can install plugins. I looked into jekyll-assets a while back, but all the references to image dimensions I found were for a fairly old version, and using the supplied syntax did not work. Not sure if this feature was removed with version 3.

---

<div class="post-metadata">

**Author:** ![jhvanderschee](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/jhvanderschee/32/583_2.png) [@jhvanderschee](https://talk.jekyllrb.com/u/jhvanderschee)\
**Post date:** [December 26, 2017, 11:32am UTC](https://talk.jekyllrb.com/t/extract-image-dimensions-automatically/1296/4 "2017-12-26T11:32:24Z")

</div>

You can force image resizing, using [images.weserv.nl](http://images.weserv.nl). It can solve all your image problems. 🙂
