EXIF Library

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

···

--
Posted via http://www.ruby-forum.com/.

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

Markus Strickler wrote:

···

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

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

···

--
Posted via http://www.ruby-forum.com/\.

Remco van 't Veer wrote:

Please try EXIFR, http://rubyforge.org/projects/exifr

  gem install exifr

You may need: sudo gem install exifr

···

--
Posted via http://www.ruby-forum.com/\.

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.

···

--
Posted via http://www.ruby-forum.com/.

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.

--
Posted via http://www.ruby-forum.com/.

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.

···

--
Posted via http://www.ruby-forum.com/\.

Just released 0.9.3 with the ability to read GPSInfo.

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

···

On Sat, May 12, 2007 at 11:44:53AM +0900, 12 34 wrote:
    ========================================================================
                              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

--

Jeremy Hinegardner jeremy@hinegardner.org

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. :slight_smile:

regards
Jan

···

--
Posted via http://www.ruby-forum.com/\.

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 5/12/07, 12 34 <rubyforum@web.knobby.ws> 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.

--
Posted via http://www.ruby-forum.com/\.

--
http://blog.remvee.net/

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)?

--
Posted via http://www.ruby-forum.com/\.

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?

···

--
Posted via http://www.ruby-forum.com/\.

Jeremy Hinegardner 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 Sat, May 12, 2007 at 11:44:53AM +0900, 12 34 wrote:

--
Posted via http://www.ruby-forum.com/\.

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. :slight_smile:

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.

···

--
Posted via http://www.ruby-forum.com/\.

require 'rubygems'
require 'exifr'

p EXIFR::JPEG.new('IMG_4061.JPG').date_time

···

2008/5/27 frog cgc <isfrog@gmail.com>:

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?
--
Posted via http://www.ruby-forum.com/\.

Jeremy Hinegardner 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
>
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 Sun, May 13, 2007 at 01:26:17AM +0900, 12 34 wrote:

> On Sat, May 12, 2007 at 11:44:53AM +0900, 12 34 wrote:

--

Jeremy Hinegardner jeremy@hinegardner.org

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.

···

--
RMagick [http://rmagick.rubyforge.org]
RMagick Installation FAQ [http://rmagick.rubyforge.org/install-faq.html\]

12 34 wrote:

Fantastic. This is what I wanted.

Nice to hear. :slight_smile:

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. :slight_smile:

Regards
Jan

Jeremy Hinegardner 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 Sun, May 13, 2007 at 01:26:17AM +0900, 12 34 wrote:

--
Posted via http://www.ruby-forum.com/\.