tupalo-mini_magick 3.2 → 3.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mini_magick.rb +7 -4
- data/test/montage_test.rb +30 -0
- metadata +6 -3
data/lib/mini_magick.rb
CHANGED
@@ -392,9 +392,12 @@ module MiniMagick
|
|
392
392
|
#
|
393
393
|
# The 'montage' script has several options, see here: http://www.imagemagick.org/script/montage.php
|
394
394
|
def self.new(images, output_extension, options={})
|
395
|
-
|
396
|
-
|
397
|
-
|
395
|
+
begin
|
396
|
+
tempfile = Tempfile.new(['mini_magick', ".#{output_extension}"])
|
397
|
+
tempfile.binmode
|
398
|
+
ensure
|
399
|
+
tempfile.close if tempfile
|
400
|
+
end
|
398
401
|
|
399
402
|
args = options.collect { |key,value| "-#{key.to_s} #{value.to_s}" } # collect hash parts into arguments
|
400
403
|
images.each do |image|
|
@@ -404,7 +407,7 @@ module MiniMagick
|
|
404
407
|
|
405
408
|
# This is a little hacky - cannikin's CommandeRunner would be a useful
|
406
409
|
# alternative (http://github.com/cannikin/mini_magick).
|
407
|
-
Image.new(images.first.path).run_command('montage', *args)
|
410
|
+
Image.new(images.first.path, tempfile).run_command('montage', *args)
|
408
411
|
return Image.open(tempfile.path)
|
409
412
|
end
|
410
413
|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.join(File.dirname(__FILE__), '../lib/mini_magick')
|
3
|
+
|
4
|
+
class Montage < Test::Unit::TestCase
|
5
|
+
include MiniMagick
|
6
|
+
|
7
|
+
CURRENT_DIR = File.dirname(File.expand_path(__FILE__)) + "/"
|
8
|
+
|
9
|
+
TOP_IMAGE_PATH = CURRENT_DIR + "simple.gif"
|
10
|
+
BOTTOM_IMAGE_PATH = CURRENT_DIR + "leaves spaced.tiff"
|
11
|
+
OUTPUT_FORMAT = 'jpg'
|
12
|
+
|
13
|
+
def test_montage_from_images
|
14
|
+
begin
|
15
|
+
image1 = Image.open(TOP_IMAGE_PATH)
|
16
|
+
image2 = Image.open(BOTTOM_IMAGE_PATH)
|
17
|
+
output_path = CURRENT_DIR + 'montage.' + OUTPUT_FORMAT
|
18
|
+
output_image = Montage.new([image1, image2], OUTPUT_FORMAT)
|
19
|
+
|
20
|
+
assert_equal output_image.class, MiniMagick::Image
|
21
|
+
|
22
|
+
output_image.write(output_path)
|
23
|
+
|
24
|
+
assert File.exists?(output_path)
|
25
|
+
assert_match(/^jpeg$/i, output_image[:format])
|
26
|
+
ensure
|
27
|
+
File.delete output_path
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tupalo-mini_magick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 2
|
9
|
-
|
9
|
+
- 2
|
10
|
+
version: 3.2.2
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Corey Johnson
|
@@ -17,7 +18,7 @@ autorequire:
|
|
17
18
|
bindir: bin
|
18
19
|
cert_chain: []
|
19
20
|
|
20
|
-
date: 2010-12-
|
21
|
+
date: 2010-12-23 00:00:00 +01:00
|
21
22
|
default_executable:
|
22
23
|
dependencies:
|
23
24
|
- !ruby/object:Gem::Dependency
|
@@ -76,6 +77,7 @@ files:
|
|
76
77
|
- test/composited.jpg
|
77
78
|
- test/image_test.rb
|
78
79
|
- test/leaves spaced.tiff
|
80
|
+
- test/montage_test.rb
|
79
81
|
- test/not_an_image.php
|
80
82
|
- test/simple-minus.gif
|
81
83
|
- test/simple.gif
|
@@ -121,6 +123,7 @@ test_files:
|
|
121
123
|
- test/composited.jpg
|
122
124
|
- test/image_test.rb
|
123
125
|
- test/leaves spaced.tiff
|
126
|
+
- test/montage_test.rb
|
124
127
|
- test/not_an_image.php
|
125
128
|
- test/simple-minus.gif
|
126
129
|
- test/simple.gif
|