axon 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +6 -0
- data/README.rdoc +23 -49
- data/Rakefile +33 -7
- data/TODO.rdoc +6 -1
- data/ext/axon/jpeg.c +32 -66
- data/ext/axon/png.c +46 -71
- data/ext/java/axon/AxonService.java +15 -0
- data/ext/java/axon/Interpolation.java +127 -0
- data/ext/java/axon/JPEG.java +119 -0
- data/ext/java/axon/JPEGReader.java +185 -0
- data/ext/java/axon/PNG.java +47 -0
- data/ext/java/axon/PNGReader.java +164 -0
- data/ext/java/axon/RubyImage.java +216 -0
- data/lib/axon.rb +93 -7
- data/lib/axon/alpha_stripper.rb +69 -0
- data/lib/axon/axon.jar +0 -0
- data/lib/axon/cropper.rb +6 -10
- data/lib/axon/fit.rb +53 -35
- data/lib/axon/generators.rb +1 -10
- data/lib/axon/scalers.rb +2 -16
- data/test/helper.rb +7 -9
- data/test/reader_tests.rb +0 -8
- data/test/test_alpha_stripper.rb +33 -0
- data/test/test_fit.rb +38 -0
- data/test/test_jpeg_reader.rb +49 -26
- data/test/test_jpeg_writer.rb +8 -0
- data/test/writer_tests.rb +51 -40
- metadata +96 -87
data/test/test_jpeg_reader.rb
CHANGED
@@ -16,10 +16,12 @@ module Axon
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_in_color_model
|
19
|
+
skip unless @reader.respond_to?(:in_color_model)
|
19
20
|
assert_equal :YCbCr, @reader.in_color_model
|
20
21
|
end
|
21
22
|
|
22
23
|
def test_set_in_color_model
|
24
|
+
skip unless @reader.respond_to?(:in_color_model=)
|
23
25
|
@reader.in_color_model = :RGB
|
24
26
|
assert_equal :RGB, @reader.in_color_model
|
25
27
|
|
@@ -27,6 +29,7 @@ module Axon
|
|
27
29
|
end
|
28
30
|
|
29
31
|
def test_set_out_color_model
|
32
|
+
skip unless @reader.respond_to?(:color_model=)
|
30
33
|
@reader.color_model = :YCbCr
|
31
34
|
assert_equal :YCbCr, @reader.color_model
|
32
35
|
|
@@ -34,74 +37,94 @@ module Axon
|
|
34
37
|
end
|
35
38
|
|
36
39
|
def test_scale_num
|
40
|
+
skip unless @reader.respond_to?(:scale_num)
|
37
41
|
assert @reader.scale_num > 0
|
38
42
|
end
|
39
43
|
|
40
44
|
def test_set_scale_num
|
45
|
+
skip unless @reader.respond_to?(:scale_num=)
|
41
46
|
@reader.scale_num = 5
|
42
47
|
assert_equal 5, @reader.scale_num
|
43
48
|
end
|
44
49
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
def test_set_scale_denom
|
51
|
-
@reader.scale_denom = 8
|
52
|
-
assert_equal 8, @reader.scale_denom
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_scale_denom_affects_image_size
|
56
|
-
pre_width = @reader.width
|
57
|
-
pre_height = @reader.height
|
50
|
+
def test_scale_denom
|
51
|
+
skip unless @reader.respond_to?(:scale_denom)
|
52
|
+
assert @reader.scale_denom > 0
|
53
|
+
end
|
58
54
|
|
59
|
-
|
55
|
+
def test_set_scale_denom
|
56
|
+
skip unless @reader.respond_to?(:scale_denom=)
|
57
|
+
@reader.scale_denom = 8
|
58
|
+
assert_equal 8, @reader.scale_denom
|
59
|
+
end
|
60
60
|
|
61
|
-
|
62
|
-
|
61
|
+
def test_scale_denom_affects_image_size
|
62
|
+
skip unless @reader.respond_to?(:scale_denom=)
|
63
|
+
pre_width = @reader.width
|
64
|
+
pre_height = @reader.height
|
65
|
+
|
66
|
+
@reader.scale_denom = 2
|
67
|
+
|
68
|
+
if JPEG::LIB_VERSION >= 70
|
69
|
+
# I can't really explain why this doubles our dimensions. The
|
70
|
+
# jpeg decompressor reports 8 / 2 for scale_num / scale_denom.
|
71
|
+
assert_equal pre_width * 2, @reader.width
|
72
|
+
assert_equal pre_height * 2, @reader.height
|
73
|
+
else
|
74
|
+
assert_equal pre_width / 2, @reader.width
|
75
|
+
assert_equal pre_height / 2, @reader.height
|
63
76
|
end
|
77
|
+
end
|
64
78
|
|
65
|
-
|
66
|
-
|
67
|
-
|
79
|
+
def test_scale_denom_affects_written_image
|
80
|
+
skip unless @reader.respond_to?(:scale_denom=)
|
81
|
+
pre_width = @reader.width
|
82
|
+
pre_height = @reader.height
|
68
83
|
|
69
|
-
|
84
|
+
@reader.scale_denom = 2
|
70
85
|
|
71
|
-
|
72
|
-
|
73
|
-
|
86
|
+
io_out = StringIO.new
|
87
|
+
JPEG.write(@reader, io_out)
|
88
|
+
io_out.rewind
|
74
89
|
|
75
|
-
|
90
|
+
new_velvet_reader = Reader.new(io_out)
|
76
91
|
|
77
|
-
|
78
|
-
|
92
|
+
if JPEG::LIB_VERSION >= 70
|
93
|
+
assert_image_dimensions(new_velvet_reader, pre_width * 2, pre_height * 2)
|
94
|
+
else
|
95
|
+
assert_image_dimensions(new_velvet_reader, pre_width / 2, pre_height / 2)
|
79
96
|
end
|
80
97
|
end
|
81
98
|
|
82
99
|
def test_dct_method
|
100
|
+
skip unless @reader.respond_to?(:dct_method)
|
83
101
|
assert_equal Reader::DEFAULT_DCT, @reader.dct_method
|
84
102
|
end
|
85
103
|
|
86
104
|
def test_set_dct_method
|
105
|
+
skip unless @reader.respond_to?(:dct_method=)
|
87
106
|
@reader.dct_method = :IFAST
|
88
107
|
assert_equal :IFAST, @reader.dct_method
|
89
108
|
end
|
90
109
|
|
91
110
|
def test_markers_read_by_default
|
111
|
+
skip "JRuby ImageIO does not give access to headers" if(RUBY_PLATFORM =~ /java/)
|
92
112
|
refute_empty @reader[:APP0]
|
93
113
|
end
|
94
114
|
|
95
115
|
def test_empty_marker_prevents_reads
|
116
|
+
skip "JRuby ImageIO does not give access to headers" if(RUBY_PLATFORM =~ /java/)
|
96
117
|
r = Reader.new StringIO.new(@data), []
|
97
118
|
assert_empty r[:APP0]
|
98
119
|
end
|
99
120
|
|
100
121
|
def test_marker_content
|
122
|
+
skip "JRuby ImageIO does not give access to headers" if(RUBY_PLATFORM =~ /java/)
|
101
123
|
assert_match(/^JFIF/, @reader[:APP0].first)
|
102
124
|
end
|
103
125
|
|
104
126
|
def test_no_configuration_after_initiated
|
127
|
+
skip unless @reader.respond_to?(:dct_method)
|
105
128
|
@reader.gets
|
106
129
|
assert_raises(RuntimeError) { @reader.dct_method = :IFAST }
|
107
130
|
assert_raises(RuntimeError) { @reader.scale_denom = 4 }
|
data/test/test_jpeg_writer.rb
CHANGED
@@ -17,6 +17,7 @@ module Axon
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def test_invalid_bufsize
|
20
|
+
skip "JRuby's JPEG writer doesn't accept a buffer size" if(RUBY_PLATFORM =~ /java/)
|
20
21
|
assert_raises RuntimeError do
|
21
22
|
JPEG.write(@image, @io_out, :bufsize => 0)
|
22
23
|
end
|
@@ -27,6 +28,7 @@ module Axon
|
|
27
28
|
end
|
28
29
|
|
29
30
|
def test_symbol_bufsize
|
31
|
+
skip_symbol_fixnums
|
30
32
|
assert_raises TypeError do
|
31
33
|
JPEG.write(@image, @io_out, :bufsize => :foo)
|
32
34
|
end
|
@@ -55,12 +57,14 @@ module Axon
|
|
55
57
|
end
|
56
58
|
|
57
59
|
def test_symbol_quality
|
60
|
+
skip_symbol_fixnums
|
58
61
|
assert_raises TypeError do
|
59
62
|
JPEG.write(@image, @io_out, :quality => :foo)
|
60
63
|
end
|
61
64
|
end
|
62
65
|
|
63
66
|
def test_exif_roundtrip
|
67
|
+
skip unless JPEG::Reader.allocate.respond_to?(:exif)
|
64
68
|
random_data = ""
|
65
69
|
(100).times do
|
66
70
|
random_data << [rand].pack('d') # 800 bytes random data
|
@@ -75,6 +79,9 @@ module Axon
|
|
75
79
|
end
|
76
80
|
|
77
81
|
def test_exif_with_icc_roundtrip
|
82
|
+
skip unless JPEG::Reader.allocate.respond_to?(:exif)
|
83
|
+
skip unless JPEG::Reader.allocate.respond_to?(:icc_profile)
|
84
|
+
|
78
85
|
random_icc_data = ""
|
79
86
|
(2**16).times do # a little larger than one jpeg segment
|
80
87
|
random_icc_data << [rand].pack('d') # 8 bytes random data
|
@@ -97,6 +104,7 @@ module Axon
|
|
97
104
|
end
|
98
105
|
|
99
106
|
def test_large_icc_roundtrip
|
107
|
+
skip "JRuby ImageIO gives us a different icc profile than provided" if(RUBY_PLATFORM =~ /java/)
|
100
108
|
random_data = ""
|
101
109
|
(2**16).times do # a little larger than one jpeg segment
|
102
110
|
random_data << [rand].pack('d') # 8 bytes random data
|
data/test/writer_tests.rb
CHANGED
@@ -18,11 +18,16 @@ module Axon
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
def test_nil_height
|
22
|
+
assert_raises TypeError, "should throw a TypeError when given nil for height." do
|
23
|
+
@mod.write(CustomHeightImage.new(nil), @io_out)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_symbol_height
|
28
|
+
skip_symbol_fixnums
|
29
|
+
assert_raises TypeError, "should throw a TypeError when given a symbol for height." do
|
30
|
+
@mod.write(CustomHeightImage.new(:foo), @io_out)
|
26
31
|
end
|
27
32
|
end
|
28
33
|
|
@@ -41,35 +46,21 @@ module Axon
|
|
41
46
|
end
|
42
47
|
end
|
43
48
|
|
44
|
-
def
|
45
|
-
|
46
|
-
|
47
|
-
@mod.write(CustomWidthImage.new(w), @io_out)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_width_raises_exception
|
53
|
-
im = CustomWidthImage.new(Proc.new{ raise CustomError })
|
54
|
-
assert_raises CustomError do
|
55
|
-
@mod.write(im, @io_out)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_nil_image_color_model
|
60
|
-
assert_raises TypeError do
|
61
|
-
@mod.write(CustomColorModelImage.new(nil), @io_out)
|
49
|
+
def test_nil_width
|
50
|
+
assert_raises TypeError, "should throw a TypeError when given nil for width." do
|
51
|
+
@mod.write(CustomWidthImage.new(nil), @io_out)
|
62
52
|
end
|
63
53
|
end
|
64
54
|
|
65
|
-
def
|
66
|
-
|
67
|
-
|
55
|
+
def test_symbol_width
|
56
|
+
skip_symbol_fixnums
|
57
|
+
assert_raises TypeError, "should throw a TypeError when given a symbol for width." do
|
58
|
+
@mod.write(CustomWidthImage.new(:foo), @io_out)
|
68
59
|
end
|
69
60
|
end
|
70
61
|
|
71
|
-
def
|
72
|
-
im =
|
62
|
+
def test_width_raises_exception
|
63
|
+
im = CustomWidthImage.new(Proc.new{ raise CustomError })
|
73
64
|
assert_raises CustomError do
|
74
65
|
@mod.write(im, @io_out)
|
75
66
|
end
|
@@ -83,19 +74,29 @@ module Axon
|
|
83
74
|
end
|
84
75
|
end
|
85
76
|
|
86
|
-
def
|
87
|
-
|
88
|
-
|
89
|
-
@mod.write(CustomComponentsImage.new(w), @io_out)
|
90
|
-
end
|
77
|
+
def test_nil_components
|
78
|
+
assert_raises TypeError do
|
79
|
+
@mod.write(CustomComponentsImage.new(nil), @io_out)
|
91
80
|
end
|
92
81
|
end
|
93
82
|
|
94
|
-
def
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
83
|
+
def test_symbol_components
|
84
|
+
skip_symbol_fixnums
|
85
|
+
assert_raises TypeError do
|
86
|
+
@mod.write(CustomComponentsImage.new(:foo), @io_out)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_nil_components
|
91
|
+
assert_raises TypeError, "should throw a TypeError when given nil for components." do
|
92
|
+
@mod.write(CustomComponentsImage.new(nil), @io_out)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_symbol_components
|
97
|
+
skip_symbol_fixnums
|
98
|
+
assert_raises TypeError, "should throw a TypeError when given a symbol for components." do
|
99
|
+
@mod.write(CustomComponentsImage.new(:foo), @io_out)
|
99
100
|
end
|
100
101
|
end
|
101
102
|
|
@@ -110,7 +111,7 @@ module Axon
|
|
110
111
|
[-1, nil, :foo].each do |l|
|
111
112
|
# we don't know if the writer will care but test anyways to detect
|
112
113
|
# interpreter crashes and mem leaks.
|
113
|
-
@mod.write(CustomLinenoImage.new(l), @io_out)
|
114
|
+
@mod.write(CustomLinenoImage.new(l), @io_out) rescue nil
|
114
115
|
end
|
115
116
|
end
|
116
117
|
|
@@ -178,7 +179,8 @@ module Axon
|
|
178
179
|
end
|
179
180
|
|
180
181
|
def test_io_returns_invalid_type
|
181
|
-
|
182
|
+
skip "JRuby doesn't mind odd io returns" if(RUBY_PLATFORM =~ /java/)
|
183
|
+
[nil, "bar"].each do |r|
|
182
184
|
im = Solid.new(200, 100)
|
183
185
|
assert_raises TypeError, "should get a TypeError when IO#write returns a #{r.class}." do
|
184
186
|
@mod.write(im, CustomIO.new(r))
|
@@ -186,7 +188,16 @@ module Axon
|
|
186
188
|
end
|
187
189
|
end
|
188
190
|
|
191
|
+
def test_io_returns_symbol
|
192
|
+
skip_symbol_fixnums
|
193
|
+
im = Solid.new(200, 100)
|
194
|
+
assert_raises TypeError, "should get a TypeError when IO#write returns a symbol." do
|
195
|
+
@mod.write(im, CustomIO.new(:foo))
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
189
199
|
def test_io_returns_invalid_length
|
200
|
+
skip "JRuby doesn't mind odd io returns" if(RUBY_PLATFORM =~ /java/)
|
190
201
|
[0, -1, -100, 2000, 1].each do |r|
|
191
202
|
assert_raises RuntimeError do
|
192
203
|
@mod.write(@image, CustomIO.new(r))
|
metadata
CHANGED
@@ -1,108 +1,117 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: axon
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.1
|
3
|
+
version: !ruby/object:Gem::Version
|
5
4
|
prerelease:
|
5
|
+
version: 0.2.0
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
8
|
-
- Timothy Elliott
|
7
|
+
authors:
|
8
|
+
- Timothy Elliott
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-06 00:00:00.000000000Z
|
13
|
-
dependencies: []
|
14
|
-
description: ! 'axon reads, manipulates, and writes images.
|
15
|
-
|
16
|
-
|
17
|
-
axon depends only on libjpeg and libpng.
|
18
12
|
|
13
|
+
date: 2012-01-24 00:00:00 Z
|
14
|
+
dependencies: []
|
19
15
|
|
20
|
-
|
21
|
-
|
22
|
-
|
16
|
+
description: |
|
17
|
+
Read, manipulate, and write images with an emphasis on speed and a low memory
|
18
|
+
profile.
|
23
19
|
|
24
|
-
'
|
25
20
|
email: tle@holymonkey.com
|
26
21
|
executables: []
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
-
|
32
|
-
-
|
33
|
-
|
34
|
-
|
35
|
-
-
|
36
|
-
-
|
37
|
-
- CHANGELOG.rdoc
|
38
|
-
-
|
39
|
-
- lib/axon
|
40
|
-
- lib/axon/
|
41
|
-
- lib/axon/cropper.rb
|
42
|
-
- lib/axon/
|
43
|
-
-
|
44
|
-
-
|
45
|
-
-
|
46
|
-
- ext/axon/
|
47
|
-
- ext/axon/
|
48
|
-
- ext/axon/
|
49
|
-
- ext/axon/
|
50
|
-
-
|
51
|
-
-
|
52
|
-
-
|
53
|
-
-
|
54
|
-
-
|
55
|
-
-
|
56
|
-
-
|
57
|
-
-
|
58
|
-
-
|
59
|
-
-
|
60
|
-
- test/
|
61
|
-
- test/
|
62
|
-
- test/
|
63
|
-
- test/
|
64
|
-
- test/
|
65
|
-
- test/
|
66
|
-
- .
|
22
|
+
|
23
|
+
extensions:
|
24
|
+
- ext/axon/extconf.rb
|
25
|
+
extra_rdoc_files:
|
26
|
+
- README.rdoc
|
27
|
+
- CHANGELOG.rdoc
|
28
|
+
- TODO.rdoc
|
29
|
+
files:
|
30
|
+
- Rakefile
|
31
|
+
- README.rdoc
|
32
|
+
- CHANGELOG.rdoc
|
33
|
+
- TODO.rdoc
|
34
|
+
- lib/axon.rb
|
35
|
+
- lib/axon/fit.rb
|
36
|
+
- lib/axon/cropper.rb
|
37
|
+
- lib/axon/scalers.rb
|
38
|
+
- lib/axon/alpha_stripper.rb
|
39
|
+
- lib/axon/generators.rb
|
40
|
+
- lib/axon/axon.jar
|
41
|
+
- ext/axon/interpolation.c
|
42
|
+
- ext/axon/png.c
|
43
|
+
- ext/axon/jpeg.c
|
44
|
+
- ext/axon/axon.c
|
45
|
+
- ext/axon/iccjpeg.c
|
46
|
+
- ext/axon/iccjpeg.h
|
47
|
+
- ext/axon/extconf.rb
|
48
|
+
- ext/java/axon/JPEG.java
|
49
|
+
- ext/java/axon/RubyImage.java
|
50
|
+
- ext/java/axon/PNG.java
|
51
|
+
- ext/java/axon/Interpolation.java
|
52
|
+
- ext/java/axon/AxonService.java
|
53
|
+
- ext/java/axon/JPEGReader.java
|
54
|
+
- ext/java/axon/PNGReader.java
|
55
|
+
- test/stress_helper.rb
|
56
|
+
- test/test_image.rb
|
57
|
+
- test/test_png_writer.rb
|
58
|
+
- test/test_fit.rb
|
59
|
+
- test/test_generators.rb
|
60
|
+
- test/test_bilinear_scaler.rb
|
61
|
+
- test/test_nearest_neighbor_scaler.rb
|
62
|
+
- test/test_jpeg_writer.rb
|
63
|
+
- test/stress_tests.rb
|
64
|
+
- test/test_cropper.rb
|
65
|
+
- test/test_jpeg_reader.rb
|
66
|
+
- test/test_png_reader.rb
|
67
|
+
- test/helper.rb
|
68
|
+
- test/writer_tests.rb
|
69
|
+
- test/test_alpha_stripper.rb
|
70
|
+
- test/reader_tests.rb
|
71
|
+
- test/scaler_tests.rb
|
72
|
+
- .gemtest
|
67
73
|
homepage: http://github.com/ender672/axon
|
68
74
|
licenses: []
|
75
|
+
|
69
76
|
post_install_message:
|
70
77
|
rdoc_options: []
|
71
|
-
|
72
|
-
|
73
|
-
-
|
74
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
82
|
none: false
|
76
|
-
requirements:
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: "0"
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
88
|
none: false
|
82
|
-
requirements:
|
83
|
-
|
84
|
-
|
85
|
-
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: "0"
|
86
93
|
requirements: []
|
94
|
+
|
87
95
|
rubyforge_project:
|
88
|
-
rubygems_version: 1.8.
|
96
|
+
rubygems_version: 1.8.15
|
89
97
|
signing_key:
|
90
98
|
specification_version: 3
|
91
|
-
summary:
|
92
|
-
test_files:
|
93
|
-
- test/
|
94
|
-
- test/
|
95
|
-
- test/
|
96
|
-
- test/
|
97
|
-
- test/
|
98
|
-
- test/
|
99
|
-
- test/
|
100
|
-
- test/
|
101
|
-
- test/
|
102
|
-
- test/
|
103
|
-
- test/test_jpeg_reader.rb
|
104
|
-
- test/
|
105
|
-
- test/
|
106
|
-
- test/writer_tests.rb
|
107
|
-
- test/
|
108
|
-
- test/
|
99
|
+
summary: Read, write and resize images.
|
100
|
+
test_files:
|
101
|
+
- test/stress_helper.rb
|
102
|
+
- test/test_image.rb
|
103
|
+
- test/test_png_writer.rb
|
104
|
+
- test/test_fit.rb
|
105
|
+
- test/test_generators.rb
|
106
|
+
- test/test_bilinear_scaler.rb
|
107
|
+
- test/test_nearest_neighbor_scaler.rb
|
108
|
+
- test/test_jpeg_writer.rb
|
109
|
+
- test/stress_tests.rb
|
110
|
+
- test/test_cropper.rb
|
111
|
+
- test/test_jpeg_reader.rb
|
112
|
+
- test/test_png_reader.rb
|
113
|
+
- test/helper.rb
|
114
|
+
- test/writer_tests.rb
|
115
|
+
- test/test_alpha_stripper.rb
|
116
|
+
- test/reader_tests.rb
|
117
|
+
- test/scaler_tests.rb
|