# FlexImage - retrieving width / height

**URL:** <https://discuss.rubyonrails.org/t/fleximage-retrieving-width-height/26638>\
**Category:** rubyonrails-talk\
**Created:** [March 21, 2008, 6:09am UTC](https://discuss.rubyonrails.org/t/fleximage-retrieving-width-height/26638 "2008-03-21T06:09:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Drehmer](https://avatars.discourse-cdn.com/v4/letter/d/90db22/32.png) [@Daniel\_Drehmer](https://discuss.rubyonrails.org/u/Daniel_Drehmer)\
**Post date:** [March 21, 2008, 6:09am UTC](https://discuss.rubyonrails.org/t/fleximage-retrieving-width-height/26638/1 "2008-03-21T06:09:37Z")

</div>

Hello everyone.

I'm trying to find out if it's possible to tell fleximage to performe some tasks before storing the image on the filesystem (or database).

I alredy know it's possible to scale down the image before storing it... But i'm wondering if it's possible to either store the width and height of an image in the image bank so I can use this data in post processing, or if I can't retrieve it to use in my logic before the storage.

If I can't do it with fleximage, can anyone tell me how could I get the width or height of an image using RMagick?

Thank you very much.

---

<div class="post-metadata">

**Author:** ![Daniel\_Drehmer](https://avatars.discourse-cdn.com/v4/letter/d/90db22/32.png) [@Daniel\_Drehmer](https://discuss.rubyonrails.org/u/Daniel_Drehmer)\
**Post date:** [March 21, 2008, 6:12am UTC](https://discuss.rubyonrails.org/t/fleximage-retrieving-width-height/26638/2 "2008-03-21T06:12:28Z")

</div>

\*Correction: when I said "image bank" on the message above I was willing to say DataBase (or blob field to be more specific)

---

<div class="post-metadata">

**Author:** ![Long](https://avatars.discourse-cdn.com/v4/letter/l/e47774/32.png) [@Long](https://discuss.rubyonrails.org/u/Long)\
**Post date:** [March 21, 2008, 5:05pm UTC](https://discuss.rubyonrails.org/t/fleximage-retrieving-width-height/26638/3 "2008-03-21T17:05:40Z")

</div>

In ImageMagick one can use identify with the -format option to get width and height info. RMagick is based on ImageMagick so there must be a corresponding API.

hth,

-- Long [http://FATdrive.tv/wall/trakb/10-Long](http://FATdrive.tv/wall/trakb/10-Long)[http://FATdrive.tv/](http://FATdrive.tv/) - store, play, share

---

<div class="post-metadata">

**Author:** ![Daniel\_Drehmer](https://avatars.discourse-cdn.com/v4/letter/d/90db22/32.png) [@Daniel\_Drehmer](https://discuss.rubyonrails.org/u/Daniel_Drehmer)\
**Post date:** [March 22, 2008, 7:24am UTC](https://discuss.rubyonrails.org/t/fleximage-retrieving-width-height/26638/4 "2008-03-22T07:24:00Z")

</div>

Thank you for the reply.

I think you may be right about rmagick/image magic...

I'm still a little confused about how could I accomplish this...

Does anyone has a second shot on this?

In the meanwhile, I guess I'll study more.

---

<div class="post-metadata">

**Author:** ![Alex\_Wayne](https://avatars.discourse-cdn.com/v4/letter/a/e8c25b/32.png) [@Alex\_Wayne](https://discuss.rubyonrails.org/u/Alex_Wayne)\
**Post date:** [April 5, 2008, 11:25pm UTC](https://discuss.rubyonrails.org/t/fleximage-retrieving-width-height/26638/5 "2008-04-05T23:25:05Z")

</div>

Just wanted to say, I am about to release Fleximage v2, a complete rewrite of the original code.

[http://github.com/Squeegy/fleximage/tree/master](http://github.com/Squeegy/fleximage/tree/master)

It makes preprecessing, as well storing the filename, width and height, exceedingly simple. Just add image\_filename, image\_width, and image\_height fields to your model's database table, and they will be filled in automatically when files are uploaded.

More magic columns here: [http://github.com/Squeegy/fleximage/wikis/magiccolumns](http://github.com/Squeegy/fleximage/wikis/magiccolumns)

It's also just better in every way. (Except for storing image in the DB, cause that is no longer supported).
