mojo_magick 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +7 -1
- data/.ruby-version +1 -0
- data/Gemfile +3 -2
- data/Gemfile.lock +26 -0
- data/README.md +17 -4
- data/Rakefile +2 -0
- data/lib/image_resources.rb +2 -1
- data/lib/mojo_magick/opt_builder.rb +77 -0
- data/lib/mojo_magick/version.rb +1 -1
- data/lib/mojo_magick.rb +8 -78
- data/mojo_magick.gemspec +16 -1
- data/test/mojo_magick_test.rb +6 -87
- data/test/opt_builder_test.rb +92 -0
- data/test/test_helper.rb +6 -0
- metadata +54 -16
- data/.rvmrc +0 -1
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e8d7e7a6d4e6182e2f6dfe239a5ea6479e18c23d
|
4
|
+
data.tar.gz: a29fb27bbd8ffaef8acccd892abbf3245368b6c6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 48608b32f529b88428d4f4d65d88af56a8d26f3e89c7e90d6a957d02ede0ca23d2fc2d05299fdd50a2234457316e7559d431b42ff4e0ba982ba1daeca5708b94
|
7
|
+
data.tar.gz: 187989b5dec6e00b1e43d17b64c9cfa7321ff43c36996aca7030775dd58fa664538f0016159c140762e1f9d3047931dc384423f150945b2b4e7044930b215995
|
data/.gitignore
CHANGED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0-p247
|
data/Gemfile
CHANGED
@@ -1,2 +1,3 @@
|
|
1
|
-
source
|
2
|
-
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gemspec
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
mojo_magick (0.4.4)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.2.4)
|
10
|
+
multi_json (1.8.2)
|
11
|
+
rake (0.9.2.2)
|
12
|
+
rspec-expectations (2.14.3)
|
13
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
14
|
+
simplecov (0.7.1)
|
15
|
+
multi_json (~> 1.0)
|
16
|
+
simplecov-html (~> 0.7.1)
|
17
|
+
simplecov-html (0.7.1)
|
18
|
+
|
19
|
+
PLATFORMS
|
20
|
+
ruby
|
21
|
+
|
22
|
+
DEPENDENCIES
|
23
|
+
mojo_magick!
|
24
|
+
rake
|
25
|
+
rspec-expectations
|
26
|
+
simplecov
|
data/README.md
CHANGED
@@ -41,7 +41,7 @@ After this transformation, your image will be 100x100. But it does not distort
|
|
41
41
|
### Code sample of how to shrink all jpg's in a folder
|
42
42
|
|
43
43
|
require 'mojo_magick'
|
44
|
-
|
44
|
+
|
45
45
|
image_folder = '/tmp/img'
|
46
46
|
Dir::glob(File::join(image_folder, '*.jpg')).each do |image|
|
47
47
|
begin
|
@@ -85,7 +85,7 @@ complex commands.
|
|
85
85
|
c.strip
|
86
86
|
c.set 'comment', 'my favorite file'
|
87
87
|
end
|
88
|
-
|
88
|
+
|
89
89
|
# Equivalent to:
|
90
90
|
MojoMagick::raw_command('convert', 'source.jpg -crop 250x250+0+0 +repage -strip -set comment "my favorite file" dest.jpg')
|
91
91
|
|
@@ -100,7 +100,7 @@ complex commands.
|
|
100
100
|
|
101
101
|
# Example showing some additional options:
|
102
102
|
# assuming binary data that is rgb, 8bit depth and 10x20 pixels, :format => :rgb, :depth => 8, :size => '10x20'OAu
|
103
|
-
|
103
|
+
|
104
104
|
MojoMagick::convert do |c|
|
105
105
|
c.file 'source.jpg'
|
106
106
|
c.blob my_binary_data, :format => :rgb, :depth => 8, :size => '10x20'
|
@@ -109,7 +109,7 @@ complex commands.
|
|
109
109
|
c.repage!
|
110
110
|
c.file 'output.jpg'
|
111
111
|
end
|
112
|
-
|
112
|
+
|
113
113
|
# Use .file to specify file names, .blob to create and include a tempfile. The
|
114
114
|
# bang (!) can be appended to command names to use the '+' versions
|
115
115
|
# instead of '-' versions.
|
@@ -122,6 +122,19 @@ complex commands.
|
|
122
122
|
c.file 'output.jpg'
|
123
123
|
end
|
124
124
|
|
125
|
+
### Create a new image with text
|
126
|
+
|
127
|
+
Note: Use with care. If you don't have fonts installed ImageMagick can spin off wildly leaving MojoMagick not knowing what to do. For Unix/MacOSX, you should install freetype and ghostscript.
|
128
|
+
|
129
|
+
MojoMagick::convert(nil, fname) do |c|
|
130
|
+
c.background 'black'
|
131
|
+
c.fill 'white'
|
132
|
+
c.gravity 'center'
|
133
|
+
c.pointsize 80
|
134
|
+
c.size '200x200'
|
135
|
+
c.label 'the bird is the word'
|
136
|
+
end
|
137
|
+
|
125
138
|
Availablility
|
126
139
|
=============
|
127
140
|
|
data/Rakefile
CHANGED
data/lib/image_resources.rb
CHANGED
@@ -115,8 +115,9 @@ module ImageMagickResources
|
|
115
115
|
# that contains all the limit constraints
|
116
116
|
def get_limits_as_params
|
117
117
|
retval = ''
|
118
|
+
# we upcase the value here for newer versions of ImageMagick (>=6.8.x)
|
118
119
|
@@resource_limits.each do |type, value|
|
119
|
-
retval += " -limit #{type.to_s} #{value} "
|
120
|
+
retval += " -limit #{type.to_s} #{value.upcase} "
|
120
121
|
end
|
121
122
|
retval
|
122
123
|
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# Option builder used in #convert and #mogrify helpers.
|
2
|
+
module MojoMagick
|
3
|
+
class OptBuilder
|
4
|
+
def initialize
|
5
|
+
@opts = []
|
6
|
+
end
|
7
|
+
|
8
|
+
# Add command-line options with no processing
|
9
|
+
def <<(arg)
|
10
|
+
if arg.is_a?(Array)
|
11
|
+
@opts += arg
|
12
|
+
else
|
13
|
+
@opts << arg
|
14
|
+
end
|
15
|
+
self
|
16
|
+
end
|
17
|
+
|
18
|
+
# Add files to command line, formatted if necessary
|
19
|
+
def file(*args)
|
20
|
+
args.each do |arg|
|
21
|
+
add_formatted arg
|
22
|
+
end
|
23
|
+
self
|
24
|
+
end
|
25
|
+
alias files file
|
26
|
+
|
27
|
+
def label(*args)
|
28
|
+
@opts << "label:#{quoted_arg(args.join)}"
|
29
|
+
end
|
30
|
+
|
31
|
+
# Create a temporary file for the given image and add to command line
|
32
|
+
def format(*args)
|
33
|
+
@opts << '-format'
|
34
|
+
args.each do |arg|
|
35
|
+
add_formatted arg
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def blob(*args)
|
40
|
+
data = args[0]
|
41
|
+
opts = args[1] || {}
|
42
|
+
opts.each do |k,v|
|
43
|
+
send(k.to_s,v.to_s)
|
44
|
+
end
|
45
|
+
tmpfile = MojoMagick::tempfile(data, opts)
|
46
|
+
file tmpfile
|
47
|
+
end
|
48
|
+
|
49
|
+
# Generic commands. Arguments will be formatted if necessary
|
50
|
+
def method_missing(command, *args)
|
51
|
+
if command.to_s[-1, 1] == '!'
|
52
|
+
@opts << "+#{command.to_s.chop}"
|
53
|
+
else
|
54
|
+
@opts << "-#{command}"
|
55
|
+
end
|
56
|
+
args.each do |arg|
|
57
|
+
add_formatted arg
|
58
|
+
end
|
59
|
+
self
|
60
|
+
end
|
61
|
+
|
62
|
+
def to_s
|
63
|
+
@opts.join ' '
|
64
|
+
end
|
65
|
+
|
66
|
+
protected
|
67
|
+
def add_formatted(arg)
|
68
|
+
# Quote anything that would cause problems on *nix or windows
|
69
|
+
@opts << quoted_arg(arg)
|
70
|
+
end
|
71
|
+
|
72
|
+
def quoted_arg(arg)
|
73
|
+
return arg unless arg =~ /[<>^|&();` ]/
|
74
|
+
[ '"', arg.gsub('"', '\"'), '"'].join
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
data/lib/mojo_magick/version.rb
CHANGED
data/lib/mojo_magick.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
|
-
|
1
|
+
cwd = File::dirname(__FILE__)
|
2
|
+
require File::join(cwd, 'image_resources')
|
3
|
+
require File::join(cwd, 'mojo_magick/opt_builder')
|
2
4
|
require 'tempfile'
|
3
5
|
|
6
|
+
|
4
7
|
# MojoMagick is a stateless set of module methods which present a convient interface
|
5
8
|
# for accessing common tasks for ImageMagick command line library.
|
6
9
|
#
|
@@ -22,7 +25,7 @@ require 'tempfile'
|
|
22
25
|
# c.strip
|
23
26
|
# c.set 'comment', 'my favorite file'
|
24
27
|
# end
|
25
|
-
#
|
28
|
+
#
|
26
29
|
# Equivalent to:
|
27
30
|
#
|
28
31
|
# MojoMagick::raw_command('convert', 'source.jpg -crop 250x250+0+0 +repage -strip -set comment "my favorite file" dest.jpg')
|
@@ -32,7 +35,7 @@ require 'tempfile'
|
|
32
35
|
# MojoMagick::mogrify('image.jpg') {|i| i.shave '10x10'}
|
33
36
|
#
|
34
37
|
# Equivalent to:
|
35
|
-
#
|
38
|
+
#
|
36
39
|
# MojoMagick::raw_command('mogrify', '-shave 10x10 image.jpg')
|
37
40
|
#
|
38
41
|
# Example showing some additional options:
|
@@ -106,7 +109,7 @@ module MojoMagick
|
|
106
109
|
scale_options << "!" unless options[:absolute_aspect].nil?
|
107
110
|
scale_options << "^" unless options[:fill].nil?
|
108
111
|
scale_options = scale_options.join
|
109
|
-
|
112
|
+
|
110
113
|
extras = []
|
111
114
|
if !options[:width].nil? && !options[:height].nil?
|
112
115
|
geometry = "#{options[:width]}X#{options[:height]}"
|
@@ -152,7 +155,7 @@ module MojoMagick
|
|
152
155
|
raw_command('mogrify', opts.to_s)
|
153
156
|
end
|
154
157
|
|
155
|
-
|
158
|
+
|
156
159
|
def MojoMagick::tempfile(*opts)
|
157
160
|
begin
|
158
161
|
data = opts[0]
|
@@ -169,77 +172,4 @@ module MojoMagick
|
|
169
172
|
file.close
|
170
173
|
end
|
171
174
|
|
172
|
-
# Option builder used in #convert and #mogrify helpers.
|
173
|
-
class OptBuilder
|
174
|
-
def initialize
|
175
|
-
@opts = []
|
176
|
-
end
|
177
|
-
|
178
|
-
# Add command-line options with no processing
|
179
|
-
def <<(arg)
|
180
|
-
if arg.is_a?(Array)
|
181
|
-
@opts += arg
|
182
|
-
else
|
183
|
-
@opts << arg
|
184
|
-
end
|
185
|
-
self
|
186
|
-
end
|
187
|
-
|
188
|
-
# Add files to command line, formatted if necessary
|
189
|
-
def file(*args)
|
190
|
-
args.each do |arg|
|
191
|
-
add_formatted arg
|
192
|
-
end
|
193
|
-
self
|
194
|
-
end
|
195
|
-
alias files file
|
196
|
-
|
197
|
-
# Create a temporary file for the given image and add to command line
|
198
|
-
def format(*args)
|
199
|
-
@opts << '-format'
|
200
|
-
args.each do |arg|
|
201
|
-
add_formatted arg
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
def blob(*args)
|
206
|
-
data = args[0]
|
207
|
-
opts = args[1] || {}
|
208
|
-
opts.each do |k,v|
|
209
|
-
send(k.to_s,v.to_s)
|
210
|
-
end
|
211
|
-
tmpfile = MojoMagick::tempfile(data, opts)
|
212
|
-
file tmpfile
|
213
|
-
end
|
214
|
-
|
215
|
-
# Generic commands. Arguments will be formatted if necessary
|
216
|
-
def method_missing(command, *args)
|
217
|
-
if command.to_s[-1, 1] == '!'
|
218
|
-
@opts << "+#{command.to_s.chop}"
|
219
|
-
else
|
220
|
-
@opts << "-#{command}"
|
221
|
-
end
|
222
|
-
args.each do |arg|
|
223
|
-
add_formatted arg
|
224
|
-
end
|
225
|
-
self
|
226
|
-
end
|
227
|
-
|
228
|
-
def to_s
|
229
|
-
@opts.join ' '
|
230
|
-
end
|
231
|
-
|
232
|
-
protected
|
233
|
-
def add_formatted(arg)
|
234
|
-
# Quote anything that would cause problems on *nix or windows
|
235
|
-
if arg =~ /[<>^|&();` ]/
|
236
|
-
@opts << "\"#{arg.gsub('"', '\"')}\""
|
237
|
-
else
|
238
|
-
@opts << arg
|
239
|
-
end
|
240
|
-
end
|
241
|
-
end
|
242
|
-
|
243
175
|
end # MojoMagick
|
244
|
-
|
245
|
-
|
data/mojo_magick.gemspec
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
$:.push File.expand_path("../lib", __FILE__)
|
2
2
|
require "mojo_magick/version"
|
3
3
|
|
4
|
+
post_install_message = <<EOF
|
5
|
+
|
6
|
+
Thanks for installing MojoMagick - keepin it simple!
|
7
|
+
|
8
|
+
*** To make this gem work, you need a few binaries!
|
9
|
+
Make sure you've got ImageMagick available. http://imagemagick.org
|
10
|
+
If you plan to build images with text (using the "label" method) you'll need freetype and ghostscript as well.
|
11
|
+
Check out http://www.freetype.org and http://ghostscript.com respectively for installation info.
|
12
|
+
|
13
|
+
EOF
|
14
|
+
|
4
15
|
Gem::Specification.new do |s|
|
5
16
|
s.name = "mojo_magick"
|
6
17
|
s.version = MojoMagick::VERSION
|
@@ -12,10 +23,14 @@ Gem::Specification.new do |s|
|
|
12
23
|
s.description = %q{Simple Ruby stateless module interface to imagemagick.}
|
13
24
|
|
14
25
|
s.rubyforge_project = "mojo_magick"
|
15
|
-
|
26
|
+
|
16
27
|
s.files = `git ls-files`.split("\n")
|
17
28
|
s.test_files = `git ls-files -- {test,features}/*`.split("\n")
|
18
29
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
30
|
s.require_paths = ["lib"]
|
20
31
|
s.add_development_dependency('rake')
|
32
|
+
s.add_development_dependency('simplecov')
|
33
|
+
s.add_development_dependency('rspec-expectations')
|
34
|
+
|
35
|
+
s.post_install_message = post_install_message
|
21
36
|
end
|
data/test/mojo_magick_test.rb
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
require File::expand_path(File::join(File::dirname(__FILE__), '..', 'init'))
|
3
|
-
require 'fileutils'
|
4
|
-
require 'tempfile'
|
1
|
+
require File::join(File::dirname(__FILE__), 'test_helper')
|
5
2
|
|
6
3
|
class MojoMagickTest < Test::Unit::TestCase
|
7
4
|
|
@@ -121,8 +118,8 @@ class MojoMagickTest < Test::Unit::TestCase
|
|
121
118
|
@test_image = File::join(@working_path, '5742.jpg')
|
122
119
|
MojoMagick::resize(@test_image, @test_image, {:fill => true, :width => 100, :height => 100})
|
123
120
|
dim = MojoMagick::get_image_size(@test_image)
|
124
|
-
assert_equal 100, dim[:width]
|
125
|
-
assert_equal 150, dim[:height]
|
121
|
+
assert_equal 100, dim[:width]
|
122
|
+
assert_equal 150, dim[:height]
|
126
123
|
end
|
127
124
|
|
128
125
|
def test_resize_with_fill_and_crop
|
@@ -131,7 +128,7 @@ class MojoMagickTest < Test::Unit::TestCase
|
|
131
128
|
MojoMagick::resize(@test_image, @test_image, {:fill => true, :crop => true, :width => 150, :height => 120})
|
132
129
|
dim = MojoMagick::get_image_size(@test_image)
|
133
130
|
assert_equal 150, dim[:width]
|
134
|
-
assert_equal 120, dim[:height]
|
131
|
+
assert_equal 120, dim[:height]
|
135
132
|
end
|
136
133
|
|
137
134
|
def test_resource_limits
|
@@ -174,84 +171,6 @@ class MojoMagickTest < Test::Unit::TestCase
|
|
174
171
|
end
|
175
172
|
end
|
176
173
|
|
177
|
-
# These tests make the assumption that if we call #raw_command with the
|
178
|
-
# correct strings, ImageMagick itself will operate correctly. We're only
|
179
|
-
# verifying that the option builder produces the correct strings.
|
180
|
-
def test_option_builder
|
181
|
-
# Passing in basic commands produces a string
|
182
|
-
b = MojoMagick::OptBuilder.new
|
183
|
-
b.strip
|
184
|
-
b.repage
|
185
|
-
assert_equal '-strip -repage', b.to_s
|
186
|
-
|
187
|
-
# Chaining commands works
|
188
|
-
b = MojoMagick::OptBuilder.new.strip.repage
|
189
|
-
assert_equal '-strip -repage', b.to_s
|
190
|
-
|
191
|
-
# Bang (!) indicates the plus version of commands
|
192
|
-
b = MojoMagick::OptBuilder.new
|
193
|
-
b.repage
|
194
|
-
b.repage!
|
195
|
-
assert_equal '-repage +repage', b.to_s
|
196
|
-
|
197
|
-
# Accepts raw data as-is
|
198
|
-
b = MojoMagick::OptBuilder.new
|
199
|
-
b.opt1
|
200
|
-
b << 'a ! b !'
|
201
|
-
b.opt2
|
202
|
-
assert_equal '-opt1 a ! b ! -opt2', b.to_s
|
203
|
-
|
204
|
-
# Treats an array of raw data as different arguments
|
205
|
-
b = MojoMagick::OptBuilder.new
|
206
|
-
b << ['leave this data','alone']
|
207
|
-
assert_equal 'leave this data alone', b.to_s
|
208
|
-
|
209
|
-
# String includes command arguments
|
210
|
-
b = MojoMagick::OptBuilder.new
|
211
|
-
b.extent '256x256+0+0'
|
212
|
-
b.crop '64x64'
|
213
|
-
assert_equal '-extent 256x256+0+0 -crop 64x64', b.to_s
|
214
|
-
|
215
|
-
# Arguments are quoted (doublequote) if appropriate
|
216
|
-
b = MojoMagick::OptBuilder.new
|
217
|
-
b.comment 'white space'
|
218
|
-
b.comment 'w&b'
|
219
|
-
b.crop '6x6^'
|
220
|
-
assert_equal '-comment "white space" -comment "w&b" -crop "6x6^"', b.to_s
|
221
|
-
|
222
|
-
# Existing doublequotes are escaped
|
223
|
-
b = MojoMagick::OptBuilder.new
|
224
|
-
b.comment 'Fred "Woot" Rook'
|
225
|
-
assert_equal '-comment "Fred \"Woot\" Rook"', b.to_s
|
226
|
-
|
227
|
-
# Multi-argument commands should not be quoted together
|
228
|
-
b = MojoMagick::OptBuilder.new
|
229
|
-
b.set 'comment', 'the "best" comment'
|
230
|
-
assert_equal '-set comment "the \"best\" comment"', b.to_s
|
231
|
-
|
232
|
-
# File and files are helper methods
|
233
|
-
b = MojoMagick::OptBuilder.new
|
234
|
-
b.files 'source.jpg', 'source2.jpg'
|
235
|
-
b.append
|
236
|
-
b.crop '64x64'
|
237
|
-
b.file 'dest%d.jpg'
|
238
|
-
assert_equal 'source.jpg source2.jpg -append -crop 64x64 dest%d.jpg', b.to_s
|
239
|
-
|
240
|
-
# Files are quoted (doublequote) if appropriate
|
241
|
-
b = MojoMagick::OptBuilder.new
|
242
|
-
b.file 'probably on windows.jpg'
|
243
|
-
assert_equal '"probably on windows.jpg"', b.to_s
|
244
|
-
|
245
|
-
# Blob is a shortcut for the #tempfile helper method
|
246
|
-
b = MojoMagick::OptBuilder.new
|
247
|
-
b.blob 'binary data'
|
248
|
-
filename = b.to_s
|
249
|
-
File.open(filename, 'rb') do |f|
|
250
|
-
assert_equal f.read, 'binary data'
|
251
|
-
end
|
252
|
-
|
253
|
-
end
|
254
|
-
|
255
174
|
def test_command_helpers
|
256
175
|
reset_images
|
257
176
|
test_image = File::join(@working_path, '5742.jpg')
|
@@ -266,7 +185,7 @@ class MojoMagickTest < Test::Unit::TestCase
|
|
266
185
|
end
|
267
186
|
retval = MojoMagick::get_image_size(out_image)
|
268
187
|
assert_equal 92, retval[:width]
|
269
|
-
assert_equal 64, retval[:height]
|
188
|
+
assert_equal 64, retval[:height]
|
270
189
|
|
271
190
|
# Simple mogrify test
|
272
191
|
MojoMagick::mogrify do |m|
|
@@ -313,6 +232,6 @@ class MojoMagickTest < Test::Unit::TestCase
|
|
313
232
|
r = MojoMagick::get_image_size(out)
|
314
233
|
assert r[:height] == 1
|
315
234
|
assert r[:width] == 4
|
316
|
-
|
235
|
+
|
317
236
|
end
|
318
237
|
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require File::join(File::dirname(__FILE__), 'test_helper')
|
2
|
+
|
3
|
+
class MojoMagickOptBuilderTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
# These tests make the assumption that if we call #raw_command with the
|
6
|
+
# correct strings, ImageMagick itself will operate correctly. We're only
|
7
|
+
# verifying that the option builder produces the correct strings.
|
8
|
+
def test_option_builder
|
9
|
+
# Passing in basic commands produces a string
|
10
|
+
b = MojoMagick::OptBuilder.new
|
11
|
+
b.strip
|
12
|
+
b.repage
|
13
|
+
assert_equal '-strip -repage', b.to_s
|
14
|
+
|
15
|
+
# Chaining commands works
|
16
|
+
b = MojoMagick::OptBuilder.new.strip.repage
|
17
|
+
assert_equal '-strip -repage', b.to_s
|
18
|
+
|
19
|
+
# Bang (!) indicates the plus version of commands
|
20
|
+
b = MojoMagick::OptBuilder.new
|
21
|
+
b.repage
|
22
|
+
b.repage!
|
23
|
+
assert_equal '-repage +repage', b.to_s
|
24
|
+
|
25
|
+
# Accepts raw data as-is
|
26
|
+
b = MojoMagick::OptBuilder.new
|
27
|
+
b.opt1
|
28
|
+
b << 'a ! b !'
|
29
|
+
b.opt2
|
30
|
+
assert_equal '-opt1 a ! b ! -opt2', b.to_s
|
31
|
+
|
32
|
+
# Treats an array of raw data as different arguments
|
33
|
+
b = MojoMagick::OptBuilder.new
|
34
|
+
b << ['leave this data','alone']
|
35
|
+
assert_equal 'leave this data alone', b.to_s
|
36
|
+
|
37
|
+
# String includes command arguments
|
38
|
+
b = MojoMagick::OptBuilder.new
|
39
|
+
b.extent '256x256+0+0'
|
40
|
+
b.crop '64x64'
|
41
|
+
assert_equal '-extent 256x256+0+0 -crop 64x64', b.to_s
|
42
|
+
|
43
|
+
# Arguments are quoted (doublequote) if appropriate
|
44
|
+
b = MojoMagick::OptBuilder.new
|
45
|
+
b.comment 'white space'
|
46
|
+
b.comment 'w&b'
|
47
|
+
b.crop '6x6^'
|
48
|
+
assert_equal '-comment "white space" -comment "w&b" -crop "6x6^"', b.to_s
|
49
|
+
|
50
|
+
# Existing doublequotes are escaped
|
51
|
+
b = MojoMagick::OptBuilder.new
|
52
|
+
b.comment 'Fred "Woot" Rook'
|
53
|
+
assert_equal '-comment "Fred \"Woot\" Rook"', b.to_s
|
54
|
+
|
55
|
+
# Multi-argument commands should not be quoted together
|
56
|
+
b = MojoMagick::OptBuilder.new
|
57
|
+
b.set 'comment', 'the "best" comment'
|
58
|
+
assert_equal '-set comment "the \"best\" comment"', b.to_s
|
59
|
+
|
60
|
+
# File and files are helper methods
|
61
|
+
b = MojoMagick::OptBuilder.new
|
62
|
+
b.files 'source.jpg', 'source2.jpg'
|
63
|
+
b.append
|
64
|
+
b.crop '64x64'
|
65
|
+
b.file 'dest%d.jpg'
|
66
|
+
assert_equal 'source.jpg source2.jpg -append -crop 64x64 dest%d.jpg', b.to_s
|
67
|
+
|
68
|
+
# Files are quoted (doublequote) if appropriate
|
69
|
+
b = MojoMagick::OptBuilder.new
|
70
|
+
b.file 'probably on windows.jpg'
|
71
|
+
assert_equal '"probably on windows.jpg"', b.to_s
|
72
|
+
|
73
|
+
# Blob is a shortcut for the #tempfile helper method
|
74
|
+
b = MojoMagick::OptBuilder.new
|
75
|
+
b.blob 'binary data'
|
76
|
+
filename = b.to_s
|
77
|
+
File.open(filename, 'rb') do |f|
|
78
|
+
assert_equal f.read, 'binary data'
|
79
|
+
end
|
80
|
+
|
81
|
+
#label for text should use 'label:"the string"' if specified
|
82
|
+
[[ 'mylabel', 'mylabel' ],
|
83
|
+
[ 'Rock it', '"Rock it"'],
|
84
|
+
[ '#$%^&*', '"#$%^&*"']].each do |labels|
|
85
|
+
|
86
|
+
b = MojoMagick::OptBuilder.new
|
87
|
+
b.label labels[0]
|
88
|
+
expect(b.to_s).to eql "label:#{labels[1]}"
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mojo_magick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
5
|
-
prerelease:
|
4
|
+
version: 0.4.4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Steve Midgley
|
@@ -11,22 +10,48 @@ authors:
|
|
11
10
|
autorequire:
|
12
11
|
bindir: bin
|
13
12
|
cert_chain: []
|
14
|
-
date:
|
13
|
+
date: 2013-11-21 00:00:00.000000000 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: rake
|
18
17
|
requirement: !ruby/object:Gem::Requirement
|
19
|
-
none: false
|
20
18
|
requirements:
|
21
|
-
- -
|
19
|
+
- - '>='
|
22
20
|
- !ruby/object:Gem::Version
|
23
21
|
version: '0'
|
24
22
|
type: :development
|
25
23
|
prerelease: false
|
26
24
|
version_requirements: !ruby/object:Gem::Requirement
|
27
|
-
none: false
|
28
25
|
requirements:
|
29
|
-
- -
|
26
|
+
- - '>='
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '0'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: simplecov
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - '>='
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
type: :development
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: rspec-expectations
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
type: :development
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - '>='
|
30
55
|
- !ruby/object:Gem::Version
|
31
56
|
version: '0'
|
32
57
|
description: Simple Ruby stateless module interface to imagemagick.
|
@@ -38,45 +63,58 @@ extensions: []
|
|
38
63
|
extra_rdoc_files: []
|
39
64
|
files:
|
40
65
|
- .gitignore
|
41
|
-
- .
|
66
|
+
- .ruby-version
|
42
67
|
- Gemfile
|
68
|
+
- Gemfile.lock
|
43
69
|
- README.md
|
44
70
|
- Rakefile
|
45
71
|
- init.rb
|
46
72
|
- lib/image_resources.rb
|
47
73
|
- lib/mojo_magick.rb
|
74
|
+
- lib/mojo_magick/opt_builder.rb
|
48
75
|
- lib/mojo_magick/version.rb
|
49
76
|
- mojo_magick.gemspec
|
50
77
|
- test/fixtures/5742.jpg
|
51
78
|
- test/fixtures/not_an_image.jpg
|
52
79
|
- test/fixtures/zero_byte_image.jpg
|
53
80
|
- test/mojo_magick_test.rb
|
81
|
+
- test/opt_builder_test.rb
|
82
|
+
- test/test_helper.rb
|
54
83
|
homepage: http://github.com/bunnymatic/mojo_magick
|
55
84
|
licenses: []
|
56
|
-
|
85
|
+
metadata: {}
|
86
|
+
post_install_message: |2+
|
87
|
+
|
88
|
+
Thanks for installing MojoMagick - keepin it simple!
|
89
|
+
|
90
|
+
*** To make this gem work, you need a few binaries!
|
91
|
+
Make sure you've got ImageMagick available. http://imagemagick.org
|
92
|
+
If you plan to build images with text (using the "label" method) you'll need freetype and ghostscript as well.
|
93
|
+
Check out http://www.freetype.org and http://ghostscript.com respectively for installation info.
|
94
|
+
|
57
95
|
rdoc_options: []
|
58
96
|
require_paths:
|
59
97
|
- lib
|
60
98
|
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
-
none: false
|
62
99
|
requirements:
|
63
|
-
- -
|
100
|
+
- - '>='
|
64
101
|
- !ruby/object:Gem::Version
|
65
102
|
version: '0'
|
66
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
-
none: false
|
68
104
|
requirements:
|
69
|
-
- -
|
105
|
+
- - '>='
|
70
106
|
- !ruby/object:Gem::Version
|
71
107
|
version: '0'
|
72
108
|
requirements: []
|
73
109
|
rubyforge_project: mojo_magick
|
74
|
-
rubygems_version:
|
110
|
+
rubygems_version: 2.0.3
|
75
111
|
signing_key:
|
76
|
-
specification_version:
|
77
|
-
summary: mojo_magick-0.4.
|
112
|
+
specification_version: 4
|
113
|
+
summary: mojo_magick-0.4.4
|
78
114
|
test_files:
|
79
115
|
- test/fixtures/5742.jpg
|
80
116
|
- test/fixtures/not_an_image.jpg
|
81
117
|
- test/fixtures/zero_byte_image.jpg
|
82
118
|
- test/mojo_magick_test.rb
|
119
|
+
- test/opt_builder_test.rb
|
120
|
+
- test/test_helper.rb
|
data/.rvmrc
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
rvm --create use ruby-1.9.2-p318@mojo_magick
|