image_voodoo 0.8.7 → 0.8.8
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 +4 -4
- data/.travis.yml +2 -0
- data/LICENSE-2.0.txt +202 -0
- data/README.exif +18 -0
- data/README.md +1 -0
- data/Rakefile +11 -0
- data/bin/image_voodoo +26 -6
- data/lib/image_voodoo.rb +40 -4
- data/lib/image_voodoo/awt.rb +57 -14
- data/lib/image_voodoo/gae.rb +1 -1
- data/lib/image_voodoo/metadata.rb +1641 -0
- data/lib/image_voodoo/version.rb +1 -1
- data/test/test_metadata.rb +50 -0
- data/tools/gen.rb +61 -0
- data/vendor/metadata-extractor-2.7.0.jar +0 -0
- data/vendor/xmpcore-5.1.2.jar +0 -0
- metadata +13 -3
data/lib/image_voodoo/version.rb
CHANGED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require 'test/unit/testcase'
|
|
2
|
+
require 'test/unit' if $0 == __FILE__
|
|
3
|
+
require 'image_voodoo'
|
|
4
|
+
|
|
5
|
+
IMAGE_DIR = File.join File.dirname(__FILE__), '..', '..', 'metadata-extractor-images'
|
|
6
|
+
|
|
7
|
+
# FIXME: If we end up running on travis or other tool this should be ignored
|
|
8
|
+
# subdir to this project and probably clone repo into that subdir
|
|
9
|
+
unless File.exist? IMAGE_DIR
|
|
10
|
+
puts "To run this test you must clone: https://github.com/drewnoakes/metadata-extractor-images.git into a sibling directory to image_voodoo"
|
|
11
|
+
else
|
|
12
|
+
class TestImageVoodooMetadata < Test::Unit::TestCase
|
|
13
|
+
def setup
|
|
14
|
+
@path = File.join IMAGE_DIR, "Apple iPhone 4S.jpg"
|
|
15
|
+
@path_gps = File.join IMAGE_DIR, "Apple iPhone 4.jpg"
|
|
16
|
+
@path_no_exif = File.join File.dirname(__FILE__), "pix.png"
|
|
17
|
+
end
|
|
18
|
+
def test_metadata_from_file
|
|
19
|
+
ImageVoodoo.with_image @path do |img|
|
|
20
|
+
assert img.metadata[:IFD0].exists?
|
|
21
|
+
assert_equal 6, img.metadata[:IFD0][:Orientation]
|
|
22
|
+
assert_equal 6, img.metadata.orientation
|
|
23
|
+
assert_equal 3264, img.metadata.width
|
|
24
|
+
assert_equal 2448, img.metadata.height
|
|
25
|
+
assert_equal "Apple", img.metadata.make
|
|
26
|
+
assert_equal "iPhone 4S", img.metadata.model
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test_metadata_from_inputstream
|
|
31
|
+
ImageVoodoo.with_bytes File.read(@path) do |img|
|
|
32
|
+
assert_equal(6, img.metadata[:IFD0][:Orientation])
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def test_metadata_no_ifd0
|
|
37
|
+
ImageVoodoo.with_image @path_no_exif do |img|
|
|
38
|
+
assert !img.metadata[:IFD0].exists?
|
|
39
|
+
assert_equal(nil, img.metadata[:IFD0][:Orientation])
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_metadata_gps
|
|
44
|
+
ImageVoodoo.with_image @path_gps do |img|
|
|
45
|
+
assert img.metadata[:Gps].exists?
|
|
46
|
+
assert_equal("N", img.metadata[:Gps]['Latitude Ref'])
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
data/tools/gen.rb
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Used to generate part of metadata.rb. Unfortunately, I am unable to fill
|
|
2
|
+
# in appropriate access methods so I generate with get_string and then manually
|
|
3
|
+
# update. In future versions I will just run this twice with old and new src
|
|
4
|
+
# and manually splice in new data (or fixes).
|
|
5
|
+
#
|
|
6
|
+
# % find ../metadata-extractor/Source/ -name '*Directory.java' | xargs grep TAG_ | grep 'public static final' | ruby tools/gen.rb
|
|
7
|
+
|
|
8
|
+
def normalize_directory_name(path)
|
|
9
|
+
path.gsub('/', '.')
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def normalize_tag_name(capname)
|
|
13
|
+
name = capname.split('_').map {|e| e.capitalize }.join(' ')
|
|
14
|
+
[name, "TAG_#{capname}"]
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# 'ExifSubIFDDirectory' => 'Exif Sub IFD0'
|
|
18
|
+
def humanize_directory_name(s)
|
|
19
|
+
s = s.gsub('Directory', '')
|
|
20
|
+
s.split(/([A-Z]+[a-z]+)/).map {|a| a == "" ? nil : a }.compact.join(' ')
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
io = $stdin
|
|
24
|
+
directories = {}
|
|
25
|
+
|
|
26
|
+
io.readlines.each do |line|
|
|
27
|
+
# .../IptcDirectory.java: public static final int TAG_BY_LINE = 80;
|
|
28
|
+
if %r{Source/[/]?(?<directory_name>.*).java:.*TAG_(?<tag_name>[\S]+)} =~ line
|
|
29
|
+
directory_name = normalize_directory_name directory_name
|
|
30
|
+
directories[directory_name] ||= []
|
|
31
|
+
directories[directory_name] << normalize_tag_name(tag_name)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
directories.each do |directory, tag_names|
|
|
36
|
+
class_name = directory.split('.')[-1]
|
|
37
|
+
puts "class #{class_name} < Directory"
|
|
38
|
+
puts " java_import #{directory}"
|
|
39
|
+
puts ""
|
|
40
|
+
puts " def self.directory_class"
|
|
41
|
+
puts " #{directory}"
|
|
42
|
+
puts " end"
|
|
43
|
+
puts ""
|
|
44
|
+
puts " TAGS = {"
|
|
45
|
+
tag_names.each do |name, original_name|
|
|
46
|
+
puts " '#{name}' => ['#{original_name}', :get_string],"
|
|
47
|
+
end
|
|
48
|
+
puts " }"
|
|
49
|
+
puts "end"
|
|
50
|
+
puts ""
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
puts ""
|
|
54
|
+
puts "DIRECTORY_MAP = {"
|
|
55
|
+
directories.each do |directory, _|
|
|
56
|
+
class_name = directory.split('.')[-1]
|
|
57
|
+
puts " '#{humanize_directory_name(class_name)}' => #{class_name},"
|
|
58
|
+
end
|
|
59
|
+
puts "}"
|
|
60
|
+
|
|
61
|
+
|
|
Binary file
|
|
Binary file
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: image_voodoo
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Thomas E. Enebo, Charles Nutter, Nick Sieger
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2015-02-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Image manipulation in JRuby with ImageScience compatible API
|
|
14
14
|
email: tom.enebo@gmail.com
|
|
@@ -20,9 +20,12 @@ files:
|
|
|
20
20
|
- ".gitignore"
|
|
21
21
|
- ".hgignore"
|
|
22
22
|
- ".hgtags"
|
|
23
|
+
- ".travis.yml"
|
|
23
24
|
- History.txt
|
|
25
|
+
- LICENSE-2.0.txt
|
|
24
26
|
- LICENSE.txt
|
|
25
27
|
- Manifest.txt
|
|
28
|
+
- README.exif
|
|
26
29
|
- README.md
|
|
27
30
|
- Rakefile
|
|
28
31
|
- bin/image_voodoo
|
|
@@ -32,6 +35,7 @@ files:
|
|
|
32
35
|
- lib/image_voodoo/awt.rb
|
|
33
36
|
- lib/image_voodoo/awt/shapes.rb
|
|
34
37
|
- lib/image_voodoo/gae.rb
|
|
38
|
+
- lib/image_voodoo/metadata.rb
|
|
35
39
|
- lib/image_voodoo/version.rb
|
|
36
40
|
- samples/bench.rb
|
|
37
41
|
- samples/checkerboard.jpg
|
|
@@ -43,7 +47,11 @@ files:
|
|
|
43
47
|
- test/pix.png
|
|
44
48
|
- test/pix_cmyk.jpg
|
|
45
49
|
- test/test_image_science.rb
|
|
50
|
+
- test/test_metadata.rb
|
|
51
|
+
- tools/gen.rb
|
|
46
52
|
- vendor/CMYKDemo.jar
|
|
53
|
+
- vendor/metadata-extractor-2.7.0.jar
|
|
54
|
+
- vendor/xmpcore-5.1.2.jar
|
|
47
55
|
homepage: http://github.com/jruby/image_voodoo
|
|
48
56
|
licenses: []
|
|
49
57
|
metadata: {}
|
|
@@ -64,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
64
72
|
version: '0'
|
|
65
73
|
requirements: []
|
|
66
74
|
rubyforge_project: image_voodoo
|
|
67
|
-
rubygems_version: 2.
|
|
75
|
+
rubygems_version: 2.4.5
|
|
68
76
|
signing_key:
|
|
69
77
|
specification_version: 4
|
|
70
78
|
summary: Image manipulation in JRuby with ImageScience compatible API
|
|
@@ -72,3 +80,5 @@ test_files:
|
|
|
72
80
|
- test/pix.png
|
|
73
81
|
- test/pix_cmyk.jpg
|
|
74
82
|
- test/test_image_science.rb
|
|
83
|
+
- test/test_metadata.rb
|
|
84
|
+
has_rdoc: true
|