micro_exiftool is an extremely basic ruby wrapper for the ExifTool command line tool.
It allows to read and write metadata for all files supported by ExifTools, such as JPG or MP3.
This was the simplest tool that fit my own needs and deliberately tries to do as little as possible.
If you need a more complete implementation, you might want to take a look at mini_exiftool.
You need to have exiftool installed and on your PATH.
Add this line to your application's Gemfile:
gem 'micro_exiftool'
And then execute:
$ bundle
Or install it yourself as:
$ gem install micro_exiftool
All attributes are plain strings.
file = MicroExiftool::File.new(path_to_file)
file.attributes # hash including all attributes returned by exiftool
file['EXIF:Copyright'] # the EXIF copyright field
file['IPTC:CopyrightNotice'] # the IPTC copyright field
file = MicroExiftool::File.new(path_to_file)
file.update!(
'EXIF:Copyright' => 'new EXIF copyright',
'IPTC:CopyrightNotice' => 'new IPTC copyright',
)
This will update the attributes of the file in place.
Note that there is (currently) no validation that the fields are actually valid metadata fields. If you set an unknown field, it will be silently ignored.
Tobias Kraze from makandra
Licensed under the MIT license.