# How to find out image width and height which is saved in database?

**URL:** <https://www.ruby-forum.com/t/how-to-find-out-image-width-and-height-which-is-saved-in-database/164627>\
**Category:** Rails\
**Created:** [April 3, 2009, 12:16pm UTC](https://www.ruby-forum.com/t/how-to-find-out-image-width-and-height-which-is-saved-in-database/164627 "2009-04-03T12:16:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![seenu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecae2f/32.png) [@seenu](https://www.ruby-forum.com/u/seenu)\
**Post date:** [April 3, 2009, 12:16pm UTC](https://www.ruby-forum.com/t/how-to-find-out-image-width-and-height-which-is-saved-in-database/164627/1 "2009-04-03T12:16:41Z")

</div>

How to find out image width and height which is saved in database,  
with out using any applications or addons Please help

---

<div class="post-metadata">

**Author:** ![seenu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecae2f/32.png) [@seenu](https://www.ruby-forum.com/u/seenu)\
**Post date:** [April 3, 2009, 2:55pm UTC](https://www.ruby-forum.com/t/how-to-find-out-image-width-and-height-which-is-saved-in-database/164627/2 "2009-04-03T14:55:32Z")

</div>

On Apr 3, 2009, at 6:15 AM, seenu wrote:

> How to find out image width and height which is saved in database,  
> with out using any applications or addons Please help

You could do what I did: [ImageSize finds the width x height · GitHub](http://gist.github.com/89738)

Then you can do things like:

irb\> require ‘image\_size’  
=\> true  
irb\> x=ImageSize.of\_file(‘/Users/rab/Pictures/Boston\_MIT\_8L4L2442.jpg’)  
=\> #\<ImageSize:0x32df98 @height=678, @image=#\<File:/Users/rab/Pictures/  
Boston\_MIT\_8L4L2442.jpg (closed)\>, @width=1024,  
@jpeg\_dimension\_segment=“\377\300\000\021\b  
\002\246\004\000\003\001"\000\002\021\001\003\021\001”,  
@header=“\377\330\377\340\000\020JFIF\000\001\001\001\000`\000`  
\000\000\377\333\000C\000\006\004\005\006\005\004\006\006\005\006\a\a  
\006\b\n\020\n\n\t\t\n\024\016\017\f  
\020\027\024\030\030\027\024\026\026\032\035%\037\032\e#\034\026\026 ,  
#&')\*)\031\037-0-(0%()(\377\333\000C\001\a\a\a\n\b\n\023\n\n  
\023  
(\032  
\026  
\032  
((((((((((((((((((((((((((((((((((((((((((((((((((\377\300\000\021\b  
\002\246\004\000\003\001"\000\002\021\001\003\021\001\377\304”,  
@image\_type=:jpeg\>  
irb\> x.width  
=\> 1024  
irb\> x.height  
=\> 678  
irb\> x.dimensions  
=\> [1024, 678]  
irb\> x.size  
=\> “1024x678”  
irb\> x.content\_type  
=\> “image/jpeg”

Well, unless you consider that an addon, of course.

-Rob

Rob B. [http://agileconsultingllc.com](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid
