pikl 0.2.2-x86-mswin32
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.
- data/History.txt +8 -0
- data/License.txt +21 -0
- data/Manifest.txt +37 -0
- data/README.txt +66 -0
- data/Rakefile +4 -0
- data/config/hoe.rb +89 -0
- data/config/requirements.rb +15 -0
- data/ext/pikl/pikl.h +264 -0
- data/ext/pikl/pikl_bitmap.c +152 -0
- data/ext/pikl/pikl_bitmap.h +18 -0
- data/ext/pikl/pikl_effect.c +191 -0
- data/ext/pikl/pikl_effect.h +20 -0
- data/ext/pikl/pikl_io.c +137 -0
- data/ext/pikl/pikl_io.h +27 -0
- data/ext/pikl/pikl_jpeg.c +161 -0
- data/ext/pikl/pikl_jpeg.h +22 -0
- data/ext/pikl/pikl_png.c +188 -0
- data/ext/pikl/pikl_png.h +17 -0
- data/ext/pikl/pikl_private.h +24 -0
- data/ext/pikl/pikl_resize.c +338 -0
- data/ext/pikl/pikl_resize.h +12 -0
- data/ext/pikl/pikl_rotate.c +70 -0
- data/ext/pikl/pikl_rotate.h +12 -0
- data/ext/pikl/pikl_trim.c +28 -0
- data/ext/pikl/pikl_trim.h +11 -0
- data/lib/pikl/const.rb +54 -0
- data/lib/pikl/errors.rb +7 -0
- data/lib/pikl/ext.rb +35 -0
- data/lib/pikl/image.rb +230 -0
- data/lib/pikl/pikl.dll +0 -0
- data/lib/pikl/version.rb +9 -0
- data/lib/pikl.rb +14 -0
- data/setup.rb +1585 -0
- data/test/sample.jpg +0 -0
- data/test/test_helper.rb +2 -0
- data/test/test_pikl_image.rb +268 -0
- metadata +95 -0
data/test/sample.jpg
ADDED
Binary file
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,268 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestPiklImage < Test::Unit::TestCase
|
4
|
+
|
5
|
+
SAMPLE_IMAGE = File.dirname(__FILE__) + '/sample.jpg'
|
6
|
+
SAMPLE_OUTPUT = File.dirname(__FILE__) + '/output.jpg'
|
7
|
+
|
8
|
+
SAMPLE_IMAGE_W = 120
|
9
|
+
SAMPLE_IMAGE_H = 160
|
10
|
+
|
11
|
+
def setup
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
def teardown
|
16
|
+
if File.exists? SAMPLE_OUTPUT
|
17
|
+
File.delete SAMPLE_OUTPUT
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_width_height
|
22
|
+
# + test open method without block.
|
23
|
+
img = Pikl::Image.open(SAMPLE_IMAGE)
|
24
|
+
assert_equal(SAMPLE_IMAGE_W, img.width)
|
25
|
+
assert_equal(SAMPLE_IMAGE_H, img.height)
|
26
|
+
img.close()
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_trim
|
31
|
+
Pikl::Image.open(SAMPLE_IMAGE) do |img|
|
32
|
+
|
33
|
+
img.trim(0,0,:auto,:auto)
|
34
|
+
assert_equal(SAMPLE_IMAGE_W, img.width)
|
35
|
+
assert_equal(SAMPLE_IMAGE_H, img.height)
|
36
|
+
img.save(SAMPLE_OUTPUT)
|
37
|
+
|
38
|
+
Pikl::Image.open(SAMPLE_OUTPUT) do |imgout|
|
39
|
+
assert_equal(SAMPLE_IMAGE_W,imgout.width)
|
40
|
+
assert_equal(SAMPLE_IMAGE_H,imgout.height)
|
41
|
+
end
|
42
|
+
|
43
|
+
img.trim(5,10,:auto,:auto)
|
44
|
+
assert_equal(SAMPLE_IMAGE_W-5, img.width)
|
45
|
+
assert_equal(SAMPLE_IMAGE_H-10, img.height)
|
46
|
+
img.save(SAMPLE_OUTPUT)
|
47
|
+
|
48
|
+
Pikl::Image.open(SAMPLE_OUTPUT) do |imgout|
|
49
|
+
assert_equal(SAMPLE_IMAGE_W-5, imgout.width)
|
50
|
+
assert_equal(SAMPLE_IMAGE_H-10, imgout.height)
|
51
|
+
end
|
52
|
+
|
53
|
+
img.trim(0,0,-1,-3)
|
54
|
+
assert_equal(SAMPLE_IMAGE_W-5-1, img.width)
|
55
|
+
assert_equal(SAMPLE_IMAGE_H-10-3, img.height)
|
56
|
+
img.save(SAMPLE_OUTPUT)
|
57
|
+
|
58
|
+
Pikl::Image.open(SAMPLE_OUTPUT) do |imgout|
|
59
|
+
assert_equal(SAMPLE_IMAGE_W-5-1, imgout.width)
|
60
|
+
assert_equal(SAMPLE_IMAGE_H-10-3, imgout.height)
|
61
|
+
end
|
62
|
+
|
63
|
+
img.trim(2,3,4,5)
|
64
|
+
assert_equal(4, img.width)
|
65
|
+
assert_equal(5, img.height)
|
66
|
+
img.save(SAMPLE_OUTPUT)
|
67
|
+
|
68
|
+
Pikl::Image.open(SAMPLE_OUTPUT) do |imgout|
|
69
|
+
assert_equal(4, imgout.width)
|
70
|
+
assert_equal(5, imgout.height)
|
71
|
+
end
|
72
|
+
|
73
|
+
#bad args
|
74
|
+
assert_raise(Pikl::ParameterException){img.trim(0,0,0,0)}
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_rotate
|
81
|
+
Pikl::Image.open(SAMPLE_IMAGE) do |img|
|
82
|
+
|
83
|
+
img.rotate(90)
|
84
|
+
assert_equal(SAMPLE_IMAGE_H, img.width)
|
85
|
+
assert_equal(SAMPLE_IMAGE_W, img.height)
|
86
|
+
img.save(SAMPLE_OUTPUT)
|
87
|
+
|
88
|
+
Pikl::Image.open(SAMPLE_OUTPUT) do |imgout|
|
89
|
+
assert_equal(SAMPLE_IMAGE_H,imgout.width)
|
90
|
+
assert_equal(SAMPLE_IMAGE_W,imgout.height)
|
91
|
+
end
|
92
|
+
|
93
|
+
img.rotate(90)
|
94
|
+
assert_equal(SAMPLE_IMAGE_W, img.width)
|
95
|
+
assert_equal(SAMPLE_IMAGE_H, img.height)
|
96
|
+
img.save(SAMPLE_OUTPUT)
|
97
|
+
|
98
|
+
Pikl::Image.open(SAMPLE_OUTPUT) do |imgout|
|
99
|
+
assert_equal(SAMPLE_IMAGE_W,imgout.width)
|
100
|
+
assert_equal(SAMPLE_IMAGE_H,imgout.height)
|
101
|
+
end
|
102
|
+
|
103
|
+
img.rotate(180)
|
104
|
+
assert_equal(SAMPLE_IMAGE_W, img.width)
|
105
|
+
assert_equal(SAMPLE_IMAGE_H, img.height)
|
106
|
+
img.save(SAMPLE_OUTPUT)
|
107
|
+
|
108
|
+
Pikl::Image.open(SAMPLE_OUTPUT) do |imgout|
|
109
|
+
assert_equal(SAMPLE_IMAGE_W,imgout.width)
|
110
|
+
assert_equal(SAMPLE_IMAGE_H,imgout.height)
|
111
|
+
end
|
112
|
+
|
113
|
+
img.rotate(270)
|
114
|
+
assert_equal(SAMPLE_IMAGE_H, img.width)
|
115
|
+
assert_equal(SAMPLE_IMAGE_W, img.height)
|
116
|
+
img.save(SAMPLE_OUTPUT)
|
117
|
+
|
118
|
+
Pikl::Image.open(SAMPLE_OUTPUT) do |imgout|
|
119
|
+
assert_equal(SAMPLE_IMAGE_H,imgout.width)
|
120
|
+
assert_equal(SAMPLE_IMAGE_W,imgout.height)
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_resize
|
127
|
+
Pikl::Image.open(SAMPLE_IMAGE) do |img|
|
128
|
+
img.resize(50,:auto)
|
129
|
+
img.save(SAMPLE_OUTPUT)
|
130
|
+
Pikl::Image.open(SAMPLE_OUTPUT) do |imgout|
|
131
|
+
assert_equal(50,imgout.width)
|
132
|
+
assert_equal((SAMPLE_IMAGE_H*50/SAMPLE_IMAGE_W).to_i,imgout.height)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def test_effect
|
138
|
+
Pikl::Image.open(SAMPLE_IMAGE) do |img|
|
139
|
+
img.unshapmask(255, 10)
|
140
|
+
img.save(SAMPLE_OUTPUT)
|
141
|
+
Pikl::Image.open(SAMPLE_OUTPUT) do |imgout|
|
142
|
+
assert_equal(SAMPLE_IMAGE_W,imgout.width)
|
143
|
+
assert_equal(SAMPLE_IMAGE_H,imgout.height)
|
144
|
+
end
|
145
|
+
|
146
|
+
img.contrast(127)
|
147
|
+
img.save(SAMPLE_OUTPUT)
|
148
|
+
Pikl::Image.open(SAMPLE_OUTPUT) do |imgout|
|
149
|
+
assert_equal(SAMPLE_IMAGE_W,imgout.width)
|
150
|
+
assert_equal(SAMPLE_IMAGE_H,imgout.height)
|
151
|
+
end
|
152
|
+
|
153
|
+
img.level(1.0, 0.1, 0.95)
|
154
|
+
img.save(SAMPLE_OUTPUT)
|
155
|
+
Pikl::Image.open(SAMPLE_OUTPUT) do |imgout|
|
156
|
+
assert_equal(SAMPLE_IMAGE_W,imgout.width)
|
157
|
+
assert_equal(SAMPLE_IMAGE_H,imgout.height)
|
158
|
+
end
|
159
|
+
|
160
|
+
img.brightness(1)
|
161
|
+
img.save(SAMPLE_OUTPUT)
|
162
|
+
Pikl::Image.open(SAMPLE_OUTPUT) do |imgout|
|
163
|
+
assert_equal(SAMPLE_IMAGE_W,imgout.width)
|
164
|
+
assert_equal(SAMPLE_IMAGE_H,imgout.height)
|
165
|
+
end
|
166
|
+
|
167
|
+
img.hls(1,1,113.2)
|
168
|
+
img.save(SAMPLE_OUTPUT)
|
169
|
+
Pikl::Image.open(SAMPLE_OUTPUT) do |imgout|
|
170
|
+
assert_equal(SAMPLE_IMAGE_W,imgout.width)
|
171
|
+
assert_equal(SAMPLE_IMAGE_H,imgout.height)
|
172
|
+
end
|
173
|
+
|
174
|
+
img.gamma(1.5)
|
175
|
+
img.save(SAMPLE_OUTPUT)
|
176
|
+
Pikl::Image.open(SAMPLE_OUTPUT) do |imgout|
|
177
|
+
assert_equal(SAMPLE_IMAGE_W,imgout.width)
|
178
|
+
assert_equal(SAMPLE_IMAGE_H,imgout.height)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
def test_validate_trim
|
184
|
+
Pikl::Image.open(SAMPLE_IMAGE) do |img|
|
185
|
+
assert_nil(img.validate_trim(0,0,1,1))
|
186
|
+
|
187
|
+
assert_raise(Pikl::ParameterException){img.validate_trim(0,0,0,0)}
|
188
|
+
assert_raise(Pikl::ParameterException){img.validate_trim(0,0,0,1)}
|
189
|
+
assert_raise(Pikl::ParameterException){img.validate_trim(0,0,1,0)}
|
190
|
+
|
191
|
+
assert_raise(Pikl::ParameterException){img.validate_trim("A",0,1,1)}
|
192
|
+
assert_raise(Pikl::ParameterException){img.validate_trim(0,"B",1,1)}
|
193
|
+
assert_raise(Pikl::ParameterException){img.validate_trim(0,0,"C",1)}
|
194
|
+
assert_raise(Pikl::ParameterException){img.validate_trim(0,0,1,"D")}
|
195
|
+
|
196
|
+
assert_nil(img.validate_trim(0,0,1,:auto))
|
197
|
+
assert_nil(img.validate_trim(0,0,:auto,1))
|
198
|
+
assert_nil(img.validate_trim(0,0,:auto,:auto))
|
199
|
+
|
200
|
+
assert_nil(img.validate_trim(0,0,1,Pikl::PIX_LIMIT))
|
201
|
+
assert_nil(img.validate_trim(0,0,Pikl::PIX_LIMIT,1))
|
202
|
+
assert_nil(img.validate_trim(0,0,Pikl::PIX_LIMIT,Pikl::PIX_LIMIT))
|
203
|
+
assert_raise(Pikl::ParameterException){img.validate_trim(0,0,1,Pikl::PIX_LIMIT+1)}
|
204
|
+
assert_raise(Pikl::ParameterException){img.validate_trim(0,0,Pikl::PIX_LIMIT+1,1)}
|
205
|
+
|
206
|
+
assert_nil(img.validate_trim(0,0,1,-1))
|
207
|
+
assert_nil(img.validate_trim(0,0,-1,1))
|
208
|
+
end
|
209
|
+
|
210
|
+
end
|
211
|
+
|
212
|
+
def test_validate_rotate
|
213
|
+
Pikl::Image.open(SAMPLE_IMAGE) do |img|
|
214
|
+
|
215
|
+
assert_raise(Pikl::ParameterException){img.validate_rotate(15)}
|
216
|
+
assert_nil(img.validate_rotate(0))
|
217
|
+
assert_nil(img.validate_rotate(90))
|
218
|
+
assert_nil(img.validate_rotate(180))
|
219
|
+
assert_nil(img.validate_rotate(270))
|
220
|
+
assert_nil(img.validate_rotate(360))
|
221
|
+
|
222
|
+
end
|
223
|
+
|
224
|
+
end
|
225
|
+
|
226
|
+
def test_validate_resize
|
227
|
+
Pikl::Image.open(SAMPLE_IMAGE) do |img|
|
228
|
+
|
229
|
+
assert_raise(Pikl::ParameterException){ img.validate_resize("hoge",900) }
|
230
|
+
assert_raise(Pikl::ParameterException){ img.validate_resize(600,"fuga") }
|
231
|
+
|
232
|
+
assert_raise(Pikl::ParameterException){img.validate_resize(30,Pikl::PIX_LIMIT+1)}
|
233
|
+
assert_raise(Pikl::ParameterException){img.validate_resize(Pikl::PIX_LIMIT+1,10)}
|
234
|
+
assert_nil(img.validate_resize(30,Pikl::PIX_LIMIT))
|
235
|
+
assert_nil(img.validate_resize(Pikl::PIX_LIMIT,10))
|
236
|
+
|
237
|
+
assert_raise(Pikl::ParameterException){img.validate_resize(30,0)}
|
238
|
+
assert_raise(Pikl::ParameterException){img.validate_resize(0,10)}
|
239
|
+
assert_nil(img.validate_resize(1,10))
|
240
|
+
assert_nil(img.validate_resize(10,1))
|
241
|
+
|
242
|
+
assert_raise(Pikl::ParameterException){img.validate_resize(:auto,:auto)}
|
243
|
+
assert_nil(img.validate_resize(600,:auto))
|
244
|
+
assert_nil(img.validate_resize(:auto,6))
|
245
|
+
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
def test_format
|
250
|
+
Pikl::Image.open(SAMPLE_IMAGE) do |img|
|
251
|
+
assert_equal(Pikl::JPEG, img.format)
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
def test_compress
|
256
|
+
Pikl::Image.open(SAMPLE_IMAGE) do |img|
|
257
|
+
img.trim(5,10,:auto,:auto)
|
258
|
+
img.save(SAMPLE_OUTPUT,Pikl::JPEG,5)
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
def test_method_chain
|
263
|
+
Pikl::Image.open(SAMPLE_IMAGE) do |img|
|
264
|
+
img.trim(5,10,:auto,:auto).rotate(90).resize(50,:auto).unshapmask(10,3).contrast(10).level(5,5,1.2).brightness(10).hls(0.1,0.1,355).gamma(1.2).save(SAMPLE_OUTPUT)
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pikl
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.2
|
5
|
+
platform: x86-mswin32
|
6
|
+
authors:
|
7
|
+
- Ryota Maruko
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-05-02 00:00:00 +09:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Pikl is an image librarry for ruby. This library aims easily image processing. Supports JPEG, PNG and BITMAP.
|
17
|
+
email:
|
18
|
+
- ""
|
19
|
+
executables: []
|
20
|
+
|
21
|
+
extensions: []
|
22
|
+
|
23
|
+
extra_rdoc_files:
|
24
|
+
- History.txt
|
25
|
+
- License.txt
|
26
|
+
- Manifest.txt
|
27
|
+
- README.txt
|
28
|
+
files:
|
29
|
+
- History.txt
|
30
|
+
- License.txt
|
31
|
+
- Manifest.txt
|
32
|
+
- README.txt
|
33
|
+
- Rakefile
|
34
|
+
- config/hoe.rb
|
35
|
+
- config/requirements.rb
|
36
|
+
- ext/pikl/pikl.h
|
37
|
+
- ext/pikl/pikl_bitmap.c
|
38
|
+
- ext/pikl/pikl_bitmap.h
|
39
|
+
- ext/pikl/pikl_effect.c
|
40
|
+
- ext/pikl/pikl_effect.h
|
41
|
+
- ext/pikl/pikl_io.c
|
42
|
+
- ext/pikl/pikl_io.h
|
43
|
+
- ext/pikl/pikl_jpeg.c
|
44
|
+
- ext/pikl/pikl_jpeg.h
|
45
|
+
- ext/pikl/pikl_png.c
|
46
|
+
- ext/pikl/pikl_png.h
|
47
|
+
- ext/pikl/pikl_private.h
|
48
|
+
- ext/pikl/pikl_resize.c
|
49
|
+
- ext/pikl/pikl_resize.h
|
50
|
+
- ext/pikl/pikl_rotate.c
|
51
|
+
- ext/pikl/pikl_rotate.h
|
52
|
+
- ext/pikl/pikl_trim.c
|
53
|
+
- ext/pikl/pikl_trim.h
|
54
|
+
- lib/pikl.rb
|
55
|
+
- lib/pikl/const.rb
|
56
|
+
- lib/pikl/errors.rb
|
57
|
+
- lib/pikl/ext.rb
|
58
|
+
- lib/pikl/image.rb
|
59
|
+
- lib/pikl/pikl.dll
|
60
|
+
- lib/pikl/version.rb
|
61
|
+
- setup.rb
|
62
|
+
- test/sample.jpg
|
63
|
+
- test/test_helper.rb
|
64
|
+
- test/test_pikl_image.rb
|
65
|
+
has_rdoc: true
|
66
|
+
homepage: http://pikl.rubyforge.org
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options:
|
69
|
+
- --main
|
70
|
+
- README.txt
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
- ext
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: "0"
|
79
|
+
version:
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: "0"
|
85
|
+
version:
|
86
|
+
requirements: []
|
87
|
+
|
88
|
+
rubyforge_project: pikl-mswin32
|
89
|
+
rubygems_version: 1.0.1
|
90
|
+
signing_key:
|
91
|
+
specification_version: 2
|
92
|
+
summary: Pikl is an image librarry for ruby. This library aims easily image processing. Supports JPEG, PNG and BITMAP.
|
93
|
+
test_files:
|
94
|
+
- test/test_helper.rb
|
95
|
+
- test/test_pikl_image.rb
|