2

I'm attempting to get image EXIF data from the ruby-vips gem but I keep receiving errors. I've found documentation from others who have attempted to repair this issue and I've attempted their fixes with no success.

i=VIPS::Image.new("/home/eric/Pictures/golden-clouds-wallpaper.jpg")
i.get("exif-Orientation")
i.get("exif-ifd0-Orientation")

Both give errors:

VIPS error: vips_image_get: field "exif-Orientation" not found
VIPS error: vips_image_get: field "exif-ifd0-Orientation" not found

Ubuntu version 13.10

Vips version 7.28.5

ruby-vips 0.3.7

Edit

2.1.0 :001 > require 'rubygems' => false 
2.1.0 :002 > require 'vips' => true 
2.1.0 :003 > a = VIPS::Image.new('/home/eric/Pictures/devProfile.JPG') => #<VIPS::Image:0x00000001e4d7b0> 
2.1.0 :004 > a.get("exif-Orientation")
VIPS::Error: VIPS error: vips_image_get: field "exif-Orientation" not found

from (irb):4:in `get'
from (irb):4
from /home/eric/.rvm/rubies/ruby-2.1.0/bin/irb:11:in `<main>'
Nakilon
  • 34,866
  • 14
  • 107
  • 142
eabraham
  • 4,094
  • 1
  • 23
  • 29
  • For those looking to auto orient your image, take a look at [Rmagick#auto_orient](http://studio.imagemagick.org/RMagick/doc/image1.html#auto_orient), saved me a ton of time. – Joshua Pinter Apr 10 '14 at 21:02
  • Thanks, yes Rmagick#auto_orient works well but this is a thread about the vips gem. Previously, I used Rmagick but I had 10 times image processing times on it verses VIPS. The trade-off is that the Vips Gem doesn't support auto_orient out of the box. – eabraham Jun 11 '14 at 18:29
  • In hindsight, you're totally right, not sure why I posted this comment here. Maybe just as an alternative. Good to know how much more efficient VIPS is, though, thanks! – Joshua Pinter Jun 11 '14 at 19:31

1 Answers1

1

Install the vips GUI, nip2, then try loading your JPEG image in that. Right-click on the thumbnail, select Header, and look at the fields displayed. You should see orientation in there.

I have Ubuntu 13.10 / vips-7.28.5 / ruby-vips 0.3.7 here and I see:

$ vips --version
vips-7.28.5-Sat Mar  9 18:46:42 UTC 2013
$ gem install ruby-vips
Fetching: ruby-vips-0.3.7.gem (100%)
Building native extensions.  This could take a while...
Successfully installed ruby-vips-0.3.7
1 gem installed
Installing ri documentation for ruby-vips-0.3.7...
Installing RDoc documentation for ruby-vips-0.3.7...
$ irb
irb(main):001:0> require 'rubygems'
=> false
irb(main):002:0> require 'vips'
=> true
irb(main):003:0> a = VIPS::Image.new("pics/img_2522.jpg")
=> #<VIPS::Image:0x00000001a0e528>
irb(main):004:0> a.get("exif-Orientation")
=> "1 (Top-left, Short, 1 components, 2 bytes)"
irb(main):005:0> 
jcupitt
  • 10,213
  • 2
  • 23
  • 39
  • 1
    I've updated my question with output that matches your answer. Still doesn't work. – eabraham Feb 12 '14 at 17:54
  • Could you try with nip2, the vips GUI? It's in apt, just `sudo apt-get install nip2`. Load your image and confirm that vips can see the orientation field in your jpeg. Then in ruby-vips, try `VIPS::LIB_VERSION` and confirm that ruby-vips is picking up the correct libvips. – jcupitt Feb 13 '14 at 13:40
  • VIPS::LIB_VERSION = "7.28.5-Sat Mar 9 18:46:42 UTC 2013" matches my libvips version. – eabraham Feb 13 '14 at 16:07
  • Here's my test image: http://www.vips.ecs.soton.ac.uk/vips-7.8/doc/examples/img_2522.jpg can you see orientation in that? `a.exif?` should say if there's an EXIF block on the image, `a.exif` should return all the exif data as a binary string. – jcupitt Feb 14 '14 at 12:38
  • Interesting, your test image works but all of my test images fail. I'm diving into the EXIF data now. – eabraham Feb 14 '14 at 16:22
  • How strange. Could you post a test image somewhere? I'd like to investigate too. – jcupitt Feb 25 '14 at 12:59
  • All of the major image hosting services auto orient on upload. Let me see if I can find one that doesn't touch the EXIF data. – eabraham Feb 26 '14 at 20:42