image-stitcher 0.0.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/stitch +11 -7
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 662e6f4fe4b9933e78669eba8309cc77e8f43d85
|
4
|
+
data.tar.gz: 2f9ca7a5bce41d804f6708348f0b4712a37a39ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d48df967a41853df6af59e45e79dec832cf51d0e005b6365092ac56fcd060014801304e78ae5abcf6e8015092d35e7b6122bd6f30c755710495452c3354a039
|
7
|
+
data.tar.gz: 4c9090112f845473f86004034e56030b9e64c532361ad95bcc17614846c66b80b90aeb87c21628e4961c005acfcb9ec10c4a34f3ab1351b406a368cb0f3c2a25
|
data/bin/stitch
CHANGED
@@ -6,28 +6,32 @@ require 'ruby-progressbar'
|
|
6
6
|
|
7
7
|
DEFAULT_OUTPUT_FILENAME = 'output.png'.freeze
|
8
8
|
DEFAULT_OVERLAP_HEIGHT = 15
|
9
|
+
DEFAULT_FIXED_FOOTER_HEIGHT = 0
|
9
10
|
|
10
|
-
options = ARGV.getopts('', 'help', '
|
11
|
-
if ARGV.empty? || options['
|
12
|
-
puts 'usage: stitch [--output output.png] [--overlap-height 15] 1.png 2.png 3.png'
|
11
|
+
options = ARGV.getopts('', 'help', 'o:', 'output:', 'overlap-height:', 'fixed-footer-height:')
|
12
|
+
if ARGV.empty? || options['help']
|
13
|
+
puts 'usage: stitch [--output output.png] [--overlap-height 15] [--fixed-footer-height 50] 1.png 2.png 3.png'
|
13
14
|
exit(0)
|
14
15
|
end
|
15
|
-
output_file = options['o'] || DEFAULT_OUTPUT_FILENAME
|
16
|
+
output_file = options['o'] || options['output'] || DEFAULT_OUTPUT_FILENAME
|
16
17
|
overlap_height = (options['overlap-height'] || DEFAULT_OVERLAP_HEIGHT).to_i
|
18
|
+
fixed_footer_height = (options['fixed-footer-height'] || DEFAULT_FIXED_FOOTER_HEIGHT).to_i
|
17
19
|
|
18
20
|
source_images = Magick::ImageList.new(*ARGV)
|
19
21
|
progress_bar = ProgressBar.create(total: source_images.size)
|
20
22
|
result = source_images.inject do |previous_image, image|
|
21
23
|
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(
|
24
|
+
combined.push(previous_image.crop(Magick::NorthGravity, previous_image.columns, previous_image.rows - fixed_footer_height - overlap_height))
|
25
|
+
bottom_of_previous_image = previous_image.crop(0, previous_image.rows - fixed_footer_height - overlap_height, previous_image.columns, overlap_height)
|
26
|
+
image_is_last = (image == source_images.last)
|
24
27
|
(image.rows - bottom_of_previous_image.rows).times.each do |row|
|
25
28
|
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))
|
29
|
+
combined.push(image.crop(Magick::NorthGravity, 0, row, image.columns, image.rows - (image_is_last ? 0 : fixed_footer_height) - row))
|
27
30
|
break
|
28
31
|
end
|
29
32
|
if row == image.rows - bottom_of_previous_image.rows - 1
|
30
33
|
puts 'error: failed to combine images'
|
34
|
+
combined.write(output_file)
|
31
35
|
exit(1)
|
32
36
|
end
|
33
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: image-stitcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shintaro Morikawa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rmagick
|
@@ -46,7 +46,7 @@ extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
48
|
- bin/stitch
|
49
|
-
homepage:
|
49
|
+
homepage: https://github.com/morishin/image-stitcher
|
50
50
|
licenses:
|
51
51
|
- MIT
|
52
52
|
metadata: {}
|
@@ -66,9 +66,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
66
|
version: '0'
|
67
67
|
requirements: []
|
68
68
|
rubyforge_project:
|
69
|
-
rubygems_version: 2.
|
69
|
+
rubygems_version: 2.5.2
|
70
70
|
signing_key:
|
71
71
|
specification_version: 4
|
72
72
|
summary: Combine continuous multiple images
|
73
73
|
test_files: []
|
74
|
-
has_rdoc:
|