mini_magick 3.6.0 → 3.7.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of mini_magick might be problematic. Click here for more details.

@@ -0,0 +1,31 @@
1
+ require 'rbconfig'
2
+
3
+ module MiniMagick
4
+ module Utilities
5
+ class << self
6
+ # Cross-platform way of finding an executable in the $PATH.
7
+ #
8
+ # which('ruby') #=> /usr/bin/ruby
9
+ def which(cmd)
10
+ exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
11
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
12
+ exts.each { |ext|
13
+ exe = File.join(path, "#{cmd}#{ext}")
14
+ return exe if File.executable? exe
15
+ }
16
+ end
17
+ return nil
18
+ end
19
+
20
+ # Finds out if the host OS is windows
21
+ def windows?
22
+ RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
23
+ end
24
+
25
+ def windows_escape(cmdline)
26
+ '"' + cmdline.gsub(/\\(?=\\*\")/, "\\\\\\").gsub(/\"/, "\\\"").gsub(/\\$/, "\\\\\\").gsub("%", "%%") + '"'
27
+ end
28
+ end
29
+ end
30
+ end
31
+
@@ -1,3 +1,3 @@
1
1
  module MiniMagick
2
- VERSION = "3.6.0"
2
+ VERSION = "3.7.0"
3
3
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_magick
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.0
5
- prerelease:
4
+ version: 3.7.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Corey Johnson
@@ -11,12 +10,11 @@ authors:
11
10
  autorequire:
12
11
  bindir: bin
13
12
  cert_chain: []
14
- date: 2013-05-21 00:00:00.000000000 Z
13
+ date: 2013-11-26 00:00:00.000000000 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: subexec
18
17
  requirement: !ruby/object:Gem::Requirement
19
- none: false
20
18
  requirements:
21
19
  - - ~>
22
20
  - !ruby/object:Gem::Version
@@ -24,7 +22,6 @@ dependencies:
24
22
  type: :runtime
25
23
  prerelease: false
26
24
  version_requirements: !ruby/object:Gem::Requirement
27
- none: false
28
25
  requirements:
29
26
  - - ~>
30
27
  - !ruby/object:Gem::Version
@@ -32,33 +29,57 @@ dependencies:
32
29
  - !ruby/object:Gem::Dependency
33
30
  name: rake
34
31
  requirement: !ruby/object:Gem::Requirement
35
- none: false
36
32
  requirements:
37
- - - ! '>='
33
+ - - '>='
38
34
  - !ruby/object:Gem::Version
39
35
  version: '0'
40
36
  type: :development
41
37
  prerelease: false
42
38
  version_requirements: !ruby/object:Gem::Requirement
43
- none: false
44
39
  requirements:
45
- - - ! '>='
40
+ - - '>='
46
41
  - !ruby/object:Gem::Version
47
42
  version: '0'
48
43
  - !ruby/object:Gem::Dependency
49
44
  name: test-unit
50
45
  requirement: !ruby/object:Gem::Requirement
51
- none: false
52
46
  requirements:
53
- - - ! '>='
47
+ - - '>='
54
48
  - !ruby/object:Gem::Version
55
49
  version: '0'
56
50
  type: :development
57
51
  prerelease: false
58
52
  version_requirements: !ruby/object:Gem::Requirement
59
- none: false
60
53
  requirements:
61
- - - ! '>='
54
+ - - '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ - !ruby/object:Gem::Dependency
58
+ name: rspec
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ type: :development
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ - !ruby/object:Gem::Dependency
72
+ name: mocha
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - '>='
62
83
  - !ruby/object:Gem::Version
63
84
  version: '0'
64
85
  description: ''
@@ -73,66 +94,34 @@ files:
73
94
  - MIT-LICENSE
74
95
  - Rakefile
75
96
  - lib/mini_gmagick.rb
97
+ - lib/mini_magick/command_builder.rb
98
+ - lib/mini_magick/errors.rb
99
+ - lib/mini_magick/image.rb
100
+ - lib/mini_magick/utilities.rb
76
101
  - lib/mini_magick/version.rb
77
102
  - lib/mini_magick.rb
78
- - test/command_builder_test.rb
79
- - test/files/actually_a_gif.jpg
80
- - test/files/animation.gif
81
- - test/files/composited.jpg
82
- - test/files/erroneous.jpg
83
- - test/files/leaves (spaced).tiff
84
- - test/files/not_an_image.php
85
- - test/files/png.png
86
- - test/files/simple-minus.gif
87
- - test/files/simple.gif
88
- - test/files/special! "chars'.gif
89
- - test/files/trogdor.jpg
90
- - test/files/trogdor_capitalized.JPG
91
- - test/image_test.rb
92
- - test/leaves (spaced).tiff
93
- - test/test_helper.rb
94
- - test/trogdor_capitalized.JPG
95
103
  homepage: https://github.com/minimagick/minimagick
96
104
  licenses: []
105
+ metadata: {}
97
106
  post_install_message:
98
107
  rdoc_options: []
99
108
  require_paths:
100
109
  - lib
101
110
  required_ruby_version: !ruby/object:Gem::Requirement
102
- none: false
103
111
  requirements:
104
- - - ! '>='
112
+ - - '>='
105
113
  - !ruby/object:Gem::Version
106
114
  version: '0'
107
115
  required_rubygems_version: !ruby/object:Gem::Requirement
108
- none: false
109
116
  requirements:
110
- - - ! '>='
117
+ - - '>='
111
118
  - !ruby/object:Gem::Version
112
119
  version: '0'
113
120
  requirements:
114
121
  - You must have ImageMagick or GraphicsMagick installed
115
122
  rubyforge_project:
116
- rubygems_version: 1.8.23
123
+ rubygems_version: 2.0.3
117
124
  signing_key:
118
- specification_version: 3
125
+ specification_version: 4
119
126
  summary: Manipulate images with minimal use of memory via ImageMagick / GraphicsMagick
120
- test_files:
121
- - test/command_builder_test.rb
122
- - test/files/actually_a_gif.jpg
123
- - test/files/animation.gif
124
- - test/files/composited.jpg
125
- - test/files/erroneous.jpg
126
- - test/files/leaves (spaced).tiff
127
- - test/files/not_an_image.php
128
- - test/files/png.png
129
- - test/files/simple-minus.gif
130
- - test/files/simple.gif
131
- - test/files/special! "chars'.gif
132
- - test/files/trogdor.jpg
133
- - test/files/trogdor_capitalized.JPG
134
- - test/image_test.rb
135
- - test/leaves (spaced).tiff
136
- - test/test_helper.rb
137
- - test/trogdor_capitalized.JPG
138
- has_rdoc:
127
+ test_files: []
@@ -1,90 +0,0 @@
1
- require 'test_helper'
2
-
3
- class CommandBuilderTest < Test::Unit::TestCase
4
- include MiniMagick
5
-
6
- def setup
7
- @processor_path = MiniMagick.processor_path
8
- @processor = MiniMagick.processor
9
- end
10
-
11
- def teardown
12
- MiniMagick.processor_path = @processor_path
13
- MiniMagick.processor = @processor
14
- end
15
-
16
- def test_basic
17
- c = CommandBuilder.new("test")
18
- c.resize "30x40"
19
- assert_equal '-resize 30x40', c.args.join(" ")
20
- end
21
-
22
- def test_full_command
23
- c = CommandBuilder.new("test")
24
- c.resize "30x40"
25
- assert_equal "test -resize 30x40", c.command
26
- end
27
-
28
- def test_complicated
29
- c = CommandBuilder.new("test")
30
- c.resize "30x40"
31
- c.alpha "1 3 4"
32
- c.resize "mome fingo"
33
- assert_equal '-resize 30x40 -alpha 1\ 3\ 4 -resize mome\ fingo', c.args.join(" ")
34
- end
35
-
36
- def test_plus_modifier_and_multiple_options
37
- c = CommandBuilder.new("test")
38
- c.distort.+ 'srt', '0.6 20'
39
- assert_equal '\+distort srt 0.6\ 20', c.args.join(" ")
40
- end
41
-
42
- def test_valid_command
43
- begin
44
- c = CommandBuilder.new("test", "path")
45
- c.input 2
46
- assert false
47
- rescue NoMethodError
48
- assert true
49
- end
50
- end
51
-
52
- def test_dashed
53
- c = CommandBuilder.new("test")
54
- c.auto_orient
55
- assert_equal "-auto-orient", c.args.join(" ")
56
- end
57
-
58
- def test_dashed_via_send
59
- c = CommandBuilder.new("test")
60
- c.send("auto-orient")
61
- assert_equal "-auto-orient", c.args.join(" ")
62
- end
63
-
64
- def test_canvas
65
- c = CommandBuilder.new('test')
66
- c.canvas 'black'
67
- assert_equal "canvas:black", c.args.join
68
- end
69
-
70
- def test_set
71
- c = CommandBuilder.new("test")
72
- c.set "colorspace RGB"
73
- assert_equal 'test -set colorspace\ RGB', c.command
74
- end
75
-
76
- def test_processor_path
77
- MiniMagick.processor_path = "/a/strange/path"
78
- c = CommandBuilder.new('test')
79
- c.auto_orient
80
- assert_equal c.command, "/a/strange/path/test -auto-orient"
81
- end
82
-
83
- def test_processor_path_with_processor
84
- MiniMagick.processor_path = "/a/strange/path"
85
- MiniMagick.processor = "processor"
86
- c = CommandBuilder.new('test')
87
- c.auto_orient
88
- assert_equal c.command, "/a/strange/path/processor test -auto-orient"
89
- end
90
- end
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1 +0,0 @@
1
- <?php I am so not an image ?>
data/test/files/png.png DELETED
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
data/test/image_test.rb DELETED
@@ -1,384 +0,0 @@
1
- require 'test_helper'
2
- require 'digest/md5'
3
-
4
- #MiniMagick.processor = :gm
5
-
6
- class ImageTest < Test::Unit::TestCase
7
- include MiniMagick
8
- include MiniMagickTestFiles
9
-
10
- def test_image_from_blob
11
- File.open(SIMPLE_IMAGE_PATH, "rb") do |f|
12
- image = Image.read(f.read)
13
- assert image.valid?
14
- image.destroy!
15
- end
16
- end
17
-
18
- def test_image_from_tempfile
19
- tempfile = Tempfile.new('magick')
20
-
21
- File.open(SIMPLE_IMAGE_PATH, 'rb') do |f|
22
- tempfile.write(f.read)
23
- tempfile.rewind
24
- end
25
-
26
- image = Image.read(tempfile)
27
- assert image.valid?
28
- image.destroy!
29
- end
30
-
31
- def test_image_open
32
- image = Image.open(SIMPLE_IMAGE_PATH)
33
- assert image.valid?
34
- image.destroy!
35
- end
36
-
37
- def test_image_io_reading
38
- # buffer = StringIO.new(File.read(SIMPLE_IMAGE_PATH)) #This way does not work properly on windows
39
- buffer = StringIO.new File.open(SIMPLE_IMAGE_PATH,"rb") { |f| f.read } #This way works the same on all platforms
40
- image = Image.read(buffer)
41
- assert image.valid?
42
- image.destroy!
43
- end
44
-
45
- def test_image_create
46
- image = Image.create do |f|
47
- #Had to replace the old File.read with the following to work across all platforms
48
- f.write(File.open(SIMPLE_IMAGE_PATH,"rb") { |f| f.read })
49
- end
50
- image.destroy!
51
- end
52
-
53
- def test_image_new
54
- image = Image.new(SIMPLE_IMAGE_PATH)
55
- image.destroy!
56
- end
57
-
58
- def test_remote_image
59
- image = Image.open("http://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png")
60
- assert image.valid?
61
- image.destroy!
62
- end
63
-
64
- def test_remote_image_with_complex_url
65
- image = Image.open("http://a0.twimg.com/a/1296609216/images/fronts/logo_withbird_home.png?extra=foo&plus=bar")
66
- assert image.valid?
67
- image.destroy!
68
- end
69
-
70
- def test_reformat_with_capitalized_extension
71
- image = Image.open(CAP_EXT_PATH)
72
- image.format "jpg"
73
- end
74
-
75
- def test_image_write
76
- output_path = "output.gif"
77
- begin
78
- image = Image.new(SIMPLE_IMAGE_PATH)
79
- image.write output_path
80
-
81
- assert File.exists?(output_path)
82
- ensure
83
- File.delete output_path
84
- end
85
- image.destroy!
86
- end
87
-
88
- def test_image_write_with_space_in_output_path
89
- output_path = "test output.gif"
90
- begin
91
- image = Image.new(SIMPLE_IMAGE_PATH)
92
- image.write output_path
93
-
94
- assert File.exists?(output_path)
95
- ensure
96
- File.delete output_path
97
- end
98
- image.destroy!
99
- end
100
-
101
- def test_image_write_with_stream
102
- stream = StringIO.new
103
- image = Image.open(SIMPLE_IMAGE_PATH)
104
- image.write("#{Dir.tmpdir}/foo.gif")
105
- image.write(stream)
106
- # assert Image.read(stream.string).valid?
107
- image.destroy!
108
- end
109
-
110
- def test_not_an_image
111
- image = Image.new(NOT_AN_IMAGE_PATH)
112
- assert_equal false, image.valid?
113
- image.destroy!
114
- end
115
-
116
- def test_throw_on_opening_not_an_image
117
- assert_raise(MiniMagick::Invalid) do
118
- image = Image.open(NOT_AN_IMAGE_PATH)
119
- image.destroy
120
- end
121
- end
122
-
123
- def test_image_meta_info
124
- image = Image.new(SIMPLE_IMAGE_PATH)
125
- assert_equal 150, image[:width]
126
- assert_equal 55, image[:height]
127
- assert_equal [150, 55], image[:dimensions]
128
- assert_true String == image[:colorspace].class
129
- assert_match(/^gif$/i, image[:format])
130
- image.destroy!
131
- end
132
-
133
- def test_erroneous_image_meta_info
134
- image = Image.new(ERRONEOUS_IMAGE_PATH)
135
- assert_equal 10, image[:width]
136
- assert_equal 10, image[:height]
137
- assert_equal [10, 10], image[:dimensions]
138
- assert_equal('JPEG', image[:format])
139
- image.destroy!
140
- end
141
-
142
- def test_tiff
143
- image = Image.new(TIFF_IMAGE_PATH)
144
- assert_equal "tiff", image[:format].to_s.downcase
145
- assert_equal 50, image[:width]
146
- assert_equal 41, image[:height]
147
- image.destroy!
148
- end
149
-
150
- def test_gif_with_jpg_format
151
- image = Image.new(GIF_WITH_JPG_EXT)
152
- assert_equal "gif", image[:format].to_s.downcase
153
- image.destroy!
154
- end
155
-
156
- def test_image_resize
157
- image = Image.open(SIMPLE_IMAGE_PATH)
158
- image.resize "20x30!"
159
-
160
- assert_equal 20, image[:width]
161
- assert_equal 30, image[:height]
162
- assert_match(/^gif$/i, image[:format])
163
- image.destroy!
164
- end
165
-
166
- def test_image_resize_with_minimum
167
- image = Image.open(SIMPLE_IMAGE_PATH)
168
- original_width, original_height = image[:width], image[:height]
169
- image.resize "#{original_width + 10}x#{original_height + 10}>"
170
-
171
- assert_equal original_width, image[:width]
172
- assert_equal original_height, image[:height]
173
- image.destroy!
174
- end
175
-
176
- def test_image_combine_options_resize_blur
177
- image = Image.open(SIMPLE_IMAGE_PATH)
178
- image.combine_options do |c|
179
- c.resize "20x30!"
180
- c.blur "50"
181
- end
182
-
183
- assert_equal 20, image[:width]
184
- assert_equal 30, image[:height]
185
- assert_match(/^gif$/i, image[:format])
186
- image.destroy!
187
- end
188
-
189
- def test_image_combine_options_with_filename_with_minusses_in_it
190
- image = Image.open(SIMPLE_IMAGE_PATH)
191
- background = "#000000"
192
- assert_nothing_raised do
193
- image.combine_options do |c|
194
- c.draw "image Over 0,0 10,10 '#{MINUS_IMAGE_PATH}'"
195
- c.thumbnail "300x500>"
196
- c.background background
197
- end
198
- end
199
- image.destroy!
200
- end
201
-
202
- def test_image_combine_options_with_filename_with_special_characters_in_it
203
- image = Image.new(SPECIAL_CHARS_IMAGE_PATH)
204
- assert_nothing_raised do
205
- image.combine_options("identify") do |c|
206
- c.ping
207
- end
208
- end
209
- image.destroy!
210
- end
211
-
212
- def test_exif
213
- image = Image.open(EXIF_IMAGE_PATH)
214
- assert_equal('0220', image["exif:ExifVersion"])
215
- image = Image.open(SIMPLE_IMAGE_PATH)
216
- assert_equal('', image["EXIF:ExifVersion"])
217
- image.destroy!
218
- end
219
-
220
- def test_original_at
221
- image = Image.open(EXIF_IMAGE_PATH)
222
- assert_equal(Time.local('2005', '2', '23', '23', '17', '24'), image[:original_at])
223
- image = Image.open(SIMPLE_IMAGE_PATH)
224
- assert_nil(image[:original_at])
225
- image.destroy!
226
- end
227
-
228
- def test_tempfile_at_path
229
- image = Image.open(TIFF_IMAGE_PATH)
230
- assert_equal image.path, image.instance_eval("@tempfile.path")
231
- image.destroy!
232
- end
233
-
234
- def test_tempfile_at_path_after_format
235
- image = Image.open(TIFF_IMAGE_PATH)
236
- image.format('png')
237
- assert File.exists?(image.path)
238
- image.destroy!
239
- end
240
-
241
- def test_previous_tempfile_deleted_after_format
242
- image = Image.open(TIFF_IMAGE_PATH)
243
- before = image.path.dup
244
- image.format('png')
245
- assert !File.exist?(before)
246
- image.destroy!
247
- end
248
-
249
- def test_change_format_of_image_with_special_characters
250
- tempfile = Tempfile.new('magick with special! "chars\'')
251
-
252
- File.open(SIMPLE_IMAGE_PATH, 'rb') do |f|
253
- tempfile.write(f.read)
254
- tempfile.rewind
255
- end
256
-
257
- image = Image.new(tempfile.path)
258
- image.format('png')
259
- assert File.exists?(image.path)
260
- image.destroy!
261
-
262
- File.delete(image.path)
263
- tempfile.unlink
264
- end
265
-
266
- def test_bad_method_bug
267
- image = Image.open(TIFF_IMAGE_PATH)
268
- begin
269
- image.to_blog
270
- rescue NoMethodError
271
- assert true
272
- end
273
- image.to_blob
274
- assert true #we made it this far without error
275
- image.destroy!
276
- end
277
-
278
- def test_simple_composite
279
- if MiniMagick.valid_version_installed?
280
- image = Image.open(EXIF_IMAGE_PATH)
281
- result = image.composite(Image.open(TIFF_IMAGE_PATH)) do |c|
282
- c.gravity "center"
283
- end
284
- assert_true File.exists?(result.path)
285
- else
286
- puts "Need at least version #{MiniMagick.minimum_image_magick_version} of ImageMagick"
287
- end
288
- end
289
-
290
- # http://github.com/probablycorey/mini_magick/issues#issue/8
291
- def test_issue_8
292
- image = Image.open(SIMPLE_IMAGE_PATH)
293
- assert_nothing_raised do
294
- image.combine_options do |c|
295
- c.sample "50%"
296
- c.rotate "-90>"
297
- end
298
- end
299
- image.destroy!
300
- end
301
-
302
- # http://github.com/probablycorey/mini_magick/issues#issue/15
303
- def test_issue_15
304
- image = Image.open(Pathname.new(SIMPLE_IMAGE_PATH))
305
- output = Pathname.new("test.gif")
306
- image.write(output)
307
- ensure
308
- FileUtils.rm("test.gif")
309
- end
310
-
311
- # https://github.com/probablycorey/mini_magick/issues/37
312
- def test_nonstandard_locale
313
- original_lang = ENV["LANG"]
314
- ENV["LANG"] = "fr_FR.UTF-8"
315
-
316
- # This test should break
317
- test_throw_on_opening_not_an_image
318
- ensure
319
- ENV["LANG"] = original_lang
320
- end
321
-
322
- def test_poop
323
- img = MiniMagick::Image.open(SIMPLE_IMAGE_PATH)
324
- img.gravity "Center"
325
- img.crop "480x480"
326
- img.resize "250x250"
327
- img.write "#{Dir.tmpdir}/output.png"
328
- end
329
-
330
- def test_throw_format_error
331
- image = Image.open(SIMPLE_IMAGE_PATH)
332
- assert_raise MiniMagick::Error do
333
- image.combine_options do |c|
334
- c.format "png"
335
- end
336
- end
337
- image.destroy!
338
- end
339
-
340
- def test_import_pixels_default_format
341
- columns = 325
342
- rows = 200
343
- depth = 16 # 16 bits (2 bytes) per pixel
344
- map = 'gray'
345
- pixels = Array.new(columns*rows) {|i| i}
346
- blob = pixels.pack("S*") # unsigned short, native byte order
347
- image = Image.import_pixels(blob, columns, rows, depth, map)
348
- assert image.valid?
349
- assert_equal "png", image[:format].to_s.downcase
350
- assert_equal columns, image[:width]
351
- assert_equal rows, image[:height]
352
- image.write("#{Dir.tmpdir}/imported_pixels_image.png")
353
- end
354
-
355
- def test_import_pixels_custom_format
356
- columns = 325
357
- rows = 200
358
- depth = 16 # 16 bits (2 bytes) per pixel
359
- map = 'gray'
360
- format = 'jpeg'
361
- pixels = Array.new(columns*rows) {|i| i}
362
- blob = pixels.pack("S*") # unsigned short, native byte order
363
- image = Image.import_pixels(blob, columns, rows, depth, map, format)
364
- assert image.valid?
365
- assert_equal format, image[:format].to_s.downcase
366
- assert_equal columns, image[:width]
367
- assert_equal rows, image[:height]
368
- image.write("#{Dir.tmpdir}/imported_pixels_image." + format)
369
- end
370
-
371
- def test_mime_type
372
- gif = Image.open(SIMPLE_IMAGE_PATH)
373
- jpeg = Image.open(EXIF_IMAGE_PATH)
374
- png = Image.open(PNG_PATH)
375
- tiff = Image.open(TIFF_IMAGE_PATH)
376
- hidden_gif = Image.open(GIF_WITH_JPG_EXT)
377
-
378
- assert_equal "image/gif", gif.mime_type
379
- assert_equal "image/jpeg", jpeg.mime_type
380
- assert_equal "image/png", png.mime_type
381
- assert_equal "image/tiff", tiff.mime_type
382
- assert_equal "image/gif", hidden_gif.mime_type
383
- end
384
- end