How to retrieve EXIF information of an image in Rails

Rukmangathan Govindarajan picture Rukmangathan Govindarajan · Aug 7, 2012 · Viewed 10.3k times · Source

I am using Rails paperclip for displaying the images in my page. I want to know how to retrieve EXIF information of an image(like dimensions, camera model,height,width., etc).Can any one help me out???

Thanks!!!

Answer

Kulbir Saini picture Kulbir Saini · Aug 7, 2012

Did you give exifr gem a try? From the documentation

EXIFR::JPEG.new('IMG_6841.JPG').width               # => 2272
EXIFR::JPEG.new('IMG_6841.JPG').height              # => 1704
EXIFR::JPEG.new('IMG_6841.JPG').exif?               # => true
EXIFR::JPEG.new('IMG_6841.JPG').model               # => "Canon PowerShot G3"
EXIFR::JPEG.new('IMG_6841.JPG').date_time           # => Fri Feb 09 16:48:54 +0100 2007
EXIFR::JPEG.new('IMG_6841.JPG').exposure_time.to_s  # => "1/15"
EXIFR::JPEG.new('IMG_6841.JPG').f_number.to_f       # => 2.0