image_voodoo 0.8.9 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +3 -0
- data/.rubocop.yml +61 -3
- data/.travis.yml +10 -2
- data/Gemfile +3 -0
- data/Jars.lock +3 -0
- data/Rakefile +10 -2
- data/bin/image_voodoo +1 -1
- data/image_voodoo.gemspec +8 -1
- data/lib/image_voodoo.rb +5 -6
- data/lib/image_voodoo/awt.rb +5 -4
- data/lib/image_voodoo/awt/core_ext/graphics2d.rb +0 -4
- data/lib/image_voodoo/metadata.rb +16 -3
- data/lib/image_voodoo/version.rb +1 -1
- data/samples/bench.rb +0 -0
- data/test/test_image_voodoo.rb +1 -1
- data/test/test_metadata.rb +8 -2
- metadata +67 -10
- data/vendor/metadata-extractor-2.7.0.jar +0 -0
- data/vendor/xmpcore-5.1.2.jar +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e110e54c634bb3970622f8b0e4fb180fa570e15c53b0ccf830d3ccaf1efed822
|
4
|
+
data.tar.gz: 34d6555550532df09c08f48d15c79d2b749573c85dc8e726bae1757b0249a189
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e4cf9fbf2a7d8045dd3a5be081ae2c1410cc71e327386f779b3f774d95fc4a1d174221e62cfc94c441e738e41e6e572e033f2c47da8e0c9759ca10cf4fcdd46
|
7
|
+
data.tar.gz: 50608dbcde4b2abc26877b0bafa91223e5a26f818dd398ad8b245dd630cc1ccd9fd8974cbaca0c0db63f493066fde7ba3d224464363fe4adbc9f44bb4b65ace7
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -69,17 +69,17 @@ Style/SpecialGlobalVars:
|
|
69
69
|
Enabled: false
|
70
70
|
|
71
71
|
# I am grouping math and using lack of whitespace for separation.
|
72
|
-
|
72
|
+
Layout/SpaceAroundOperators:
|
73
73
|
Enabled: false
|
74
74
|
|
75
75
|
# I prefer tight assignment for opt args.
|
76
|
-
|
76
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
77
77
|
Enabled: false
|
78
78
|
|
79
79
|
# Java methods which override or implement Java method names cannot be switched
|
80
80
|
# to snake case. Do we really need this as a rule anyways? I have never seen
|
81
81
|
# a Rubyist do this as a preferred style?
|
82
|
-
|
82
|
+
Naming/MethodName:
|
83
83
|
Enabled: false
|
84
84
|
|
85
85
|
# bin/image_voodoo main options block.
|
@@ -113,3 +113,61 @@ Style/ParallelAssignment:
|
|
113
113
|
Metrics/ParameterLists:
|
114
114
|
Exclude:
|
115
115
|
- 'lib/image_voodoo/awt/shapes.rb'
|
116
|
+
|
117
|
+
# This is complaining that 'x' and 'y' are bad names because they are less
|
118
|
+
# than 3 chars. Silly rule even if I appreciate what it is trying to
|
119
|
+
# accomplish. Interestingly, in image_voodoo I do use h for height and
|
120
|
+
# w for width. Those probably could be written out but they are so common
|
121
|
+
# I am basically opting for short-hand. This is something I rarely do except
|
122
|
+
# domain-driven code like this (x,y,h,w).
|
123
|
+
Naming/UncommunicativeMethodParamName:
|
124
|
+
Enabled: false
|
125
|
+
|
126
|
+
# This represents one of those frustrating dogmatic rules where if I followed
|
127
|
+
# this advice I would then violate the column length rule. I specifically
|
128
|
+
# use traditional if indented block in cases where if_mod doesn't fit.
|
129
|
+
# Gramatically, if_mod can be across two lines but I hate how that looks. The
|
130
|
+
# second solution of logical &&/|| change for a raise is alien to for all but
|
131
|
+
# assignment.
|
132
|
+
Style/IfUnlessModifier:
|
133
|
+
Enabled: false
|
134
|
+
|
135
|
+
# What the hell. Really telling people that encoding: utf-8 should not happen
|
136
|
+
# because there are no multi-byte utf-8 characters in it? Why add this noise?
|
137
|
+
Style/Encoding:
|
138
|
+
Enabled: false
|
139
|
+
|
140
|
+
# FIXME:
|
141
|
+
# This is an unknown error which I should figure out. It must be some
|
142
|
+
# StandardError (which is what nothing explicit means) but I should actually
|
143
|
+
# be more explicit here.
|
144
|
+
Style/RescueStandardError:
|
145
|
+
Exclude:
|
146
|
+
- 'lib/image_voodoo.rb'
|
147
|
+
|
148
|
+
|
149
|
+
# This was complaining metadata_impl should use @metadata_impl instead of
|
150
|
+
# @metadata. I disagree and am unsure why I need to follow this programs
|
151
|
+
# opinion on what a good name is? What is commentable is if I change the
|
152
|
+
# variable name to @gorgon it still tells me I need to use @metadata_impl.
|
153
|
+
# So if I conditionally add any state in any method it will tell me I am
|
154
|
+
# memoizing and have to use same ivar as the name of the method? Is it more
|
155
|
+
# sophisticated than that? Should I have spent 2-3 minutes trying to figure
|
156
|
+
# out how this rule was implemented? :)
|
157
|
+
Naming/MemoizedInstanceVariableName:
|
158
|
+
Enabled: false
|
159
|
+
|
160
|
+
# I have two modes of use for private. If it is a small number of individual
|
161
|
+
# methods I am explicit and inline the private. If it is a large number of
|
162
|
+
# methods especially when the name is fairly obvious that those will be private
|
163
|
+
# (like render_impl) then I use block private. Not sure telling me I can only
|
164
|
+
# use a single style is very useful.
|
165
|
+
Style/AccessModifierDeclarations:
|
166
|
+
Enabled: false
|
167
|
+
|
168
|
+
# I feel for the tiny amount of generation here a better name would not help
|
169
|
+
# me understand it better. This is one of those naming rules I feel is
|
170
|
+
# probably helpful a minority of the time. Also I have never been confused
|
171
|
+
# by what a heredoc text represents because of my heredoc terminator?
|
172
|
+
Naming/HeredocDelimiterNaming:
|
173
|
+
Enabled: false
|
data/.travis.yml
CHANGED
@@ -3,7 +3,15 @@ language: ruby
|
|
3
3
|
sudo: false
|
4
4
|
|
5
5
|
rvm:
|
6
|
-
- jruby-
|
6
|
+
- jruby-head
|
7
|
+
|
8
|
+
before_install:
|
9
|
+
- mkdir rvm_tmp
|
10
|
+
- cd rvm_tmp
|
7
11
|
|
8
12
|
before_script:
|
9
|
-
-
|
13
|
+
- cd ..
|
14
|
+
- git clone --depth 1 https://github.com/drewnoakes/metadata-extractor-images.git ../metadata-extractor-images
|
15
|
+
|
16
|
+
install: JRUBY_OPTS=--dev jruby --dev -S bundle install --jobs=3 --retry=3
|
17
|
+
|
data/Gemfile
ADDED
data/Jars.lock
ADDED
data/Rakefile
CHANGED
@@ -1,11 +1,19 @@
|
|
1
1
|
require 'bundler'
|
2
2
|
require 'rake/testtask'
|
3
|
+
require 'jars/installer'
|
3
4
|
Bundler::GemHelper.install_tasks
|
5
|
+
Bundler.setup
|
4
6
|
|
5
|
-
task :default => :test
|
7
|
+
task :default => [:vendor_jars, :test]
|
8
|
+
|
9
|
+
desc 'Vendor Jars'
|
10
|
+
task :vendor_jars do
|
11
|
+
test_file = File.expand_path File.join('lib', 'image_voodoo_jars.rb'), __dir__
|
12
|
+
Jars::Installer.vendor_jars! unless File.exist? test_file
|
13
|
+
end
|
6
14
|
|
7
15
|
desc 'Run tests'
|
8
|
-
task :test do
|
16
|
+
task :test => :vendor_jars do
|
9
17
|
Rake::TestTask.new do |t|
|
10
18
|
t.libs << 'lib:vendor'
|
11
19
|
t.test_files = FileList['test/test*.rb']
|
data/bin/image_voodoo
CHANGED
@@ -106,7 +106,7 @@ opts = OptionParser.new do |o|
|
|
106
106
|
end
|
107
107
|
|
108
108
|
o.on('--pop', 'Revert back to the previous image') do
|
109
|
-
actions << ->
|
109
|
+
actions << -> { images.pop || original_image }
|
110
110
|
end
|
111
111
|
|
112
112
|
o.on('-f', '--format', 'Print the image format') do
|
data/image_voodoo.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
|
-
$LOAD_PATH.push File.expand_path('
|
3
|
+
$LOAD_PATH.push File.expand_path('lib', __dir__)
|
4
4
|
require 'image_voodoo/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
@@ -20,4 +20,11 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
21
21
|
s.require_paths = %w[lib vendor]
|
22
22
|
s.has_rdoc = true
|
23
|
+
|
24
|
+
s.add_development_dependency 'jar-dependencies'
|
25
|
+
s.add_development_dependency 'rake'
|
26
|
+
s.add_development_dependency 'ruby-maven'
|
27
|
+
s.add_development_dependency 'test-unit'
|
28
|
+
|
29
|
+
s.requirements << 'jar com.drewnoakes, metadata-extractor, 2.11.0'
|
23
30
|
end
|
data/lib/image_voodoo.rb
CHANGED
@@ -31,7 +31,7 @@ end
|
|
31
31
|
# img = ImageVoodoo.with_image(ARGV[0])
|
32
32
|
# negative_img = img.negative
|
33
33
|
class ImageVoodoo
|
34
|
-
|
34
|
+
attr_writer :quality # used by quality(value)
|
35
35
|
|
36
36
|
include Java
|
37
37
|
|
@@ -95,12 +95,12 @@ class ImageVoodoo
|
|
95
95
|
# Creates a square thumbnail of the image cropping the longest edge to
|
96
96
|
# match the shortest edge, resizes to size, and yields/returns the new image.
|
97
97
|
def cropped_thumbnail(size)
|
98
|
-
l, t, r, b =
|
98
|
+
l, t, r, b = calculate_thumbnail_dimensions
|
99
99
|
target = with_crop(l, t, r, b).thumbnail(size)
|
100
100
|
block_given? ? yield(target) : target
|
101
101
|
end
|
102
102
|
|
103
|
-
def calculate_thumbnail_dimensions
|
103
|
+
private def calculate_thumbnail_dimensions
|
104
104
|
half = (width - height).abs / 2
|
105
105
|
if width > height
|
106
106
|
[half, 0, half + height, height]
|
@@ -108,7 +108,6 @@ class ImageVoodoo
|
|
108
108
|
[0, half, width, half + width]
|
109
109
|
end
|
110
110
|
end
|
111
|
-
private :calculate_thumbnail_dimensions
|
112
111
|
|
113
112
|
# Flips the image horizontally and yields/returns the new image.
|
114
113
|
def flip_horizontally
|
@@ -157,7 +156,7 @@ class ImageVoodoo
|
|
157
156
|
def resize(width, height)
|
158
157
|
target = guard { resize_impl(width, height) }
|
159
158
|
block_given? ? yield(target) : target
|
160
|
-
rescue
|
159
|
+
rescue java.lang.Exception => ne # figure out why this is here at all?
|
161
160
|
raise ArgumentError, ne.message
|
162
161
|
end
|
163
162
|
|
@@ -227,7 +226,7 @@ class ImageVoodoo
|
|
227
226
|
# support it. Otherwise, this method will detect that the method is
|
228
227
|
# missing.
|
229
228
|
def self.guard(&block)
|
230
|
-
|
229
|
+
block.call
|
231
230
|
rescue NoMethodError => e
|
232
231
|
"Unimplemented Feature: #{e}"
|
233
232
|
end
|
data/lib/image_voodoo/awt.rb
CHANGED
@@ -180,8 +180,8 @@ class ImageVoodoo
|
|
180
180
|
|
181
181
|
# Converts a RGB hex value into a java.awt.Color object or dies trying
|
182
182
|
# with an ArgumentError.
|
183
|
-
def hex_to_color(rgb='
|
184
|
-
rgb
|
183
|
+
def hex_to_color(rgb='000000')
|
184
|
+
rgb ||= '000000'
|
185
185
|
raise ArgumentError, 'hex rrggbb needed' if rgb !~ /[[:xdigit:]]{6,6}/
|
186
186
|
Color.new(rgb[0, 2].to_i(16), rgb[2, 2].to_i(16), rgb[4, 2].to_i(16))
|
187
187
|
end
|
@@ -248,9 +248,10 @@ class ImageVoodoo
|
|
248
248
|
when 2 then flip_horizontally
|
249
249
|
when 3 then rotate(180)
|
250
250
|
when 4 then flip_vertically
|
251
|
-
when 5 then flip_horizontally && rotate(
|
251
|
+
when 5 then flip_horizontally && rotate(90)
|
252
252
|
when 6 then rotate(90)
|
253
253
|
when 7 then flip_horizontally && rotate(270)
|
254
|
+
when 8 then rotate(270)
|
254
255
|
else self
|
255
256
|
end
|
256
257
|
end
|
@@ -290,7 +291,7 @@ class ImageVoodoo
|
|
290
291
|
def rotate_impl(radians)
|
291
292
|
new_width, new_height = rotate_new_dimensions(radians)
|
292
293
|
paint_new_buffered_image(new_width, new_height) do |g|
|
293
|
-
g.
|
294
|
+
g.translate (new_width - width) / 2, (new_height - height) / 2
|
294
295
|
g.rotate radians, width / 2, height / 2
|
295
296
|
g.draw_this_image @src
|
296
297
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require 'image_voodoo_jars'
|
2
|
+
require 'stringio'
|
3
3
|
|
4
4
|
class ImageVoodoo
|
5
5
|
# Metadata contained within the image.
|
@@ -46,6 +46,18 @@ class ImageVoodoo
|
|
46
46
|
def width
|
47
47
|
self['Exif Sub IFD']['Exif Image Width']
|
48
48
|
end
|
49
|
+
|
50
|
+
def to_s
|
51
|
+
out = StringIO.new
|
52
|
+
out.puts "[{dir name}] - {tag name} = {tag descr}"
|
53
|
+
out.puts "---------------------------------------"
|
54
|
+
@metadata.directories.each do |directory|
|
55
|
+
directory.tags.each do |tag|
|
56
|
+
out.puts "[#{directory.name}] - #{tag.tag_name} = #{tag.description}"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
out.string
|
60
|
+
end
|
49
61
|
end
|
50
62
|
|
51
63
|
# All metadata are contained within Directories. An image may have n
|
@@ -54,7 +66,8 @@ class ImageVoodoo
|
|
54
66
|
# directory.
|
55
67
|
class Directory
|
56
68
|
def initialize(metadata)
|
57
|
-
|
69
|
+
jclass = self.class.directory_class.java_class
|
70
|
+
@directory = metadata.get_first_directory_of_type jclass
|
58
71
|
end
|
59
72
|
|
60
73
|
##
|
data/lib/image_voodoo/version.rb
CHANGED
data/samples/bench.rb
CHANGED
File without changes
|
data/test/test_image_voodoo.rb
CHANGED
data/test/test_metadata.rb
CHANGED
@@ -13,8 +13,8 @@ if !File.exist? IMAGE_DIR
|
|
13
13
|
else
|
14
14
|
class TestImageVoodooMetadata < Test::Unit::TestCase
|
15
15
|
def setup
|
16
|
-
@path = File.join IMAGE_DIR, 'Apple iPhone 4S.jpg'
|
17
|
-
@path_gps = File.join IMAGE_DIR, 'Apple iPhone 4.jpg'
|
16
|
+
@path = File.join IMAGE_DIR, 'jpg', 'Apple iPhone 4S.jpg'
|
17
|
+
@path_gps = File.join IMAGE_DIR, 'jpg', 'Apple iPhone 4.jpg'
|
18
18
|
@path_no_exif = File.join File.dirname(__FILE__), 'pix.png'
|
19
19
|
end
|
20
20
|
|
@@ -53,5 +53,11 @@ else
|
|
53
53
|
assert_equal('N', img.metadata[:Gps]['Latitude Ref'])
|
54
54
|
end
|
55
55
|
end
|
56
|
+
|
57
|
+
def test_metadata_to_s
|
58
|
+
ImageVoodoo.with_image @path do |img|
|
59
|
+
assert img.metadata.to_s =~ /Make = Apple/
|
60
|
+
end
|
61
|
+
end
|
56
62
|
end
|
57
63
|
end
|
metadata
CHANGED
@@ -1,15 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: image_voodoo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas E. Enebo, Charles Nutter, Nick Sieger
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
11
|
+
date: 2019-02-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '0'
|
19
|
+
name: jar-dependencies
|
20
|
+
prerelease: false
|
21
|
+
type: :development
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
name: rake
|
34
|
+
prerelease: false
|
35
|
+
type: :development
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
name: ruby-maven
|
48
|
+
prerelease: false
|
49
|
+
type: :development
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
name: test-unit
|
62
|
+
prerelease: false
|
63
|
+
type: :development
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
13
69
|
description: Image manipulation in JRuby with ImageScience compatible API
|
14
70
|
email: tom.enebo@gmail.com
|
15
71
|
executables:
|
@@ -22,7 +78,9 @@ files:
|
|
22
78
|
- ".hgtags"
|
23
79
|
- ".rubocop.yml"
|
24
80
|
- ".travis.yml"
|
81
|
+
- Gemfile
|
25
82
|
- History.txt
|
83
|
+
- Jars.lock
|
26
84
|
- LICENSE-2.0.txt
|
27
85
|
- LICENSE.txt
|
28
86
|
- Manifest.txt
|
@@ -56,12 +114,10 @@ files:
|
|
56
114
|
- test/test_shapes.rb
|
57
115
|
- tools/gen.rb
|
58
116
|
- vendor/CMYKDemo.jar
|
59
|
-
- vendor/metadata-extractor-2.7.0.jar
|
60
|
-
- vendor/xmpcore-5.1.2.jar
|
61
117
|
homepage: http://github.com/jruby/image_voodoo
|
62
118
|
licenses: []
|
63
119
|
metadata: {}
|
64
|
-
post_install_message:
|
120
|
+
post_install_message:
|
65
121
|
rdoc_options: []
|
66
122
|
require_paths:
|
67
123
|
- lib
|
@@ -76,10 +132,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
132
|
- - ">="
|
77
133
|
- !ruby/object:Gem::Version
|
78
134
|
version: '0'
|
79
|
-
requirements:
|
135
|
+
requirements:
|
136
|
+
- jar com.drewnoakes, metadata-extractor, 2.11.0
|
80
137
|
rubyforge_project: image_voodoo
|
81
|
-
rubygems_version: 2.
|
82
|
-
signing_key:
|
138
|
+
rubygems_version: 2.7.6
|
139
|
+
signing_key:
|
83
140
|
specification_version: 4
|
84
141
|
summary: Image manipulation in JRuby with ImageScience compatible API
|
85
142
|
test_files:
|
Binary file
|
data/vendor/xmpcore-5.1.2.jar
DELETED
Binary file
|