How to retrieve EXIF information of an image in Rails

后端 未结 4 1056
囚心锁ツ
囚心锁ツ 2021-02-12 12:23

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).Ca

4条回答
  •  梦如初夏
    2021-02-12 12:43

    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
    

提交回复
热议问题