mojo_magick 0.5.7 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +25 -0
- data/.github/dependabot.yml +8 -0
- data/.rubocop-common.yml +99 -0
- data/.rubocop-performance.yml +2 -0
- data/.rubocop.yml +11 -0
- data/Gemfile +6 -1
- data/Gemfile.lock +48 -15
- data/README.md +40 -4
- data/Rakefile +15 -6
- data/examples/animated_gif.rb +11 -13
- data/examples/composite.rb +11 -13
- data/init.rb +1 -1
- data/lib/image_magick/fonts.rb +4 -11
- data/lib/mojo_magick.rb +93 -76
- data/lib/mojo_magick/command_status.rb +1 -1
- data/lib/mojo_magick/commands.rb +32 -0
- data/lib/mojo_magick/errors.rb +2 -0
- data/lib/mojo_magick/font.rb +1 -2
- data/lib/mojo_magick/opt_builder.rb +16 -27
- data/lib/mojo_magick/util/font_parser.rb +43 -0
- data/lib/mojo_magick/util/parser.rb +11 -56
- data/lib/mojo_magick/version.rb +1 -1
- data/mojo_magick.gemspec +19 -16
- data/test/fixtures/roll with it.jpg +0 -0
- data/test/{parser_test.rb → font_parser_test.rb} +7 -7
- data/test/font_test.rb +5 -5
- data/test/mojo_magick_test.rb +99 -88
- data/test/opt_builder_test.rb +99 -80
- data/test/test_helper.rb +7 -6
- metadata +47 -16
- data/lib/image_magick/resource_limits.rb +0 -91
- data/lib/initializers/hash.rb +0 -12
- data/test/fonts_test.rb +0 -11
- data/test/resource_limits_test.rb +0 -49
data/lib/mojo_magick/version.rb
CHANGED
data/mojo_magick.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
|
2
|
-
require
|
1
|
+
$LOAD_PATH.push File.expand_path("lib", __dir__)
|
2
|
+
require "mojo_magick/version"
|
3
3
|
|
4
|
-
post_install_message = <<~
|
4
|
+
post_install_message = <<~EOPOST_INSTALL
|
5
5
|
|
6
6
|
Thanks for installing MojoMagick - keepin it simple!
|
7
7
|
|
@@ -10,29 +10,32 @@ post_install_message = <<~EOF
|
|
10
10
|
If you plan to build images with text (using the "label" method) you'll need freetype and ghostscript as well.
|
11
11
|
Check out http://www.freetype.org and http://ghostscript.com respectively for installation info.
|
12
12
|
|
13
|
-
|
13
|
+
EOPOST_INSTALL
|
14
14
|
|
15
15
|
Gem::Specification.new do |s|
|
16
|
-
s.name =
|
17
|
-
s.license =
|
16
|
+
s.name = "mojo_magick"
|
17
|
+
s.license = "MIT"
|
18
18
|
s.version = MojoMagick::VERSION
|
19
19
|
s.platform = Gem::Platform::RUBY
|
20
|
-
s.authors = [
|
21
|
-
s.email = [
|
22
|
-
s.homepage =
|
20
|
+
s.authors = ["Steve Midgley", "Elliot Nelson", "Jon Rogers"]
|
21
|
+
s.email = ["science@misuse.org", "jon@rcode5.com"]
|
22
|
+
s.homepage = "http://github.com/rcode5/mojo_magick"
|
23
23
|
s.summary = "mojo_magick-#{MojoMagick::VERSION}"
|
24
|
-
s.description =
|
24
|
+
s.description = "Simple Ruby stateless module interface to imagemagick."
|
25
|
+
s.required_ruby_version = ">= 2.6.0"
|
25
26
|
|
26
|
-
s.rubyforge_project =
|
27
|
+
s.rubyforge_project = "mojo_magick"
|
27
28
|
|
28
29
|
s.files = `git ls-files`.split("\n")
|
29
30
|
s.test_files = `git ls-files -- {test,features}/*`.split("\n")
|
30
31
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
31
|
-
s.require_paths = [
|
32
|
-
s.add_development_dependency(
|
33
|
-
s.add_development_dependency(
|
34
|
-
s.add_development_dependency(
|
35
|
-
s.add_development_dependency(
|
32
|
+
s.require_paths = ["lib"]
|
33
|
+
s.add_development_dependency("bundle-audit")
|
34
|
+
s.add_development_dependency("bundler")
|
35
|
+
s.add_development_dependency("minitest")
|
36
|
+
s.add_development_dependency("rake")
|
37
|
+
s.add_development_dependency("rubocop")
|
38
|
+
s.add_development_dependency("rubocop-performance")
|
36
39
|
|
37
40
|
s.post_install_message = post_install_message
|
38
41
|
end
|
Binary file
|
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
require_relative "test_helper"
|
2
2
|
|
3
|
-
IDENTIFY_FONT_RESPONSE = <<~
|
3
|
+
IDENTIFY_FONT_RESPONSE = <<~EOFONT
|
4
4
|
|
5
5
|
Font: Zapf-Dingbats
|
6
6
|
family: Zapf Dingbats
|
@@ -17,13 +17,13 @@ IDENTIFY_FONT_RESPONSE = <<~EOF.freeze
|
|
17
17
|
glyphs: /Library/Fonts/Zapfino.ttf
|
18
18
|
|
19
19
|
|
20
|
-
|
20
|
+
EOFONT
|
21
21
|
|
22
|
-
class
|
22
|
+
class FontParserTest < MiniTest::Test
|
23
23
|
def test_parse_fonts
|
24
|
-
parser = MojoMagick::Util::
|
25
|
-
parsed_fonts = parser.
|
24
|
+
parser = MojoMagick::Util::FontParser.new(IDENTIFY_FONT_RESPONSE)
|
25
|
+
parsed_fonts = parser.parse
|
26
26
|
assert_equal parsed_fonts.length, 2
|
27
|
-
assert_equal parsed_fonts[1].style,
|
27
|
+
assert_equal parsed_fonts[1].style, "Italic"
|
28
28
|
end
|
29
29
|
end
|
data/test/font_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
require_relative "test_helper"
|
2
2
|
|
3
|
-
IDENTIFY_FONT_RESPONSE = <<~
|
3
|
+
IDENTIFY_FONT_RESPONSE = <<~EO_FONTS
|
4
4
|
Font: Zapf-Dingbats
|
5
5
|
family: Zapf Dingbats
|
6
6
|
style: Normal
|
@@ -13,7 +13,7 @@ IDENTIFY_FONT_RESPONSE = <<~EOF.freeze
|
|
13
13
|
stretch: Normal
|
14
14
|
weight: 400
|
15
15
|
glyphs: /Library/Fonts/Zapfino.ttf
|
16
|
-
|
16
|
+
EO_FONTS
|
17
17
|
|
18
18
|
class FontTest < MiniTest::Test
|
19
19
|
def test_font
|
@@ -21,8 +21,8 @@ class FontTest < MiniTest::Test
|
|
21
21
|
assert_nil f.name
|
22
22
|
assert_equal f.valid?, false
|
23
23
|
|
24
|
-
f = MojoMagick::Font.new(name:
|
25
|
-
assert_equal f.name,
|
24
|
+
f = MojoMagick::Font.new(name: "Zapfino", weight: 400)
|
25
|
+
assert_equal f.name, "Zapfino"
|
26
26
|
assert_equal f.valid?, true
|
27
27
|
assert_equal f.weight, 400
|
28
28
|
end
|
data/test/mojo_magick_test.rb
CHANGED
@@ -1,24 +1,27 @@
|
|
1
|
-
|
1
|
+
require_relative "test_helper"
|
2
2
|
|
3
3
|
class MojoMagickTest < MiniTest::Test
|
4
4
|
# we keep a fixtures path and a working path so that we can easily test image
|
5
5
|
# manipulation routines without tainting the original images
|
6
6
|
def setup
|
7
|
-
@fixtures_path = File.expand_path(File.join(File.dirname(__FILE__),
|
8
|
-
@working_path = File.join(@fixtures_path,
|
7
|
+
@fixtures_path = File.expand_path(File.join(File.dirname(__FILE__), "fixtures"))
|
8
|
+
@working_path = File.join(@fixtures_path, "tmp")
|
9
|
+
|
10
|
+
reset_images
|
11
|
+
|
12
|
+
@test_image = File.join(@working_path, "5742.jpg")
|
13
|
+
@out_image = File.join(@working_path, "out1.jpg")
|
9
14
|
end
|
10
15
|
|
11
16
|
def reset_images
|
12
17
|
FileUtils.rm_r(@working_path) if File.exist?(@working_path)
|
13
18
|
FileUtils.mkdir(@working_path)
|
14
|
-
Dir.glob(File.join(@fixtures_path,
|
19
|
+
Dir.glob(File.join(@fixtures_path, "*")).each do |file|
|
15
20
|
FileUtils.cp(file, @working_path) if File.file?(file)
|
16
21
|
end
|
17
|
-
@test_image = File.join(@working_path, '5742.jpg')
|
18
22
|
end
|
19
23
|
|
20
24
|
def test_get_image_size
|
21
|
-
reset_images
|
22
25
|
orig_image_size = File.size(@test_image)
|
23
26
|
retval = MojoMagick.get_image_size(@test_image)
|
24
27
|
assert_equal orig_image_size, File.size(@test_image)
|
@@ -28,11 +31,10 @@ class MojoMagickTest < MiniTest::Test
|
|
28
31
|
|
29
32
|
def test_image_resize
|
30
33
|
# test basic resizing
|
31
|
-
reset_images
|
32
34
|
orig_image_size = File.size(@test_image)
|
33
|
-
size_test_temp = Tempfile.new(
|
35
|
+
size_test_temp = Tempfile.new("mojo_test")
|
34
36
|
size_test = size_test_temp.path
|
35
|
-
retval = MojoMagick.resize(@test_image, size_test, {width: 100, height: 100})
|
37
|
+
retval = MojoMagick.resize(@test_image, size_test, { width: 100, height: 100 })
|
36
38
|
assert_equal size_test, retval
|
37
39
|
assert_equal orig_image_size, File.size(@test_image)
|
38
40
|
assert_equal retval, size_test
|
@@ -41,18 +43,17 @@ class MojoMagickTest < MiniTest::Test
|
|
41
43
|
assert_equal 67, new_dimensions[:width]
|
42
44
|
|
43
45
|
# we should be able to resize image right over itself
|
44
|
-
retval = MojoMagick.resize(@test_image, @test_image, {width:
|
46
|
+
retval = MojoMagick.resize(@test_image, @test_image, { width: 150, height: 150 })
|
45
47
|
assert_equal @test_image, retval
|
46
48
|
refute_equal orig_image_size, File.size(@test_image)
|
47
49
|
new_dimensions = MojoMagick.get_image_size(@test_image)
|
48
|
-
assert_equal
|
49
|
-
assert_equal
|
50
|
+
assert_equal 150, new_dimensions[:height]
|
51
|
+
assert_equal 100, new_dimensions[:width]
|
50
52
|
end
|
51
53
|
|
52
54
|
def test_image_resize_with_percentage
|
53
|
-
reset_images
|
54
55
|
original_size = MojoMagick.get_image_size(@test_image)
|
55
|
-
retval = MojoMagick.resize(@test_image, @test_image, {percent: 50})
|
56
|
+
retval = MojoMagick.resize(@test_image, @test_image, { percent: 50 })
|
56
57
|
assert_equal @test_image, retval
|
57
58
|
new_dimensions = MojoMagick.get_image_size(@test_image)
|
58
59
|
%i[height width].each do |dim|
|
@@ -62,10 +63,9 @@ class MojoMagickTest < MiniTest::Test
|
|
62
63
|
|
63
64
|
def test_shrink_with_big_dimensions
|
64
65
|
# image shouldn't resize if we specify very large dimensions and specify "shrink_only"
|
65
|
-
|
66
|
-
size_test_temp = Tempfile.new('mojo_test')
|
66
|
+
size_test_temp = Tempfile.new("mojo_test")
|
67
67
|
size_test = size_test_temp.path
|
68
|
-
retval = MojoMagick.shrink(@test_image, size_test, {width: 1000, height: 1000})
|
68
|
+
retval = MojoMagick.shrink(@test_image, size_test, { width: 1000, height: 1000 })
|
69
69
|
assert_equal size_test, retval
|
70
70
|
new_dimensions = MojoMagick.get_image_size(@test_image)
|
71
71
|
assert_equal 500, new_dimensions[:height]
|
@@ -73,9 +73,8 @@ class MojoMagickTest < MiniTest::Test
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def test_shrink
|
76
|
-
reset_images
|
77
76
|
# image should resize if we specify small dimensions and shrink_only
|
78
|
-
retval = MojoMagick.shrink(@test_image, @test_image, {width: 1000, height: 100})
|
77
|
+
retval = MojoMagick.shrink(@test_image, @test_image, { width: 1000, height: 100 })
|
79
78
|
assert_equal @test_image, retval
|
80
79
|
new_dimensions = MojoMagick.get_image_size(@test_image)
|
81
80
|
assert_equal 100, new_dimensions[:height]
|
@@ -83,9 +82,8 @@ class MojoMagickTest < MiniTest::Test
|
|
83
82
|
end
|
84
83
|
|
85
84
|
def test_resize_with_shrink_only_options
|
86
|
-
reset_images
|
87
85
|
# image should resize if we specify small dimensions and shrink_only
|
88
|
-
retval = MojoMagick.resize(@test_image, @test_image, {shrink_only: true, width: 400, height: 400})
|
86
|
+
retval = MojoMagick.resize(@test_image, @test_image, { shrink_only: true, width: 400, height: 400 })
|
89
87
|
assert_equal @test_image, retval
|
90
88
|
new_dimensions = MojoMagick.get_image_size(@test_image)
|
91
89
|
assert_equal 400, new_dimensions[:height]
|
@@ -94,8 +92,8 @@ class MojoMagickTest < MiniTest::Test
|
|
94
92
|
|
95
93
|
def test_expand_with_small_dim
|
96
94
|
# image shouldn't resize if we specify small dimensions and expand_only
|
97
|
-
|
98
|
-
retval = MojoMagick.expand(@test_image, @test_image, {width: 10, height: 10})
|
95
|
+
_orig_image_size = File.size(@test_image)
|
96
|
+
retval = MojoMagick.expand(@test_image, @test_image, { width: 10, height: 10 })
|
99
97
|
assert_equal @test_image, retval
|
100
98
|
new_dimensions = MojoMagick.get_image_size(@test_image)
|
101
99
|
assert_equal 500, new_dimensions[:height]
|
@@ -103,9 +101,8 @@ class MojoMagickTest < MiniTest::Test
|
|
103
101
|
end
|
104
102
|
|
105
103
|
def test_expand
|
106
|
-
reset_images
|
107
104
|
# image should resize if we specify large dimensions and expand_only
|
108
|
-
retval = MojoMagick.expand(@test_image, @test_image, {width: 1000, height: 1000})
|
105
|
+
retval = MojoMagick.expand(@test_image, @test_image, { width: 1000, height: 1000 })
|
109
106
|
assert_equal @test_image, retval
|
110
107
|
new_dimensions = MojoMagick.get_image_size(@test_image)
|
111
108
|
assert_equal 1000, new_dimensions[:height]
|
@@ -114,26 +111,26 @@ class MojoMagickTest < MiniTest::Test
|
|
114
111
|
|
115
112
|
def test_invalid_images
|
116
113
|
# test bad images
|
117
|
-
bad_image = File.join(@working_path,
|
118
|
-
zero_image = File.join(@working_path,
|
119
|
-
assert_raises(MojoMagick::MojoFailed) {MojoMagick.get_image_size(bad_image)}
|
120
|
-
assert_raises(MojoMagick::MojoFailed) {MojoMagick.get_image_size(zero_image)}
|
121
|
-
assert_raises(MojoMagick::MojoFailed)
|
114
|
+
bad_image = File.join(@working_path, "not_an_image.jpg")
|
115
|
+
zero_image = File.join(@working_path, "zero_byte_image.jpg")
|
116
|
+
assert_raises(MojoMagick::MojoFailed) { MojoMagick.get_image_size(bad_image) }
|
117
|
+
assert_raises(MojoMagick::MojoFailed) { MojoMagick.get_image_size(zero_image) }
|
118
|
+
assert_raises(MojoMagick::MojoFailed) do
|
119
|
+
MojoMagick.get_image_size("/file_does_not_exist_here_ok.jpg")
|
120
|
+
end
|
122
121
|
end
|
123
122
|
|
124
123
|
def test_resize_with_fill
|
125
|
-
|
126
|
-
@test_image
|
127
|
-
MojoMagick.resize(@test_image, @test_image, {fill: true, width: 100, height: 100})
|
124
|
+
@test_image = File.join(@working_path, "5742.jpg")
|
125
|
+
MojoMagick.resize(@test_image, @test_image, { fill: true, width: 100, height: 100 })
|
128
126
|
dim = MojoMagick.get_image_size(@test_image)
|
129
127
|
assert_equal 100, dim[:width]
|
130
128
|
assert_equal 150, dim[:height]
|
131
129
|
end
|
132
130
|
|
133
131
|
def test_resize_with_fill_and_crop
|
134
|
-
|
135
|
-
@test_image
|
136
|
-
MojoMagick.resize(@test_image, @test_image, {fill: true, crop: true, width: 150, height: 120})
|
132
|
+
@test_image = File.join(@working_path, "5742.jpg")
|
133
|
+
MojoMagick.resize(@test_image, @test_image, { fill: true, crop: true, width: 150, height: 120 })
|
137
134
|
dim = MojoMagick.get_image_size(@test_image)
|
138
135
|
assert_equal 150, dim[:width]
|
139
136
|
assert_equal 120, dim[:height]
|
@@ -141,25 +138,23 @@ class MojoMagickTest < MiniTest::Test
|
|
141
138
|
|
142
139
|
def test_tempfile
|
143
140
|
# Create a tempfile and return the path
|
144
|
-
filename = MojoMagick.tempfile(
|
145
|
-
File.open(filename,
|
146
|
-
assert_equal f.read,
|
141
|
+
filename = MojoMagick.tempfile("binary data")
|
142
|
+
File.open(filename, "rb") do |f|
|
143
|
+
assert_equal f.read, "binary data"
|
147
144
|
end
|
148
145
|
end
|
149
146
|
|
150
147
|
def test_label
|
151
|
-
|
152
|
-
out_image = File.join(@working_path, 'label_test.png')
|
148
|
+
out_image = File.join(@working_path, "label_test.png")
|
153
149
|
|
154
150
|
MojoMagick.convert do |c|
|
155
|
-
c.label
|
151
|
+
c.label "rock the house"
|
156
152
|
c.file out_image
|
157
153
|
end
|
158
154
|
end
|
159
155
|
|
160
156
|
def test_label_with_quote
|
161
|
-
|
162
|
-
out_image = File.join(@working_path, 'label_test.png')
|
157
|
+
out_image = File.join(@working_path, "label_test.png")
|
163
158
|
|
164
159
|
MojoMagick.convert do |c|
|
165
160
|
c.label 'rock "the house'
|
@@ -168,18 +163,16 @@ class MojoMagickTest < MiniTest::Test
|
|
168
163
|
end
|
169
164
|
|
170
165
|
def test_label_with_apostrophe
|
171
|
-
|
172
|
-
out_image = File.join(@working_path, 'label_test.png')
|
166
|
+
out_image = File.join(@working_path, "label_test.png")
|
173
167
|
|
174
168
|
MojoMagick.convert do |c|
|
175
|
-
c.label
|
169
|
+
c.label "rock 'the house"
|
176
170
|
c.file out_image
|
177
171
|
end
|
178
172
|
end
|
179
173
|
|
180
174
|
def test_label_with_quotes
|
181
|
-
|
182
|
-
out_image = File.join(@working_path, 'label_test.png')
|
175
|
+
out_image = File.join(@working_path, "label_test.png")
|
183
176
|
|
184
177
|
MojoMagick.convert do |c|
|
185
178
|
c.label 'this is "it!"'
|
@@ -189,89 +182,107 @@ class MojoMagickTest < MiniTest::Test
|
|
189
182
|
|
190
183
|
def test_bad_command
|
191
184
|
MojoMagick.convert do |c|
|
192
|
-
c.unknown_option
|
193
|
-
c.file
|
185
|
+
c.unknown_option "fail"
|
186
|
+
c.file "boogabooga.whatever"
|
194
187
|
end
|
195
188
|
rescue MojoMagick::MojoFailed => e
|
196
|
-
assert e.message.include?(
|
197
|
-
|
189
|
+
assert e.message.include?("unrecognized option"),
|
190
|
+
"Unable to find ImageMagick commandline error in the message"
|
191
|
+
assert e.message.include?("convert.c/ConvertImageCommand"),
|
192
|
+
"Unable to find ImageMagick commandline error in the message"
|
198
193
|
end
|
199
194
|
|
200
|
-
def
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
data = (16.times.map { [rand > 0.5 ? 0 : 255] * 3 }).flatten
|
205
|
-
bdata = data.pack 'C' * data.size
|
206
|
-
out = 'out.png'
|
195
|
+
def test_blob_rgb
|
196
|
+
data = (Array.new(16) { [rand > 0.5 ? 0 : 255] * 3 }).flatten
|
197
|
+
bdata = data.pack "C" * data.size
|
198
|
+
out = "out.png"
|
207
199
|
MojoMagick.convert(nil, "png:#{out}") do |c|
|
208
|
-
c.blob bdata, format: :rgb, depth: 8, size:
|
200
|
+
c.blob bdata, format: :rgb, depth: 8, size: "4x4"
|
209
201
|
end
|
210
202
|
r = MojoMagick.get_image_size(out)
|
211
203
|
assert r[:height] == 4
|
212
204
|
assert r[:width] == 4
|
213
205
|
end
|
214
206
|
|
215
|
-
def
|
216
|
-
reset_images
|
217
|
-
test_image = File.join(@working_path, '5742.jpg')
|
218
|
-
out_image = File.join(@working_path, 'out1.jpg')
|
219
|
-
|
220
|
-
# Simple convert test
|
207
|
+
def test_convert
|
221
208
|
MojoMagick.convert do |c|
|
222
|
-
c.file test_image
|
223
|
-
c.crop
|
209
|
+
c.file @test_image
|
210
|
+
c.crop "92x64+0+0"
|
224
211
|
c.repage!
|
225
|
-
c.file out_image
|
212
|
+
c.file @out_image
|
226
213
|
end
|
227
|
-
retval = MojoMagick.get_image_size(out_image)
|
214
|
+
retval = MojoMagick.get_image_size(@out_image)
|
228
215
|
assert_equal 92, retval[:width]
|
229
216
|
assert_equal 64, retval[:height]
|
217
|
+
end
|
230
218
|
|
219
|
+
def test_mogrify
|
220
|
+
MojoMagick.convert do |c|
|
221
|
+
c.file @test_image
|
222
|
+
c.file @out_image
|
223
|
+
end
|
231
224
|
# Simple mogrify test
|
232
225
|
MojoMagick.mogrify do |m|
|
233
|
-
m.crop
|
226
|
+
m.crop "32x32+0+0"
|
234
227
|
m.repage!
|
235
|
-
m.file out_image
|
228
|
+
m.file @out_image
|
236
229
|
end
|
237
|
-
retval = MojoMagick.get_image_size(out_image)
|
230
|
+
retval = MojoMagick.get_image_size(@out_image)
|
238
231
|
assert_equal 32, retval[:width]
|
239
232
|
assert_equal 32, retval[:height]
|
233
|
+
end
|
240
234
|
|
241
|
-
|
242
|
-
MojoMagick.convert(test_image, out_image) do |c|
|
243
|
-
c.crop
|
235
|
+
def test_convert_crop_and_repage
|
236
|
+
MojoMagick.convert(@test_image, @out_image) do |c|
|
237
|
+
c.crop "100x100+0+0"
|
244
238
|
c.repage!
|
245
239
|
end
|
246
|
-
retval = MojoMagick.get_image_size(out_image)
|
240
|
+
retval = MojoMagick.get_image_size(@out_image)
|
247
241
|
assert_equal 100, retval[:width]
|
248
242
|
assert_equal 100, retval[:height]
|
243
|
+
end
|
249
244
|
|
250
|
-
|
251
|
-
MojoMagick.
|
252
|
-
|
245
|
+
def test_mogrify_with_shave_and_repage
|
246
|
+
MojoMagick.convert do |c|
|
247
|
+
c.file @test_image
|
248
|
+
c.crop "100x100+0+0"
|
249
|
+
c.file @out_image
|
250
|
+
end
|
251
|
+
MojoMagick.mogrify(@out_image) { |m| m.shave("25x25").repage! }
|
252
|
+
retval = MojoMagick.get_image_size(@out_image)
|
253
253
|
assert_equal 50, retval[:width]
|
254
254
|
assert_equal 50, retval[:height]
|
255
|
+
end
|
255
256
|
|
256
|
-
|
257
|
-
bdata =
|
258
|
-
out =
|
257
|
+
def test_convert_rgb
|
258
|
+
bdata = "aaaaaabbbbbbccc"
|
259
|
+
out = "out.png"
|
259
260
|
MojoMagick.convert do |c|
|
260
|
-
c.blob bdata, format: :rgb, depth: 8, size:
|
261
|
+
c.blob bdata, format: :rgb, depth: 8, size: "5x1"
|
261
262
|
c.file out
|
262
263
|
end
|
263
264
|
r = MojoMagick.get_image_size(out)
|
264
265
|
assert r[:height] == 1
|
265
266
|
assert r[:width] == 5
|
267
|
+
end
|
266
268
|
|
267
|
-
|
268
|
-
|
269
|
+
def test_convert_rgba
|
270
|
+
bdata = "1111222233334444"
|
271
|
+
out = "out.png"
|
269
272
|
MojoMagick.convert do |c|
|
270
|
-
c.blob bdata, format: :rgba, depth: 8, size:
|
273
|
+
c.blob bdata, format: :rgba, depth: 8, size: "4x1"
|
271
274
|
c.file out
|
272
275
|
end
|
273
276
|
r = MojoMagick.get_image_size(out)
|
274
277
|
assert r[:height] == 1
|
275
278
|
assert r[:width] == 4
|
276
279
|
end
|
280
|
+
|
281
|
+
def test_available_fonts
|
282
|
+
fonts = MojoMagick.available_fonts
|
283
|
+
assert fonts.is_a? Array
|
284
|
+
assert fonts.length > 1
|
285
|
+
assert fonts.first.name
|
286
|
+
assert(fonts.first.name.is_a?(String))
|
287
|
+
end
|
277
288
|
end
|