mini_exiftool 2.4.2 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 85c8d58c8a6e5dd3372fab24ddcbad3d8ec940a5
4
- data.tar.gz: 2de6dc0ca9ea4fc221d9e019dca237d555c8bc13
3
+ metadata.gz: b0e0fe3eca725bd05c5eef9f9907856e213e08c8
4
+ data.tar.gz: 20d86a8c55a4da6bab8f34a35c14e465bb9bde5b
5
5
  SHA512:
6
- metadata.gz: 01aafd921026ba2f6828cb3cb1355d86bfaa9dbac7b5d09da7db514aa3109b4d88680ea702bf7fbba4b3360bf6c35f6336c5770dbb7d29e518af66e24380e87f
7
- data.tar.gz: 2d7b5ef57000167e18523b47cf9945a6c74598469be6d74957e2095bd29b78dc7ebcae8e3dbea854eba4847a334906d6c188fa3cd79b9d7c375451805f513665
6
+ metadata.gz: f2dd6a906910217fff909a4302edf1b7836c9aeef8721dba8df8639c71462711259389319c8fa5457af119030cc98bee14547736faba93b8f14d5f7e9d360c86
7
+ data.tar.gz: 3dc83dc895f1f1349e4493cab61685a631014db5325da40250a1d54a3085af00d5c73e91e52cd3ce4bf1478e09465cdc9ea7e2b4d895891b133283939b2e6803
data/Changelog CHANGED
@@ -1,3 +1,10 @@
1
+ 2.5.0
2
+ - Make the pstore dir customizable:
3
+ MiniExiftool.pstore_dir and MiniExiftool.pstore_dir=
4
+ Thanks to Shawn Pyle for the idea and a first approach
5
+ of implementation.
6
+ - Update README.
7
+
1
8
  2.4.2
2
9
  - Bugfix: Don't ignoring *_encoding options when saving.
3
10
 
@@ -27,6 +27,23 @@ install the gem with
27
27
  If you need to support older versions of Ruby or exiftool (see Requirements above)
28
28
  gem install --version "< 2.0.0" mini_exiftool
29
29
 
30
+ == Configuration
31
+
32
+ You can manually set the exiftool command that should be used via
33
+ MiniExiftool.command = '/path/to/my/exiftool'
34
+
35
+ In addition, you can also tell MiniExiftool where to store the PStore files with tags
36
+ which exiftool supports. The PStore files are used for performance issues.
37
+ Per default the PStore files are stored in a sub directory .mini_exiftool or
38
+ _mini_exiftool under your home directory.
39
+ MiniExiftool.pstore_dir = '/path/to/pstore/dir'
40
+
41
+ If you're using Rails, this is easily done with
42
+ MiniExiftool.pstore_dir = Rails.root.join('tmp').to_s
43
+
44
+ Important hint: if you have to change the configuration you have to do this direct
45
+ after require 'mini_exiftool'.
46
+
30
47
  == Usage
31
48
 
32
49
  In general MiniExiftool is very intuitive to use as the following examples show:
@@ -49,6 +66,56 @@ For further information about using MiniExiftool read the Tutorial.rdoc
49
66
  in the project root folder and have a look at the examples in directory
50
67
  examples.
51
68
 
69
+ == Encodings
70
+
71
+ In MiniExiftool all strings are encoded in UTF-8. If you need other
72
+ encodings in your project use the String#encod* methods.
73
+
74
+ If you have problems with corrupted strings when using MiniExiftool
75
+ there are two reasons for this:
76
+
77
+ === Internal character sets
78
+
79
+ You can specify the charset in which the meta data is in the file encoded
80
+ if you read or write to some sections of meta data (i.e. IPTC, XMP ...).
81
+ It exists various options of the form *_encoding: exif, iptc, xmp, png,
82
+ id3, pdf, photoshop, quicktime, aiff, mie and vorbis.
83
+
84
+ For IPTC meta data it is recommended to set also the CodedCharacterSet
85
+ tag.
86
+
87
+ Please read the section about the character sets of the ExifTool command
88
+ line application carefully to understand what's going on
89
+ (http://www.sno.phy.queensu.ca/~phil/exiftool/faq.html#Q10)!
90
+
91
+ # Using UTF-8 as internal encoding for IPTC tags and MacRoman
92
+ # as internal encoding for EXIF tags
93
+ photo = MiniExiftool.new('photo.jpg', iptc_encoding: 'UTF8',
94
+ exif_encoding: 'MacRoman'
95
+ # IPTC CaptionAbstract is already UTF-8 encoded
96
+ puts photo.caption_abstract
97
+ # EXIF Comment is converted from MacRoman to UTF-8
98
+ puts photo.comment
99
+
100
+ photo = MiniExiftool.new('photo.jpg', iptc_encoding: 'UTF8',
101
+ exif_encoding: 'MacRoman'
102
+ # When saving IPTC data setting CodedCharacterSet as recommended
103
+ photo.coded_character_set = 'UTF8'
104
+ # IPTC CaptionAbstract will be stored in UTF-8 encoding
105
+ photo.caption_abstract = 'Some text with Ümläuts'
106
+ # EXIF Comment will be stored in MacRoman encoding
107
+ photo.comment = 'Comment with Ümläuts'
108
+ photo.save
109
+
110
+ === Corrupt characters
111
+
112
+ You use the correct internal character set but in the string are still corrupt
113
+ characters.
114
+ This problem you can solve with the option replace_invalid_chars:
115
+
116
+ # Replace all invalid characters with a question mark
117
+ photo = MiniExiftool.new('photo.jpg', replace_invalid_chars: '?')
118
+
52
119
  == Contribution
53
120
 
54
121
  The code is hosted in a git repository on Gitorious at
@@ -25,7 +25,7 @@ require 'time'
25
25
  # Simple OO access to the Exiftool command-line application.
26
26
  class MiniExiftool
27
27
 
28
- VERSION = '2.4.2'
28
+ VERSION = '2.5.0'
29
29
 
30
30
  # Name of the Exiftool command-line application
31
31
  @@cmd = 'exiftool'
@@ -335,6 +335,22 @@ class MiniExiftool
335
335
  tag.to_s.gsub(/[-_]/,'').downcase
336
336
  end
337
337
 
338
+ @@running_on_windows = /mswin|mingw|cygwin/ === RbConfig::CONFIG['host_os']
339
+
340
+ def self.pstore_dir
341
+ unless defined? @@pstore_dir
342
+ # This will hopefully work on *NIX and Windows systems
343
+ home = ENV['HOME'] || ENV['HOMEDRIVE'] + ENV['HOMEPATH'] || ENV['USERPROFILE']
344
+ subdir = @@running_on_windows ? '_mini_exiftool' : '.mini_exiftool'
345
+ @@pstore_dir = File.join(home, subdir)
346
+ end
347
+ @@pstore_dir
348
+ end
349
+
350
+ def self.pstore_dir= dir
351
+ @@pstore_dir = dir
352
+ end
353
+
338
354
  # Exception class
339
355
  class MiniExiftool::Error < StandardError; end
340
356
 
@@ -462,14 +478,9 @@ class MiniExiftool
462
478
  result
463
479
  end
464
480
 
465
- @@running_on_windows = /mswin|mingw|cygwin/ === RbConfig::CONFIG['host_os']
466
-
467
481
  def self.load_or_create_pstore
468
- # This will hopefully work on *NIX and Windows systems
469
- home = ENV['HOME'] || ENV['HOMEDRIVE'] + ENV['HOMEPATH'] || ENV['USERPROFILE']
470
- subdir = @@running_on_windows ? '_mini_exiftool' : '.mini_exiftool'
471
- FileUtils.mkdir_p(File.join(home, subdir))
472
- pstore_filename = File.join(home, subdir, 'exiftool_tags_' << exiftool_version.gsub('.', '_') << '.pstore')
482
+ FileUtils.mkdir_p(pstore_dir)
483
+ pstore_filename = File.join(pstore_dir, 'exiftool_tags_' << exiftool_version.gsub('.', '_') << '.pstore')
473
484
  @@pstore = PStore.new pstore_filename
474
485
  if !File.exist?(pstore_filename) || File.size(pstore_filename) == 0
475
486
  @@pstore.transaction do |ps|
@@ -0,0 +1,24 @@
1
+ # -- encoding: utf-8 --
2
+ require 'helpers_for_test'
3
+
4
+ class TestPstore < TestCase
5
+
6
+ def test_pstore
7
+ pstore_dir = Dir.mktmpdir
8
+ s = MiniExiftool.writable_tags.size.to_s
9
+ cmd = %Q(#{RUBY_ENGINE} -EUTF-8 -I lib -r mini_exiftool -e "MiniExiftool.pstore_dir = '#{pstore_dir}'; p MiniExiftool.writable_tags.size")
10
+ a = Time.now
11
+ result = `#{cmd}`
12
+ b = Time.now
13
+ assert_equal s, result.chomp
14
+ assert_equal 1, Dir[File.join(pstore_dir, '*')].size
15
+ c = Time.now
16
+ result = `#{cmd}`
17
+ d = Time.now
18
+ assert_equal s, result.chomp
19
+ assert 10 * (d - c) < (b - a)
20
+ ensure
21
+ FileUtils.rm_rf pstore_dir
22
+ end
23
+
24
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_exiftool
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.2
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Friedrich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-21 00:00:00.000000000 Z
11
+ date: 2014-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rim
@@ -57,6 +57,7 @@ files:
57
57
  - test/test_from_hash.rb
58
58
  - test/test_invalid_byte_sequence_in_utf8.rb
59
59
  - test/test_invalid_rational.rb
60
+ - test/test_pstore.rb
60
61
  - test/test_read.rb
61
62
  - test/test_read_coordinates.rb
62
63
  - test/test_read_numerical.rb
@@ -91,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
92
  version: '0'
92
93
  requirements: []
93
94
  rubyforge_project:
94
- rubygems_version: 2.2.2
95
+ rubygems_version: 2.4.4
95
96
  signing_key:
96
97
  specification_version: 4
97
98
  summary: This library is wrapper for the Exiftool command-line application (http://www.sno.phy.queensu.ca/~phil/exiftool).