Tuesday, May 15, 2018


....A simple wrapper around exiv2...
A simple wrapper around the C++ Exiv2 libary for reading and writing image metadata.
Requires that the exiv2 C++ library is installed.


gem install exiv2
if you get errors with header could not be found below:
exiv2.cpp:1:10: fatal error: 'exiv2/image.hpp' file not found
#include "exiv2/image.hpp"
please explicitly declare the header path
gem install exiv2 -- --with-exiv2-include="${EXIV2_PREFIX}/include" --with-exiv2-lib="${EXIV2_PREFIX}/lib"
on OSX with Homebrew's exiv2, the EXIV2_PREFIX can be set:
export EXIV2_PREFIX=$(brew --prefix exiv2)
If you get this error while trying to install as part of a bundle install, you can set these paths using:
bundle config build.exiv2 --with-exiv2-include="${EXIV2_PREFIX}/include" --with-exiv2-lib="${EXIV2_PREFIX}/lib"
If you are on new version of Command Line Tool (that is newer than 6.2, and bump into following error:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iterator:341:10: fatal error: '__debug' file not found
#include <__debug>
You can follow the quick hack by touching a new file /Library/Developer/CommandLineTools/usr/include/c++/v1/__debug with content:
#define _LIBCPP_ASSERT(...) ((void)0)
Once everything is successfully installed, you can give it a go:
require 'exiv2'
image = Exiv2::ImageFactory.open("image.jpg")
image.iptc_data.each do |key, value|
  puts "#{key} = #{value}\n"
image.exif_data.each { ... }
image.xmp_data.each { ... }

iptc_data_hash  = image.iptc_data.to_hash
xmp_data_hash   = image.xmp_data.to_hash


image.iptc_data["Iptc.Application2.Caption"] = "A New Caption"
image.iptc_data.add("Iptc.Application2.Keywords", "fishy")


A simple wrapper around exiv2

No comments:

neutron generator...

...back to war! NK? you've been called stupid since 1973...lithium 6 what you so hardly achieved to produce, as the most powerful ene...