image_voodoo 0.9.0 → 0.9.1
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/.gitignore +1 -0
- data/.rubocop.yml +3 -11
- data/Gemfile +2 -0
- data/Rakefile +3 -1
- data/bin/image_voodoo +2 -0
- data/image_voodoo.gemspec +2 -3
- data/lib/image_science.rb +2 -0
- data/lib/image_voodoo/awt/core_ext/buffered_image.rb +2 -0
- data/lib/image_voodoo/awt/core_ext/graphics2d.rb +2 -0
- data/lib/image_voodoo/awt/shapes.rb +3 -1
- data/lib/image_voodoo/awt.rb +6 -0
- data/lib/image_voodoo/gae.rb +2 -0
- data/lib/image_voodoo/metadata.rb +9 -0
- data/lib/image_voodoo/needs_head.rb +2 -0
- data/lib/image_voodoo/version.rb +3 -1
- data/lib/image_voodoo.rb +6 -2
- data/samples/bench.rb +1 -0
- data/samples/file_greyscale.rb +2 -0
- data/samples/file_thumbnail.rb +2 -0
- data/samples/file_view.rb +2 -0
- data/samples/in_memory.rb +2 -0
- data/samples/lossy.rb +2 -0
- data/test/test_image_science.rb +2 -0
- data/test/test_image_voodoo.rb +2 -0
- data/test/test_metadata.rb +2 -0
- data/test/test_shapes.rb +2 -0
- data/tools/gen.rb +3 -0
- metadata +17 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5028b379cc34f48eb0851549a5f49a9ebd2495385d5fdbfe09d6b9fb0bdd006c
|
4
|
+
data.tar.gz: 873525e43dbfb68a86b664b19d19fa49d522e5312945f86d1939386d17369f94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee3af809b508d7cf1e4d880e155e487c19ce9579298d132b02d494edf2e63c681b0deed07b891b8d430f75fc6e3058c12fe7ad98fee47f704acdf4bc5abf8087
|
7
|
+
data.tar.gz: 50fd50f6ba4d34afc4b6585dfdeaeb2077a380ef1073522641253f89f7b2e5aa956174019e8275ee674a7cbad8287d22e42cd50fe2af5a576624bd0b577ce4e6
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -38,12 +38,12 @@ Metrics/AbcSize:
|
|
38
38
|
# in a table and then execute lambdas for each orientation but this is much
|
39
39
|
# more clear.
|
40
40
|
Metrics/CyclomaticComplexity:
|
41
|
-
Max:
|
41
|
+
Max: 10
|
42
42
|
|
43
43
|
# A bunch of fields in a hash are basically generated data. Correcting them
|
44
44
|
# for column seems much too pedantic. I guess exclude is the right thing for
|
45
45
|
# an unusual file?
|
46
|
-
|
46
|
+
Layout/LineLength:
|
47
47
|
Max: 132
|
48
48
|
Exclude:
|
49
49
|
- 'lib/image_voodoo/metadata.rb'
|
@@ -87,14 +87,6 @@ Metrics/BlockLength:
|
|
87
87
|
Exclude:
|
88
88
|
- 'bin/image_voodoo'
|
89
89
|
|
90
|
-
# casecmp for this case seems like it is much less readable in a place where
|
91
|
-
# performance could never matter (a 3-4 char downcase before processing an
|
92
|
-
# image :) ). This could end up being important somewhere but as a default
|
93
|
-
# on it feels weird since I find it less readable.
|
94
|
-
Performance/Casecmp:
|
95
|
-
Exclude:
|
96
|
-
- 'lib/image_voodoo/awt.rb'
|
97
|
-
|
98
90
|
# Hash rocket looks much more natural in a rakefile for its deps.
|
99
91
|
Style/HashSyntax:
|
100
92
|
Exclude:
|
@@ -120,7 +112,7 @@ Metrics/ParameterLists:
|
|
120
112
|
# w for width. Those probably could be written out but they are so common
|
121
113
|
# I am basically opting for short-hand. This is something I rarely do except
|
122
114
|
# domain-driven code like this (x,y,h,w).
|
123
|
-
Naming/
|
115
|
+
Naming/MethodParameterName:
|
124
116
|
Enabled: false
|
125
117
|
|
126
118
|
# This represents one of those frustrating dogmatic rules where if I followed
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'bundler'
|
2
4
|
require 'rake/testtask'
|
3
5
|
require 'jars/installer'
|
4
6
|
Bundler::GemHelper.install_tasks
|
5
7
|
Bundler.setup
|
6
8
|
|
7
|
-
task :default => [
|
9
|
+
task :default => %i[vendor_jars test]
|
8
10
|
|
9
11
|
desc 'Vendor Jars'
|
10
12
|
task :vendor_jars do
|
data/bin/image_voodoo
CHANGED
data/image_voodoo.gemspec
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
$LOAD_PATH.push File.expand_path('lib', __dir__)
|
4
5
|
require 'image_voodoo/version'
|
@@ -13,16 +14,14 @@ Gem::Specification.new do |s|
|
|
13
14
|
s.summary = 'Image manipulation in JRuby with ImageScience compatible API'
|
14
15
|
s.description = 'Image manipulation in JRuby with ImageScience compatible API'
|
15
16
|
|
16
|
-
s.rubyforge_project = 'image_voodoo'
|
17
|
-
|
18
17
|
s.files = `git ls-files`.split("\n")
|
19
18
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
21
20
|
s.require_paths = %w[lib vendor]
|
22
|
-
s.has_rdoc = true
|
23
21
|
|
24
22
|
s.add_development_dependency 'jar-dependencies'
|
25
23
|
s.add_development_dependency 'rake'
|
24
|
+
s.add_development_dependency 'rubocop'
|
26
25
|
s.add_development_dependency 'ruby-maven'
|
27
26
|
s.add_development_dependency 'test-unit'
|
28
27
|
|
data/lib/image_science.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class ImageVoodoo
|
2
4
|
# (Experimental) An attempt at some primitive drawing in images.
|
3
5
|
module Shapes
|
@@ -14,7 +16,7 @@ class ImageVoodoo
|
|
14
16
|
border_width = options[:width].to_i || 2
|
15
17
|
new_width, new_height = width + 2*border_width, height + 2*border_width
|
16
18
|
target = paint(BufferedImage.new(new_width, new_height, color_type)) do |g|
|
17
|
-
paint_border(g, new_width, new_height, options
|
19
|
+
paint_border(g, new_width, new_height, options)
|
18
20
|
g.draw_image(@src, nil, border_width, border_width)
|
19
21
|
end
|
20
22
|
block_given? ? yield(target) : target
|
data/lib/image_voodoo/awt.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'image_voodoo/awt/core_ext/buffered_image'
|
2
4
|
require 'image_voodoo/awt/core_ext/graphics2d'
|
3
5
|
require 'image_voodoo/awt/shapes'
|
@@ -132,7 +134,9 @@ class ImageVoodoo
|
|
132
134
|
|
133
135
|
def determine_format_from_file_name(file_name)
|
134
136
|
ext = file_name.split('.')[-1]
|
137
|
+
|
135
138
|
raise ArgumentError, "no extension in file name #{file_name}" unless ext
|
139
|
+
|
136
140
|
ext
|
137
141
|
end
|
138
142
|
|
@@ -182,7 +186,9 @@ class ImageVoodoo
|
|
182
186
|
# with an ArgumentError.
|
183
187
|
def hex_to_color(rgb='000000')
|
184
188
|
rgb ||= '000000'
|
189
|
+
|
185
190
|
raise ArgumentError, 'hex rrggbb needed' if rgb !~ /[[:xdigit:]]{6,6}/
|
191
|
+
|
186
192
|
Color.new(rgb[0, 2].to_i(16), rgb[2, 2].to_i(16), rgb[4, 2].to_i(16))
|
187
193
|
end
|
188
194
|
|
data/lib/image_voodoo/gae.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'image_voodoo_jars'
|
2
4
|
require 'stringio'
|
3
5
|
|
@@ -19,7 +21,9 @@ class ImageVoodoo
|
|
19
21
|
#
|
20
22
|
def [](dirname)
|
21
23
|
dirclass = DIRECTORY_MAP[dirname.to_s]
|
24
|
+
|
22
25
|
raise ArgumentError, "Uknown metadata group: #{dirname}" unless dirclass
|
26
|
+
|
23
27
|
dirclass.new @metadata
|
24
28
|
end
|
25
29
|
|
@@ -81,10 +85,15 @@ class ImageVoodoo
|
|
81
85
|
# defined.
|
82
86
|
def [](tag_name)
|
83
87
|
return nil unless @directory
|
88
|
+
|
84
89
|
(tag_type, tag_method) = self.class::TAGS[tag_name.to_s]
|
90
|
+
|
85
91
|
raise ArgumentError, "Unkown tag_name: #{tag_name}" unless tag_type
|
92
|
+
|
86
93
|
java_tag_type = self.class.directory_class.const_get tag_type
|
94
|
+
|
87
95
|
return nil unless @directory.contains_tag java_tag_type
|
96
|
+
|
88
97
|
@directory.__send__ tag_method, java_tag_type
|
89
98
|
end
|
90
99
|
end
|
data/lib/image_voodoo/version.rb
CHANGED
data/lib/image_voodoo.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Before we load image_voodoo we can specify whether we want it to load full
|
2
4
|
# AWT ala http://www.oracle.com/technetwork/articles/javase/headless-136834.html
|
3
5
|
# Most users are using image_voodoo as a library for manipulation and do not
|
@@ -156,8 +158,8 @@ class ImageVoodoo
|
|
156
158
|
def resize(width, height)
|
157
159
|
target = guard { resize_impl(width, height) }
|
158
160
|
block_given? ? yield(target) : target
|
159
|
-
rescue java.lang.Exception =>
|
160
|
-
raise ArgumentError,
|
161
|
+
rescue java.lang.Exception => e # figure out why this is here at all?
|
162
|
+
raise ArgumentError, e.message
|
161
163
|
end
|
162
164
|
|
163
165
|
# Rotates the image by angle (specified in degrees).
|
@@ -171,6 +173,7 @@ class ImageVoodoo
|
|
171
173
|
def save(file)
|
172
174
|
format = File.extname(file)
|
173
175
|
return false if format == ''
|
176
|
+
|
174
177
|
format = format[1..-1].downcase
|
175
178
|
guard { save_impl(format, JFile.new(file)) }
|
176
179
|
true
|
@@ -207,6 +210,7 @@ class ImageVoodoo
|
|
207
210
|
# A top-level image loader opens path and then yields/returns the image.
|
208
211
|
def self.with_image(path)
|
209
212
|
raise ArgumentError, "file does not exist: #{path}" unless File.file?(path)
|
213
|
+
|
210
214
|
image = guard { with_image_impl(JFile.new(path)) }
|
211
215
|
image && block_given? ? yield(image) : image
|
212
216
|
end
|
data/samples/bench.rb
CHANGED
data/samples/file_greyscale.rb
CHANGED
data/samples/file_thumbnail.rb
CHANGED
data/samples/file_view.rb
CHANGED
data/samples/in_memory.rb
CHANGED
data/samples/lossy.rb
CHANGED
data/test/test_image_science.rb
CHANGED
data/test/test_image_voodoo.rb
CHANGED
data/test/test_metadata.rb
CHANGED
data/test/test_shapes.rb
CHANGED
data/tools/gen.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Used to generate part of metadata.rb. Unfortunately, I am unable to fill
|
2
4
|
# in appropriate access methods so I generate with get_string and then manually
|
3
5
|
# update. In future versions I will just run this twice with old and new src
|
@@ -30,6 +32,7 @@ directories = {}
|
|
30
32
|
io.readlines.each do |line|
|
31
33
|
# .../IptcDirectory.java: public static final int TAG_BY_LINE = 80;
|
32
34
|
next if %r{Source/[/]?(?<dir_name>.*).java:.*TAG_(?<tag_name>[\S]+)} !~ line
|
35
|
+
|
33
36
|
directory_name = normalize_directory_name dir_name
|
34
37
|
directories[directory_name] ||= []
|
35
38
|
directories[directory_name] << normalize_tag_name(tag_name)
|
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.9.
|
4
|
+
version: 0.9.1
|
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: 2021-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
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: rubocop
|
48
|
+
prerelease: false
|
49
|
+
type: :development
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
requirement: !ruby/object:Gem::Requirement
|
43
57
|
requirements:
|
@@ -134,8 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
148
|
version: '0'
|
135
149
|
requirements:
|
136
150
|
- jar com.drewnoakes, metadata-extractor, 2.11.0
|
137
|
-
|
138
|
-
rubygems_version: 2.7.6
|
151
|
+
rubygems_version: 3.2.14
|
139
152
|
signing_key:
|
140
153
|
specification_version: 4
|
141
154
|
summary: Image manipulation in JRuby with ImageScience compatible API
|