module MultiExiftool
Constants
- VERSION
Attributes
exiftool_command[RW]
exiftool_version[R]
Public Class Methods
batch() { |batch| ... }
click to toggle source
Execute a batch of write commands Returns an array of the error messages
Example:
errors = MultiExiftool.batch do Dir['*.jpg'].each_with_index do |filename, i| write filename, {author: 'Jan Friedrich', comment: "This is file number #{i+1}."} end unless errors.empty? # do error handling end
# File lib/multi_exiftool.rb, line 81 def batch &block batch = Batch.new if block.arity == 0 batch.instance_exec &block else yield batch end batch.execute batch.errors end
delete_values(filenames, opts={})
click to toggle source
Deleting metadata Returns an array of the error messages
Examples:
# delete values for all tags errors = MultiExiftool.delete_values(Dir['*.jpg']) unless errors.empty? # do error handling end # delete values for tags Author and Title errors = MultiExiftool.delete_values(Dir['*.jpg'], %w[author title]) unless errors.empty? # do error handling end
# File lib/multi_exiftool.rb, line 63 def delete_values filenames, opts={} tags = opts.fetch(:tags, :all) values = Array(tags).inject(Hash.new) {|h,tag| h[tag] = nil; h} write(filenames, values) end
exiftool_command=(cmd)
click to toggle source
# File lib/multi_exiftool.rb, line 95 def exiftool_command= cmd @exiftool_command = cmd @exiftool_version = nil end
read(filenames, opts={})
click to toggle source
Reading metadata Be aware: it returns an array of two elements: values, errors
Example:
values, errors = MultiExiftool.read(Dir['*.jpg']) if errors.empty? values.each {|val| do_something_with(val) } else # error handling end
# File lib/multi_exiftool.rb, line 28 def read filenames, opts={} reader = Reader.new(filenames, opts) values = reader.read [values, reader.errors] end
write(filenames, values, opts={})
click to toggle source
Writing metadata Returns an array of the error messages
Example:
errors = MultiExiftool.write(Dir['*.jpg'], {author: 'Jan Friedrich'}) unless errors.empty? # do error handling end
# File lib/multi_exiftool.rb, line 42 def write filenames, values, opts={} writer = Writer.new(filenames, values, opts) writer.write writer.errors end