Hi- does anyone know of a working EXIF library for Ruby that runs on Windows and Linux? So far I've tried rexif and ruby-exif without any success. RMagick (RMagick-1.9.2-IM-6.2.4-6-win32) returns some data, but adds a '.' at the end of every value and undfortunately doesn't seem to handle GPSInfo, which contains most of the info I'm interested in. Thanks for any help, -markus
on 23.06.2006 14:22
on 27.06.2006 22:13
Please try EXIFR, http://rubyforge.org/projects/exifr gem install exifr It's a pure ruby EXIF reader so it works on both windows and linux. Please file a bug in the tracker at rubyforge if GPSInfo is not read properly/ at all and send me some examples (including the expected results) since I don't have any files containing GPSInfo. Thanks, Remco
on 28.06.2006 18:06
Remco van 't Veer wrote: > Please try EXIFR, http://rubyforge.org/projects/exifr > > gem install exifr > > It's a pure ruby EXIF reader so it works on both windows and linux. > Please file a bug in the tracker at rubyforge if GPSInfo is not read > properly/ at all and send me some examples (including the expected > results) since I don't have any files containing GPSInfo. > > Thanks, > Remco Hi- thanks for the pointer. Unfortunately it doesn't work. I filed a bug report as you suggested. From a quick glance at the code I couldn't find any support for GPSInfo IFD. But then again I'm very new to ruby, actually this was going to be my first ruby microproject. For the time being I've implemented it in python... Thanks, -markus
on 29.06.2006 17:37
Just released 0.9.3 with the ability to read GPSInfo.
on 12.05.2007 04:12
Remco van 't Veer wrote: > Please try EXIFR, http://rubyforge.org/projects/exifr > > gem install exifr > You may need: sudo gem install exifr
on 12.05.2007 04:44
Newbie here. What's the syntax to read say the date and time the picture
was taken?
I tried:
puts EXIFR::JPEG.new("/file/is/here/tests/data/exif.jpg").date_time
and got: NameError: uninitialized constant EXIFR
Maybe I didn't get it installed right?
Thanks for any help.
on 12.05.2007 04:51
As a follow on to my Newbie question, here's what I got when I installed it $ sudo gem install exifr Password: Bulk updating Gem source index for: http://gems.rubyforge.org Successfully installed exifr-0.10.2 Installing ri documentation for exifr-0.10.2... Installing RDoc documentation for exifr-0.10.2... - PS I don't se an edit for postings. But I guess this is only a window to Usenet so that wouldn't work.
on 12.05.2007 07:36
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? > > I tried: > > puts EXIFR::JPEG.new("/file/is/here/tests/data/exif.jpg").date_time > > and got: NameError: uninitialized constant EXIFR > > Maybe I didn't get it installed right? Install exifr with : sudo gem install exifr 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 ======================================================================== exposure_mode : 1 shutter_speed_value : 117/16 exposure_time : 1/160 orientation : EXIFR::TIFF::TopLeftOrientation sensing_method : 2 color_space : 1 metering_mode : 2 x_resolution : 180 white_balance : 0 focal_plane_x_resolution : 100000/13 aperture_value : 95/32 f_number : 14/5 pixel_x_dimension : 1600 date_time_original : Thu Dec 30 12:02:53 -0700 2004 y_resolution : 180 resolution_unit : 2 digital_zoom_ratio : 1 focal_plane_y_resolution : 100000/13 ycb_cr_positioning : 1 pixel_y_dimension : 1200 flash : 16 date_time_digitized : Thu Dec 30 12:02:53 -0700 2004 make : Canon focal_plane_resolution_unit : 2 exposure_bias_value : 4294967291/3 focal_length : 173/32 model : Canon PowerShot SD100 scene_capture_type : 0 max_aperture_value : 95/32 custom_rendered : 0 compressed_bits_per_pixel : 3 date_time : Thu Dec 30 12:02:53 -0700 2004 enjoy, -jeremy
on 12.05.2007 18:26
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 > =============================================================== <snip-snip long output> 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.
on 12.05.2007 20:19
Remco van 't Veer wrote: > Please try EXIFR, http://rubyforge.org/projects/exifr > > gem install exifr > > It's a pure ruby EXIF reader so it works on both windows and linux. > Please file a bug in the tracker at rubyforge if GPSInfo is not read > properly/ at all and send me some examples (including the expected > results) since I don't have any files containing GPSInfo. > > Thanks, > Remco Can this be expanded to support RAW images? Specifically MRW (Konica-Minolta)? If how would I get into the OS X hooks for handling this? Maybe this isn't a Ruby question and I'll have to go elsewhere. I'm a Newbie to Ruby (groan), but OS X supports many RAW formats. I have Appscript, so assume that's the path, but was hoping to avoid that for awhile. Thanks for any clues.
on 13.05.2007 00:57
On Sun, May 13, 2007 at 01:26:17AM +0900, 12 34 wrote: > > require 'exifr' > > puts "Standard items".center(72) > > h.each_pair do |k,v| > > puts "#{k.to_s.rjust(30)} : #{v}" > > end > > else > > puts "No EXIF information in this image" > > end > > > Jeremy > I am enjoying. Learned several things with your help. "require" for > example. require is how you pull in other ruby libraries into the current file/program. Libraries must be 'required' before they can be utilized. > 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 This is a copy and paste of the command line program 'cat' which dumped the contents of hte file 'exif-test.rb' to the terminal/command window. It is a unix command. The equivalent in Windows is 'type'. > or > image_file = ARGV.first > lines. ARGV is a special global Array that holds the other parameters on the command line after the ruby script. So in this case, at the command line I had : ruby exif-test.rb image.jpg ^ ^ ^ | | +--- the image file being processed and first | | element of the ARGV Array. It can be | | accessed via ARGV[0] or ARGV.first | | | +---------------- The ruby program being invoked (accessed as $0) | +--------------------- Invoking the ruby interpreter. > 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. You may also be interested in Programming Ruby (http://pragmaticprogrammer.com/titles/ruby/index.html) enjoy, -jeremy
on 13.05.2007 01:46
Jeremy Hinegardner wrote: > On Sun, May 13, 2007 at 01:26:17AM +0900, 12 34 wrote: >> > require 'exifr' >> > puts "Standard items".center(72) >> > h.each_pair do |k,v| >> > puts "#{k.to_s.rjust(30)} : #{v}" >> > end >> > else >> > puts "No EXIF information in this image" >> > end >> > >> Jeremy >> I am enjoying. Learned several things with your help. "require" for >> example. > > require is how you pull in other ruby libraries into the current > file/program. Libraries must be 'required' before they can be utilized. > >> 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 > > This is a copy and paste of the command line program 'cat' which dumped > the contents of hte file 'exif-test.rb' to the terminal/command window. > It is a unix command. The equivalent in Windows is 'type'. > > >> or >> image_file = ARGV.first >> lines. > > ARGV is a special global Array that holds the other parameters on the > command line after the ruby script. So in this case, at the command > line I had : > > ruby exif-test.rb image.jpg > ^ ^ ^ > | | +--- the image file being processed and first > | | element of the ARGV Array. It can be > | | accessed via ARGV[0] or ARGV.first > | | > | +---------------- The ruby program being invoked (accessed as > $0) > | > +--------------------- Invoking the ruby interpreter. > > >> 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. > > You may also be interested in Programming Ruby > (http://pragmaticprogrammer.com/titles/ruby/index.html) > > enjoy, > > -jeremy Thanks Jeremy. I have the book and it's over my head. But Black's book arrived today. I ordered it because it is supposed to be a good intermediate book. I had looked up all the ARGV refs in Pickaxe and they didn't make much sense. I get "require," but still am learning what needs to be "required" and what's built in. I think I can see how ARGV will be useful, because eventually I'll be processing all the files in a folder. I'm running from TextMate in OS X, so wasn't thinking command line (which I use infrequently), so I'll pull in the file paths some other way. Much to learn and thanks again. Since exifr doesn't support Raw images (see separate posting), I also have to dig into the hooks to apps in the Mac OS to read the exif for Raw. But now that I've got Black I'll put some time in with that before working on my own project too much. Plus I have to take a vacation to Utah and Colorado in the next two weeks. Poor me.
on 13.05.2007 01:54
12 34 wrote: > 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 If you're still in the market for a book, check out my review of "Beginning Ruby" on Slashdot: http://books.slashdot.org/article.pl?sid=07/04/23/1429230. I think you'd find it useful.
on 13.05.2007 02:17
On Sun, May 13, 2007 at 08:46:57AM +0900, 12 34 wrote: > (which I use infrequently), so I'll pull in the file paths some other > way. You may be interested in using ruby-osa (http://rubyosa.rubyforge.org/) > Much to learn and thanks again. No worries, have fun and enjoy yourself. > Since exifr doesn't support Raw images (see separate posting), I also > have to dig into the hooks to apps in the Mac OS to read the exif for > Raw. But now that I've got Black I'll put some time in with that before > working on my own project too much. That would be cool. Interfacing ruby with CoreImage, you may want to follow the RubyCocoa project, from their website it says that the unstable branch supports CoreImage (via QuartzCore), http://rubycocoa.sourceforge.net/doc/unstable/ I haven't played with any of these yet, but they do look fun. > Plus I have to take a vacation to Utah and Colorado in the next two > weeks. Poor me. If you hit anywhere near Boulder, CO I'll stand you to a beverage of your choice. If you happen to make here on May 15, the Boulder/Denver Ruby Users group is meeting. enjoy, -jeremy
on 13.05.2007 06:48
Jeremy Hinegardner wrote: > On Sun, May 13, 2007 at 08:46:57AM +0900, 12 34 wrote: > > That would be cool. Interfacing ruby with CoreImage, you may want to > follow the RubyCocoa project, from their website it says that the > unstable branch supports CoreImage (via QuartzCore), > > http://rubycocoa.sourceforge.net/doc/unstable/ > > I haven't played with any of these yet, but they do look fun. > >> Plus I have to take a vacation to Utah and Colorado in the next two >> weeks. Poor me. > > If you hit anywhere near Boulder, CO I'll stand you to a beverage of > your choice. If you happen to make here on May 15, the Boulder/Denver > Ruby Users group is meeting. > > enjoy, > > -jeremy Ruby Cocoa looks like a bit much for me to tackle yet. How about Telluride? We're going to the Mountain Film Festival over Memorial Day Weekend? Beers on me.
on 13.05.2007 07:14
On Sun, May 13, 2007 at 01:48:31PM +0900, 12 34 wrote: > How about Telluride? We're going to the Mountain Film Festival over > Memorial Day Weekend? Beers on me. Sorry, running the BolderBoulder on Memorial Day. And Telluride is not exactly near Boulder, its just short 7 hour drive :-). Oh well, next time. Enjoy the Film Festival. -jeremy
on 13.05.2007 07:54
Jeremy Hinegardner wrote: > On Sun, May 13, 2007 at 01:48:31PM +0900, 12 34 wrote: >> How about Telluride? We're going to the Mountain Film Festival over >> Memorial Day Weekend? Beers on me. > > Sorry, running the BolderBoulder on Memorial Day. And Telluride is not > exactly near Boulder, its just short 7 hour drive :-). > > Oh well, next time. > > Enjoy the Film Festival. > > -jeremy Next time. How long is the run? Answered my own question. Looks like a big event from the web page. Good luck. We're mountain biking Moab and Fruita before Telluride and also in Telluride. I did install RubyCocoa. Will be handy later when I want to put on a GUI. Is it CoreImage I'd need. I'm not going to change the image or display it, but I need the meta data. I'll find out eventually. I think it's in Image Events. I just have to figure out the dictionary and how to write it in Ruby via Appscript.
on 13.05.2007 11:51
On Sun, May 13, 2007 at 02:54:57PM +0900, 12 34 wrote: > I did install RubyCocoa. Will be handy later when I want to put on a > GUI. Is it CoreImage I'd need. I'm not going to change the image or > display it, but I need the meta data. I'll find out eventually. I think > it's in Image Events. I just have to figure out the dictionary and how > to write it in Ruby via Appscript. While looking around for things dealing with this thread, I happened upon exiv2[1], which is an Exif and IPTC tag reader/writer. And as it turns out there are ruby bindings to it already. You can use macports to install the original library and then use gem to install the ruby bindings[2] to it. The documentation is a little lacking for the ruby bindings, but it is quite fun too play around with. I'm already thinking of a few uses for it. enjoy, -jeremy 1 - http://www.exiv2.org/ 2 - http://rubyforge.org/projects/ruby-exiv2/
on 14.05.2007 03:24
Jeremy Hinegardner wrote: > On Sun, May 13, 2007 at 02:54:57PM +0900, 12 34 wrote: >> I did install RubyCocoa. Will be handy later when I want to put on a >> GUI. > > While looking around for things dealing with this thread, I happened > upon exiv2[1], which is an Exif and IPTC tag reader/writer. And as it > turns out there are ruby bindings to it already. You can use macports > to install the original library and then use gem to install the ruby > bindings[2] to it. The documentation is a little lacking for the ruby > bindings, but it is quite fun too play around with. I'm already > thinking of a few uses for it. > > enjoy, > > -jeremy > > 1 - http://www.exiv2.org/ > 2 - http://rubyforge.org/projects/ruby-exiv2/ I have to use some OS X apps anyway, so I think I'll try using those via Appscsript rather than getting more confused trying to use exiv. iMagine Photo and Image Events are two that come to mind. But thanks for the suggestion
on 14.05.2007 10:51
12 34 wrote: > Can this be expanded to support RAW images? Specifically MRW > (Konica-Minolta)? Maybe you can use MiniExiftool (http://miniexiftool.rubyforge.org/) wich can handle (read and write) meta-data of many file formats inclusive raw-formats such as MRW. :) regards Jan
on 19.05.2007 13:58
The call is correct. I think you forgot to require exifr (and
rubygems);
require 'rubygems'
require 'exifr'
puts EXIFR::JPEG.new("/file/is/here/tests/data/exif.jpg").date_time
HTH,
Remco
on 19.05.2007 14:05
I will not implement any vendor specific decoding in the near future. 12 34 wrote: > Remco van 't Veer wrote: >> Please try EXIFR, http://rubyforge.org/projects/exifr > > Can this be expanded to support RAW images? Specifically MRW > (Konica-Minolta)?
on 19.06.2007 20:23
Jan Friedrich wrote: > 12 34 wrote: >> Can this be expanded to support RAW images? Specifically MRW >> (Konica-Minolta)? > Maybe you can use MiniExiftool (http://miniexiftool.rubyforge.org/) wich > can handle (read and write) meta-data of many file formats inclusive > raw-formats such as MRW. :) > > regards > Jan Fantastic. This is what I wanted. I just got back to trying to write my script after reading a couple of the books. When I got to the EXIF part I found ExifTool and despair that nothing was available that would handle MRW using Ruby, until I revisited MiniExifTool. I think in part the name threw me. This tool is in no way mini. I'm also finding Ruby easier to write than AppleScript. I could rarely get anything to work without help. But Ruby syntax is easier to deal with.
on 19.06.2007 22:05
12 34 wrote: > Fantastic. This is what I wanted. Nice to hear. :) > I think in part the name threw me. This tool is in no way mini. I've updated the project description. The "mini" has nothing to do with the functionality only with the concept of writing only a wrapper to a command-line application which is a lightweight approach that brings maximal functionality with *mini*mal work. :) Regards Jan
on 20.06.2007 02:46
Jan Friedrich wrote: > 12 34 wrote: >> Fantastic. This is what I wanted. > Nice to hear. :) > >> I think in part the name threw me. This tool is in no way mini. maximal functionality with *mini*mal work. :) > > Regards > Jan Now you've got it. PS. While you're updating, the Perl program is authored by "Phil Harvey." Minor typo.
on 21.06.2007 20:36
12 34 wrote: > PS. While you're updating, the Perl program is authored by "Phil > Harvey." Minor typo. Thanks for the hint. Typos (it was also in the Documentation) fixed. Regards Jan
on 27.05.2008 09:48
12 34 wrote: > Newbie here. What's the syntax to read say the date and time the picture > was taken? > > I tried: > > puts EXIFR::JPEG.new("/file/is/here/tests/data/exif.jpg").date_time > > and got: NameError: uninitialized constant EXIFR > > Maybe I didn't get it installed right? > > Thanks for any help. I got the same error in "rb" file . but all were OK when run code from 'irb' ! Anyone will tell me why?
on 27.05.2008 11:16
2008/5/27 frog cgc <isfrog@gmail.com>: > > Maybe I didn't get it installed right? > > > > Thanks for any help. > > I got the same error in "rb" file . > but all were OK when run code from 'irb' ! > Anyone will tell me why? > -- > Posted via http://www.ruby-forum.com/. > > require 'rubygems' require 'exifr' p EXIFR::JPEG.new('IMG_4061.JPG').date_time