image-stitcher 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/bin/stitch +38 -0
  3. metadata +74 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e06b519eeea4d3371017f402203f75a3a90a92c9
4
+ data.tar.gz: b3ac26fa3529867d389cacfc091f8a6f28307321
5
+ SHA512:
6
+ metadata.gz: ab264c24a29c2d5e28e879787fea2760627d40b11da2079082a86a0b46571a27bb870af13cfc68b37405561e6fe44ae5a58d208dd48f0b62628e9ccb0dfa61ca
7
+ data.tar.gz: 73ea74d511f33188f506035c09a0ef6d94bcb71931f331a74c287a73edf7bf3c2d108f46235d707989562dfb94591583e0eabe61ae0d26563766f827ad84686e
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require 'rmagick'
5
+ require 'ruby-progressbar'
6
+
7
+ DEFAULT_OUTPUT_FILENAME = 'output.png'.freeze
8
+ DEFAULT_OVERLAP_HEIGHT = 15
9
+
10
+ options = ARGV.getopts('', 'help', 'h', 'output:', 'o:', 'overlap-height:')
11
+ if ARGV.empty? || options['h'] || options['help']
12
+ puts 'usage: stitch [--output output.png] [--overlap-height 15] 1.png 2.png 3.png'
13
+ exit(0)
14
+ end
15
+ output_file = options['o'] || DEFAULT_OUTPUT_FILENAME
16
+ overlap_height = (options['overlap-height'] || DEFAULT_OVERLAP_HEIGHT).to_i
17
+
18
+ source_images = Magick::ImageList.new(*ARGV)
19
+ progress_bar = ProgressBar.create(total: source_images.size)
20
+ result = source_images.inject do |previous_image, image|
21
+ combined = Magick::ImageList.new
22
+ combined.push(previous_image.crop(Magick::NorthGravity, previous_image.columns, previous_image.rows - overlap_height))
23
+ bottom_of_previous_image = previous_image.crop(Magick::SouthGravity, previous_image.columns, overlap_height)
24
+ (image.rows - bottom_of_previous_image.rows).times.each do |row|
25
+ if bottom_of_previous_image == image.crop(Magick::NorthGravity, 0, row, image.columns, overlap_height)
26
+ combined.push(image.crop(Magick::NorthGravity, 0, row, image.columns, image.rows - row))
27
+ break
28
+ end
29
+ if row == image.rows - bottom_of_previous_image.rows - 1
30
+ puts 'error: failed to combine images'
31
+ exit(1)
32
+ end
33
+ end
34
+ progress_bar.increment
35
+ combined.append(true)
36
+ end
37
+
38
+ result.write(output_file)
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: image-stitcher
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Shintaro Morikawa
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-08-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rmagick
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.15'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.15'
27
+ - !ruby/object:Gem::Dependency
28
+ name: ruby-progressbar
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.8'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.8'
41
+ description: Combine continuous multiple images
42
+ email: sntr92@gmail.com
43
+ executables:
44
+ - stitch
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - bin/stitch
49
+ homepage: http://rubygems.org/gems/image-stitcher
50
+ licenses:
51
+ - MIT
52
+ metadata: {}
53
+ post_install_message:
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ requirements: []
68
+ rubyforge_project:
69
+ rubygems_version: 2.4.5.1
70
+ signing_key:
71
+ specification_version: 4
72
+ summary: Combine continuous multiple images
73
+ test_files: []
74
+ has_rdoc: