tupalo-mini_magick 3.1 → 3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/mini_magick.rb +32 -36
- metadata +3 -4
- data/VERSION +0 -1
data/Rakefile
CHANGED
@@ -26,7 +26,7 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
|
|
26
26
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
27
27
|
end
|
28
28
|
|
29
|
-
spec = eval(File.read('mini_magick.gemspec'))
|
29
|
+
spec = eval(File.read('tupalo-mini_magick.gemspec'))
|
30
30
|
Rake::GemPackageTask.new(spec) do |pkg|
|
31
31
|
pkg.gem_spec = spec
|
32
32
|
end
|
data/lib/mini_magick.rb
CHANGED
@@ -373,49 +373,45 @@ module MiniMagick
|
|
373
373
|
result
|
374
374
|
end
|
375
375
|
end
|
376
|
-
|
377
|
-
# Combines multiple images into a single montage via ImageMagick's montage script
|
376
|
+
|
378
377
|
class Montage
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
tempfile = TempFile.new(output_extension)
|
378
|
+
# Class Methods
|
379
|
+
# -------------
|
380
|
+
|
381
|
+
# To create a montage simply call Montage.new with the images you want combine,
|
382
|
+
# the path to the output file and any command line options you may want.
|
383
|
+
# You will be returned a MiniMagick::Image instance for the new montage:
|
384
|
+
#
|
385
|
+
# image1 = MiniMagick::Image.open('alice.png')
|
386
|
+
# image2 = MiniMagick::Image.open('bob.png')
|
387
|
+
# output_image = MiniMagick::Composite.new([image1, image2], 'jpg', :background => '#336699')
|
388
|
+
# output_image.write('montage.jpg')
|
389
|
+
#
|
390
|
+
# The above example would combine the two images into a new JPEG file using a background color of #336699.
|
391
|
+
# The the image is saved using the standard Image.save method.
|
392
|
+
#
|
393
|
+
# The 'montage' script has several options, see here: http://www.imagemagick.org/script/montage.php
|
394
|
+
def self.new(images, output_extension, options={})
|
395
|
+
tempfile = Tempfile.new(['mini_magick', output_extension.to_s])
|
398
396
|
tempfile.binmode
|
399
|
-
ensure
|
400
397
|
tempfile.close
|
398
|
+
|
399
|
+
args = options.collect { |key,value| "-#{key.to_s} #{value.to_s}" } # collect hash parts into arguments
|
400
|
+
images.each do |image|
|
401
|
+
args.push image.path
|
402
|
+
end
|
403
|
+
args.push(tempfile.path)
|
404
|
+
|
405
|
+
# This is a little hacky - cannikin's CommandeRunner would be a useful
|
406
|
+
# alternative (http://github.com/cannikin/mini_magick).
|
407
|
+
Image.new(images.first.path).run_command('montage', *args)
|
408
|
+
return Image.open(tempfile.path)
|
401
409
|
end
|
402
|
-
|
403
|
-
args = options.collect { |key,value| "-#{key.to_s} #{value.to_s}" } # collect hash parts into arguments
|
404
|
-
images.each do |image|
|
405
|
-
args.push image.path
|
406
|
-
end
|
407
|
-
args.push(tempfile.path)
|
408
410
|
|
409
|
-
|
410
|
-
|
411
|
-
Image.new(images.first.path).run_command('montage', *args)
|
412
|
-
return Image.open(tempfile.path)
|
413
|
-
end
|
411
|
+
def run
|
412
|
+
end
|
414
413
|
|
415
|
-
def run
|
416
414
|
end
|
417
|
-
|
418
|
-
end
|
419
415
|
|
420
416
|
class CommandBuilder
|
421
417
|
attr :args
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tupalo-mini_magick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: "3.
|
8
|
+
- 2
|
9
|
+
version: "3.2"
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Corey Johnson
|
@@ -66,7 +66,6 @@ extra_rdoc_files: []
|
|
66
66
|
|
67
67
|
files:
|
68
68
|
- README.rdoc
|
69
|
-
- VERSION
|
70
69
|
- MIT-LICENSE
|
71
70
|
- Rakefile
|
72
71
|
- lib/mini_gmagick.rb
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
3.1
|