Get Image Dimensions Given Local File Path

Hi All,

I have an image file (.jpg) that I can open via and I am curious on the easiest way to get the dimensions of this file. I’d prefer this to be a ruby/rails way and not a javascript method. Basically, I am looking for a way to verify that when a user uploads an image file that it is not larger than x by y. I’ve been looking around the web and I’m having trouble finding a way to do this. Also, if there is a way to just resize any image over some pre-defined size that would work as well.

Thanks in advance,

Look at:

Ryan Prins wrote:

try FlexImage

It allows you to crop, resize, etc. checkout the RDoc link above, and
see if that will work for you.


There are RoR plugins that allow you to resize and validate image
uploads. Try the file_column plugin: