LoginSignup
0
0

More than 3 years have passed since last update.

exifrを使用したフォルダ内画像のexifデータ一括抽出

Posted at

プログラミング初心者です。
任意のフォルダ内に格納されている画像のexifを抽出するのに手間取ったため、備忘録として残します。


require 'exifr/jpeg'
require 'csv'

puts Dir.pwd

dir_name = "/Users/任意のフォルダパス"

Dir.chdir(dir_name)
dir = Dir.open(dir_name)
puts Dir.pwd

CSV.open('exif.csv','w') do |csv|
 csv << ['model','lens','f','exposure','iso','date']
  name = p Dir.glob('*.JPG')
  name.each do |syashin|
   exif = EXIFR::JPEG.new(syashin)
    a = exif.model
    b = exif.lens_model
    c = exif.f_number.to_f
    d = exif.exposure_time
    e = exif.iso_speed_ratings
    f = exif.date_time
    csv << [a,b,c,d,e,f]
   end
end

画像と同じフォルダにcsvファイルが作成されます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0