Forum: Ruby on Rails How to find out image width and height which is saved in database?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
58013f120c5d09858aff19b887bff632?d=identicon&s=25 seenu (Guest)
on 2009-04-03 12:16
(Received via mailing list)
How to find out image width and height which is saved in database,
with out using any applications or addons Please help
Ef3aa7f7e577ea8cd620462724ddf73b?d=identicon&s=25 Rob Biedenharn (Guest)
on 2009-04-03 14:55
(Received via mailing list)
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:  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 Biedenharn    http://agileconsultingllc.com
Rob@AgileConsultingLLC.com
This topic is locked and can not be replied to.