# FlexImage - retrieving width / height

**URL:** <https://www.ruby-forum.com/t/fleximage-retrieving-width-height/132540>\
**Category:** Rails\
**Created:** [March 21, 2008, 7:10am UTC](https://www.ruby-forum.com/t/fleximage-retrieving-width-height/132540 "2008-03-21T07:10:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gattone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/898d66/32.png) [@gattone](https://www.ruby-forum.com/u/gattone)\
**Post date:** [March 21, 2008, 7:10am UTC](https://www.ruby-forum.com/t/fleximage-retrieving-width-height/132540/1 "2008-03-21T07:10:04Z")

</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:** ![gattone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/898d66/32.png) [@gattone](https://www.ruby-forum.com/u/gattone)\
**Post date:** [March 21, 2008, 7:13am UTC](https://www.ruby-forum.com/t/fleximage-retrieving-width-height/132540/2 "2008-03-21T07:13:00Z")

</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:** ![gattone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/898d66/32.png) [@gattone](https://www.ruby-forum.com/u/gattone)\
**Post date:** [March 21, 2008, 5:09pm UTC](https://www.ruby-forum.com/t/fleximage-retrieving-width-height/132540/3 "2008-03-21T17:09:18Z")

</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

----- Original Message -----  
From: “Daniel D.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: “Ruby on Rails: Talk” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Friday, March 21, 2008 1:09 AM  
Subject: [Rails] FlexImage - retrieving width / height

> 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

---

<div class="post-metadata">

**Author:** ![gattone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/898d66/32.png) [@gattone](https://www.ruby-forum.com/u/gattone)\
**Post date:** [March 22, 2008, 8:24am UTC](https://www.ruby-forum.com/t/fleximage-retrieving-width-height/132540/4 "2008-03-22T08:24:43Z")

</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:** ![gattone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/898d66/32.png) [@gattone](https://www.ruby-forum.com/u/gattone)\
**Post date:** [April 6, 2008, 1:25am UTC](https://www.ruby-forum.com/t/fleximage-retrieving-width-height/132540/5 "2008-04-06T01:25:56Z")

</div>

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

> **[GitHub - AlexJWayne/fleximage: Rails plugin for uploading images as resources,...](https://github.com/AlexJWayne/fleximage/tree/master)**
>
> 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:

> **[GitHub: Let’s build from here](https://github.com/)**
>
> GitHub is where over 100 million developers shape the future of software, together. Contribute to the open source community, manage your Git repositories, review code like a pro, track bugs and fea...

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