pikl 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +3 -0
- data/Manifest.txt +0 -1
- data/config/hoe.rb +1 -1
- data/lib/pikl/image.rb +15 -0
- data/lib/pikl/version.rb +1 -1
- data/test/test_pikl_image.rb +55 -0
- metadata +47 -41
- data/Rakefile +0 -4
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
data/config/hoe.rb
CHANGED
@@ -61,7 +61,7 @@ $hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
|
61
61
|
p.description = DESCRIPTION
|
62
62
|
p.summary = DESCRIPTION
|
63
63
|
p.url = HOMEPATH
|
64
|
-
p.rubyforge_name = (PACKAGE_PLATFORM =~ /mswin32/) ? "#{GEM_NAME}-
|
64
|
+
p.rubyforge_name = (PACKAGE_PLATFORM =~ /mswin32/) ? "#{GEM_NAME}-mswin32" : GEM_NAME
|
65
65
|
|
66
66
|
p.test_globs = ["test/**/test_*.rb"]
|
67
67
|
p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
|
data/lib/pikl/image.rb
CHANGED
@@ -82,6 +82,21 @@ module Pikl
|
|
82
82
|
self
|
83
83
|
end
|
84
84
|
|
85
|
+
def fit(width, height, mode = :inner)
|
86
|
+
error("invalid mode parameter. # => #{mode}") unless [:inner, :outer].include?(mode)
|
87
|
+
self.send("fit_#{mode.to_s}", width, height)
|
88
|
+
end
|
89
|
+
|
90
|
+
def fit_inner(width, height)
|
91
|
+
to_w, to_h = ((width.to_f / self.width.to_f) < (height.to_f / self.height.to_f)) ? [width, :auto] : [:auto, height]
|
92
|
+
resize(to_w,to_h)
|
93
|
+
end
|
94
|
+
|
95
|
+
def fit_outer(width, height)
|
96
|
+
to_w, to_h = ((width.to_f / self.width.to_f) > (height.to_f / self.height.to_f)) ? [width, :auto] : [:auto, height]
|
97
|
+
resize(to_w,to_h)
|
98
|
+
end
|
99
|
+
|
85
100
|
def color_int(colorstr)
|
86
101
|
validate_color(colorstr)
|
87
102
|
cs = colorstr.gsub(/^#/,"")
|
data/lib/pikl/version.rb
CHANGED
data/test/test_pikl_image.rb
CHANGED
@@ -27,6 +27,61 @@ class TestPiklImage < Test::Unit::TestCase
|
|
27
27
|
|
28
28
|
end
|
29
29
|
|
30
|
+
def test_fit_inner
|
31
|
+
#sample.jpg must be 120x160.
|
32
|
+
img = Pikl::Image.open(SAMPLE_IMAGE)
|
33
|
+
img.fit(60,81)
|
34
|
+
assert_equal(60, img.width)
|
35
|
+
assert_equal(80, img.height)
|
36
|
+
img.close()
|
37
|
+
|
38
|
+
img = Pikl::Image.open(SAMPLE_IMAGE)
|
39
|
+
img.fit(61,80)
|
40
|
+
assert_equal(60, img.width)
|
41
|
+
assert_equal(80, img.height)
|
42
|
+
img.close()
|
43
|
+
|
44
|
+
img = Pikl::Image.open(SAMPLE_IMAGE)
|
45
|
+
img.fit(240,321)
|
46
|
+
assert_equal(240, img.width)
|
47
|
+
assert_equal(320, img.height)
|
48
|
+
img.close()
|
49
|
+
|
50
|
+
img = Pikl::Image.open(SAMPLE_IMAGE)
|
51
|
+
img.fit(361,480)
|
52
|
+
assert_equal(360, img.width)
|
53
|
+
assert_equal(480, img.height)
|
54
|
+
img.close()
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_fit_outer
|
58
|
+
#sample.jpg must be 120x160.
|
59
|
+
img = Pikl::Image.open(SAMPLE_IMAGE)
|
60
|
+
img.fit(360,479,:outer)
|
61
|
+
assert_equal(360, img.width)
|
62
|
+
assert_equal(480, img.height)
|
63
|
+
img.close()
|
64
|
+
|
65
|
+
img = Pikl::Image.open(SAMPLE_IMAGE)
|
66
|
+
img.fit(359,480,:outer)
|
67
|
+
assert_equal(360, img.width)
|
68
|
+
assert_equal(480, img.height)
|
69
|
+
img.close()
|
70
|
+
|
71
|
+
img = Pikl::Image.open(SAMPLE_IMAGE)
|
72
|
+
img.fit(119,160,:outer)
|
73
|
+
assert_equal(120, img.width)
|
74
|
+
assert_equal(160, img.height)
|
75
|
+
img.close()
|
76
|
+
|
77
|
+
img = Pikl::Image.open(SAMPLE_IMAGE)
|
78
|
+
img.fit(120,159,:outer)
|
79
|
+
assert_equal(120, img.width)
|
80
|
+
assert_equal(160, img.height)
|
81
|
+
img.close()
|
82
|
+
end
|
83
|
+
|
84
|
+
|
30
85
|
def test_trim
|
31
86
|
Pikl::Image.open(SAMPLE_IMAGE) do |img|
|
32
87
|
|
metadata
CHANGED
@@ -1,41 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.2
|
3
|
-
specification_version: 1
|
4
2
|
name: pikl
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.2.
|
7
|
-
date: 2008-06-13 00:00:00 +09:00
|
8
|
-
summary: Pikl is an image librarry for JPEG, PNG and Bitmap.Pikl's API is designed to process the image easily with method chain.
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
- ext
|
12
|
-
email:
|
13
|
-
- ""
|
14
|
-
homepage: http://pikl.rubyforge.org
|
15
|
-
rubyforge_project: pikl
|
16
|
-
description: Pikl is an image librarry for JPEG, PNG and Bitmap.Pikl's API is designed to process the image easily with method chain.
|
17
|
-
autorequire:
|
18
|
-
default_executable:
|
19
|
-
bindir: bin
|
20
|
-
has_rdoc: true
|
21
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
22
|
-
requirements:
|
23
|
-
- - ">"
|
24
|
-
- !ruby/object:Gem::Version
|
25
|
-
version: 0.0.0
|
26
|
-
version:
|
4
|
+
version: 0.2.5
|
27
5
|
platform: ruby
|
28
|
-
signing_key:
|
29
|
-
cert_chain:
|
30
|
-
post_install_message:
|
31
6
|
authors:
|
32
7
|
- Ryota Maruko
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-06-22 00:00:00 +09:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Pikl is an image librarry for JPEG, PNG and Bitmap.Pikl's API is designed to process the image easily with method chain.
|
17
|
+
email:
|
18
|
+
- ""
|
19
|
+
executables: []
|
20
|
+
|
21
|
+
extensions:
|
22
|
+
- ext/pikl/extconf.rb
|
23
|
+
extra_rdoc_files:
|
24
|
+
- History.txt
|
25
|
+
- License.txt
|
26
|
+
- Manifest.txt
|
27
|
+
- README.txt
|
33
28
|
files:
|
34
29
|
- History.txt
|
35
30
|
- License.txt
|
36
31
|
- Manifest.txt
|
37
32
|
- README.txt
|
38
|
-
- Rakefile
|
39
33
|
- config/hoe.rb
|
40
34
|
- config/requirements.rb
|
41
35
|
- ext/pikl/extconf.rb
|
@@ -69,22 +63,34 @@ files:
|
|
69
63
|
- test/sample.jpg
|
70
64
|
- test/test_helper.rb
|
71
65
|
- test/test_pikl_image.rb
|
72
|
-
|
73
|
-
|
74
|
-
|
66
|
+
has_rdoc: true
|
67
|
+
homepage: http://pikl.rubyforge.org
|
68
|
+
post_install_message:
|
75
69
|
rdoc_options:
|
76
70
|
- --main
|
77
71
|
- README.txt
|
78
|
-
|
79
|
-
-
|
80
|
-
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
- ext
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: "0"
|
80
|
+
version:
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: "0"
|
86
|
+
version:
|
87
87
|
requirements: []
|
88
88
|
|
89
|
-
|
90
|
-
|
89
|
+
rubyforge_project: pikl
|
90
|
+
rubygems_version: 1.0.1
|
91
|
+
signing_key:
|
92
|
+
specification_version: 2
|
93
|
+
summary: Pikl is an image librarry for JPEG, PNG and Bitmap.Pikl's API is designed to process the image easily with method chain.
|
94
|
+
test_files:
|
95
|
+
- test/test_helper.rb
|
96
|
+
- test/test_pikl_image.rb
|
data/Rakefile
DELETED