From: 12 34 Date: 2007-05-13T01:26:17+09:00 Subject: Re: EXIF Library Jeremy Hinegardner wrote: > On Sat, May 12, 2007 at 11:44:53AM +0900, 12 34 wrote: >> Newbie here. What's the syntax to read say the date and time the picture >> was taken? >> > > Example program to display exif tags. > > > cat exif-test.rb > require 'rubygems' > require 'exifr' > > image_file = ARGV.first > exif_info = nil > case image_file.downcase > when /.jpg\Z/ > exif_info = EXIFR::JPEG.new(image_file) > when /.tiff?\Z/ > exif_info = EXIFR::TIFF.new(image_file) > end > > puts "Standard items".center(72) > puts "=" * 72 > puts " File : #{image_file}" > puts " Height : #{exif_info.height}" > puts " Width : #{exif_info.width}" > puts > > if exif_info.exif? then > puts "EXIF information".center(72) > puts "=" * 72 > h = exif_info.exif.to_hash > h.each_pair do |k,v| > puts "#{k.to_s.rjust(30)} : #{v}" > end > else > puts "No EXIF information in this image" > end > > Running that program on an image > > > ruby exif-test.rb 2004120087.JPG > Standard items > ======================================================================== > File : 2004120087.JPG > Height : 1200 > Width : 1600 > > EXIF information > =============================================================== enjoy, > > -jeremy Jeremy I am enjoying. Learned several things with your help. "require" for example. And some other nice details about outputting. I got it working by simplifying the beginning. I didn't understand two lines: cat exif-test.rb or image_file = ARGV.first lines. As I changed the script it works for me. But in the interest of learning. I'm waiting for Black's book before going much further. Thanks again. -- Posted via http://www.ruby-forum.com/.