mpo_tools 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +33 -0
- data/LICENSE +22 -0
- data/README.md +84 -0
- data/Rakefile +7 -0
- data/bin/mpo_convert +30 -0
- data/lib/mpo_tools.rb +137 -0
- data/lib/version.rb +3 -0
- data/mpo_tools.gemspec +28 -0
- data/spec/example_data/sample.mpo +0 -0
- data/spec/mpo_tools_spec.rb +103 -0
- data/spec/spec_helper.rb +4 -0
- metadata +128 -0
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm ruby-1.9.2-p290@mpo_tools
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
mpo_tools (0.0.1)
|
5
|
+
rmagick
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
colored (1.2)
|
11
|
+
diff-lcs (1.2.5)
|
12
|
+
rake (10.1.1)
|
13
|
+
rake-notes (0.2.0)
|
14
|
+
colored
|
15
|
+
rake
|
16
|
+
rmagick (2.13.2)
|
17
|
+
rspec (2.14.1)
|
18
|
+
rspec-core (~> 2.14.0)
|
19
|
+
rspec-expectations (~> 2.14.0)
|
20
|
+
rspec-mocks (~> 2.14.0)
|
21
|
+
rspec-core (2.14.7)
|
22
|
+
rspec-expectations (2.14.5)
|
23
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
24
|
+
rspec-mocks (2.14.5)
|
25
|
+
|
26
|
+
PLATFORMS
|
27
|
+
ruby
|
28
|
+
|
29
|
+
DEPENDENCIES
|
30
|
+
mpo_tools!
|
31
|
+
rake
|
32
|
+
rake-notes
|
33
|
+
rspec
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Will Brown
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# MPO Tools
|
2
|
+
|
3
|
+
## Synopsis
|
4
|
+
This gem provides some simple utility methods for working with MPO format 3D image files. This file format is used in 3D cameras such as the [Nintendo 3DS](http://en.wikipedia.org/wiki/Nintendo_3ds) and the [Fujifilm FinePix W3](http://en.wikipedia.org/wiki/Fujifilm_FinePix_Real_3D_W3).
|
5
|
+
|
6
|
+
ImageMagick does not support this file type and, as a consequence, I found the format difficult to work with when I needed to process images in bulk (for example when creating 3D timelapses). This gem is intended to make that process easier.
|
7
|
+
|
8
|
+
The gem can be used to extract the EXIF data or the left and right images themselves from an MPO file. It can also be used to convert MPO files into a number of different (2D display friendly) viewing formats.
|
9
|
+
|
10
|
+
Supported output formats include:
|
11
|
+
|
12
|
+
| Name | Format | Description |
|
13
|
+
| ---------- | ------------- | ---------------------------------------------- |
|
14
|
+
| Stereogram | `:stereo` | left/right side by side |
|
15
|
+
| Cross-eyed | `:cross_eyed` | right/left side by side |
|
16
|
+
| Analglyph | `:analglyph` | red and blue (for use with coloured glasses) |
|
17
|
+
| Wiggle GIF | `:wiggle` | animated gif (cycles between left/right image) |
|
18
|
+
|
19
|
+
Also included is a binary for converting MPO files on the command line.
|
20
|
+
|
21
|
+
The mechanism for extracting the left and right images from the MPO is based on the exiftool usage example described in [this article](http://brainwagon.org/2009/11/04/fujifilm-real-3d-w1-camera/) by Mark VandeWettering.
|
22
|
+
|
23
|
+
|
24
|
+
## Install the gem
|
25
|
+
|
26
|
+
Install it with [RubyGems](https://rubygems.org)
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
gem install mpo_tools
|
30
|
+
```
|
31
|
+
|
32
|
+
or add this to your Gemfile if you use [Bundler](http://gembundler.com)
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
gem 'mpo_tools'
|
36
|
+
```
|
37
|
+
|
38
|
+
MPO Tools is dependent on [exiftool](http://www.sno.phy.queensu.ca/~phil/exiftool/), to install this on Ubuntu run
|
39
|
+
|
40
|
+
sudo apt-get install libimage-exiftool-perl
|
41
|
+
|
42
|
+
## Getting Started
|
43
|
+
|
44
|
+
Here's an example of how you might convert a whole directory of MPO image files to analglyphs and resize them to 320x240 pixels.
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
require 'mpo_tools'
|
48
|
+
path = '/home/bob/3d_pictures/*.MPO'
|
49
|
+
dest = '/home/bob/analglyphs/'
|
50
|
+
Dir.glob(path).each do |mpo|
|
51
|
+
# path_to_mpo, output_path, format, scale/resolution
|
52
|
+
MpoTools.convert mpo, dest, :analglyph, [320,240]
|
53
|
+
end
|
54
|
+
```
|
55
|
+
|
56
|
+
For information on how to use the command line tool run
|
57
|
+
|
58
|
+
$ mpo_convert -h
|
59
|
+
|
60
|
+
For more information please take a look at the rdoc documentation.
|
61
|
+
|
62
|
+
## License
|
63
|
+
Copyright (c) 2014 Will Brown
|
64
|
+
|
65
|
+
MIT License
|
66
|
+
|
67
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
68
|
+
a copy of this software and associated documentation files (the
|
69
|
+
"Software"), to deal in the Software without restriction, including
|
70
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
71
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
72
|
+
permit persons to whom the Software is furnished to do so, subject to
|
73
|
+
the following conditions:
|
74
|
+
|
75
|
+
The above copyright notice and this permission notice shall be
|
76
|
+
included in all copies or substantial portions of the Software.
|
77
|
+
|
78
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
79
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
80
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
81
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
82
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
83
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
84
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
data/bin/mpo_convert
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Encoding: utf-8
|
3
|
+
# Name: MPO Convert
|
4
|
+
# Author: Will Brown
|
5
|
+
# Created: 2014-02-17
|
6
|
+
# Description:
|
7
|
+
# Utility for converting .mpo 3D image files to other 3D image formats
|
8
|
+
require 'pathname'
|
9
|
+
require 'optparse'
|
10
|
+
$LOAD_PATH << Pathname.new(__FILE__).realpath.parent.parent + 'lib'
|
11
|
+
require 'mpo_tools'
|
12
|
+
|
13
|
+
source, destination, format, scale = nil, nil, :stereo, 1
|
14
|
+
OptionParser.new do |opts|
|
15
|
+
opts.banner = 'Usage: mpo_convert -s pics/sample.mpo -d converted/ -a -c 0.5'
|
16
|
+
opts.on('-s', '--source PATH', 'location of disk of the .mpo file') {|s| source = s }
|
17
|
+
opts.on('-d', '--destination PATH', 'output location of the new file') {|d| destination = d }
|
18
|
+
opts.on('-c', '--scale SCALE', 'The size of the outputted image') {|c| scale = c.to_f }
|
19
|
+
opts.on('-t', '--stereo', 'Output as stereo (default)') { format = :stereo }
|
20
|
+
opts.on('-x', '--cross-eyed', 'Output as cross-eyed') { format = :cross_eyed }
|
21
|
+
opts.on('-w', '--wiggle', 'Output as wiggle gif') { format = :wiggle }
|
22
|
+
opts.on('-a', '--analglyph', 'Output as analglyph') { format = :analglyph }
|
23
|
+
opts.on('-h', '--help', 'this message') { puts opts; exit 1 }
|
24
|
+
end.parse!
|
25
|
+
|
26
|
+
begin
|
27
|
+
MpoTools.convert(source, destination, format, scale)
|
28
|
+
rescue MpoError => e
|
29
|
+
abort e.message
|
30
|
+
end
|
data/lib/mpo_tools.rb
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
['pathname', 'json', 'RMagick'].each { |lib| require lib }
|
2
|
+
|
3
|
+
# Raised when the MPO file cannot be parsed or converted
|
4
|
+
class MpoError < StandardError; end
|
5
|
+
|
6
|
+
# The core library. This module provides methods for converting and extracing
|
7
|
+
# data from MPO format 3D photographs. It uses imagemagick and exiftool to do
|
8
|
+
# this, so both libraries must be installed on your system for this code to work
|
9
|
+
module MpoTools
|
10
|
+
|
11
|
+
# List of supported output formats
|
12
|
+
FORMATS = [:stereo, :cross_eyed, :wiggle, :analglyph]
|
13
|
+
|
14
|
+
# Convert the provided MPO file into the desired format
|
15
|
+
# ==== Parameters
|
16
|
+
# [source] The location of disk of the .mpo file
|
17
|
+
# [destination] The desired output location of the new file (Optional)
|
18
|
+
# [format] The desired output format. A list of valid formats can be found in
|
19
|
+
# the +FORMATS+ constant (Optional, defaults to :stereo)
|
20
|
+
# [scale] The size of the outputted image. This can be provided as a scale
|
21
|
+
# with 1 representing the original size. Alternatively an array can be
|
22
|
+
# passed in with the format [x_size, y_size]
|
23
|
+
#
|
24
|
+
# ==== Returns
|
25
|
+
# * The location on disk of the newly created output file.
|
26
|
+
#
|
27
|
+
# ==== Raises
|
28
|
+
# * MpoError - Raised when the provided source file cannot be converted
|
29
|
+
def self.convert(source, destination=nil, format=FORMATS.first, scale=1)
|
30
|
+
raise MpoError.new "Invalid format: #{format}" if !FORMATS.include?(format)
|
31
|
+
source, destination = validate_paths source, destination, format
|
32
|
+
left, right = extract_images source
|
33
|
+
left, right = scale_images left, right, scale unless scale == 1
|
34
|
+
send "output_as_#{format}", left, right, destination
|
35
|
+
end
|
36
|
+
|
37
|
+
# Reads the source MPO file and returns a hash of exif data
|
38
|
+
# ==== Parameters
|
39
|
+
# [source] The location on disk of the .mpo file
|
40
|
+
#
|
41
|
+
# ==== Returns
|
42
|
+
# * A ruby hash containing the file's exif meta data
|
43
|
+
#
|
44
|
+
# ==== Raises
|
45
|
+
# * MpoError - Raised when exif data cannot be read from the source or when
|
46
|
+
# the exiftool application has not been installed
|
47
|
+
def self.exif_data(source)
|
48
|
+
exif = `exiftool -u -d "%Y-%m-%d %H:%M:%S" -json #{source}`
|
49
|
+
return JSON.parse(exif).first
|
50
|
+
rescue Errno::ENOENT => e
|
51
|
+
raise MpoError.new "Please install 'exiftool' on your machine.\n \"sudo apt-get install libimage-exiftool-perl\" on Ubuntu"
|
52
|
+
rescue JSON::ParserError => e
|
53
|
+
raise MpoError.new 'Unable to read exif data'
|
54
|
+
end
|
55
|
+
|
56
|
+
# Extracts two images from the MPO file
|
57
|
+
# ==== Parameters
|
58
|
+
# [source] The location on disk of the .mpo file
|
59
|
+
#
|
60
|
+
# ==== Returns
|
61
|
+
# * The left eye image in +Magick::Image+ format
|
62
|
+
# * The right eye image in +Magick::Image+ format
|
63
|
+
#
|
64
|
+
# ==== Raises
|
65
|
+
# * MpoError - Raised when two images cannot be created based on the provided
|
66
|
+
# source file or when the exiftool application has not been installed
|
67
|
+
def self.extract_images(source)
|
68
|
+
left = Magick::Image.from_blob(`exiftool -trailer:all= #{source} -o -`)[0]
|
69
|
+
right = Magick::Image.from_blob(`exiftool #{source} -mpimage2 -b`)[0]
|
70
|
+
return left, right
|
71
|
+
rescue Errno::ENOENT => e
|
72
|
+
raise MpoError.new "Please install 'exiftool' on your machine.\n \"sudo apt-get install libimage-exiftool-perl\" on Ubuntu"
|
73
|
+
rescue Magick::ImageMagickError => e
|
74
|
+
raise MpoError.new 'Unable to extract images'
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
# Resizes both left and right images
|
80
|
+
def self.scale_images left, right, scale
|
81
|
+
if scale.is_a?(Array) && scale.length == 2
|
82
|
+
return left.scale(*scale), right.scale(*scale)
|
83
|
+
elsif scale.is_a?(Float) || scale.is_a?(Integer)
|
84
|
+
return left.scale(scale), right.scale(scale)
|
85
|
+
else
|
86
|
+
raise MpoError.new 'Invalid scale'
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# Outputs the 3D image in stereo, left image on the left and right image
|
91
|
+
# on the right
|
92
|
+
def self.output_as_stereo(left, right, destination)
|
93
|
+
destination = "#{destination}.jpg" unless destination =~ /.jpg$/i
|
94
|
+
Magick::ImageList.new.push(left, right).append(false).write(destination)
|
95
|
+
return destination
|
96
|
+
end
|
97
|
+
|
98
|
+
# Creates a reversed stereo image, which can be viewed by going cross-eyed
|
99
|
+
def self.output_as_cross_eyed(left, right, destination)
|
100
|
+
output_as_stereo right, left, destination
|
101
|
+
end
|
102
|
+
|
103
|
+
# Outputs as an analglyph that can be viewed with coloured glasses
|
104
|
+
def self.output_as_analglyph(left, right, destination)
|
105
|
+
destination = "#{destination}.jpg" unless destination =~ /.jpg$/i
|
106
|
+
left.stereo(right).write(destination)
|
107
|
+
return destination
|
108
|
+
end
|
109
|
+
|
110
|
+
# Outputs as a 'wiggle' gif. An animated gif that rapidly cycles between
|
111
|
+
# left and right image
|
112
|
+
def self.output_as_wiggle(left, right, destination)
|
113
|
+
destination = "#{destination}.gif" unless destination =~ /.gif$/i
|
114
|
+
gif = Magick::ImageList.new.push(left, right)
|
115
|
+
gif.delay = 5
|
116
|
+
gif.write(destination)
|
117
|
+
return destination
|
118
|
+
end
|
119
|
+
|
120
|
+
# Validates the provided source and destination paths, builds the destination
|
121
|
+
# path if a full file path has not been provided
|
122
|
+
def self.validate_paths(source, destination, format)
|
123
|
+
raise MpoError.new('Source not an mpo') unless source =~ /\.mpo$/i
|
124
|
+
raise MpoError.new('Source not found') unless File.exists?(source)
|
125
|
+
source = Pathname.new(source)
|
126
|
+
if destination && File.directory?(destination)
|
127
|
+
source_name = source.basename.to_s.gsub(/\.mpo$/, '')
|
128
|
+
destination = Pathname.new(destination) + "#{source_name}_#{format}"
|
129
|
+
elsif destination
|
130
|
+
destination = Pathname.new(destination)
|
131
|
+
else
|
132
|
+
stripped_source = source.realpath.to_s.gsub(/\.mpo$/, '')
|
133
|
+
destination = Pathname.new(stripped_source + "_#{format}")
|
134
|
+
end
|
135
|
+
return source.realpath.to_s, destination.to_s
|
136
|
+
end
|
137
|
+
end
|
data/lib/version.rb
ADDED
data/mpo_tools.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ['Will Brown']
|
6
|
+
gem.email = ['mail@willbrown.name']
|
7
|
+
gem.description = 'Tools for working with MPO format stereoscopic 3D images'
|
8
|
+
gem.summary = 'Tools for working with MPO format stereoscopic 3D images'
|
9
|
+
gem.homepage = 'https://github.com/rawls/mpo_tools'
|
10
|
+
gem.files = `git ls-files`.split($\)
|
11
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
12
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
13
|
+
gem.name = "mpo_tools"
|
14
|
+
gem.require_paths = ["lib"]
|
15
|
+
gem.version = MpoTools::VERSION
|
16
|
+
gem.platform = Gem::Platform::RUBY
|
17
|
+
gem.date = '2014-02-07'
|
18
|
+
gem.license = 'MIT'
|
19
|
+
|
20
|
+
gem.required_ruby_version = '>= 1.9.2'
|
21
|
+
gem.extra_rdoc_files = ['README.md']
|
22
|
+
|
23
|
+
gem.add_runtime_dependency 'rmagick'
|
24
|
+
|
25
|
+
gem.add_development_dependency 'rake'
|
26
|
+
gem.add_development_dependency 'rspec'
|
27
|
+
gem.add_development_dependency 'rake-notes'
|
28
|
+
end
|
Binary file
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'mpo_tools'
|
2
|
+
|
3
|
+
describe MpoTools do
|
4
|
+
before :all do
|
5
|
+
path = Pathname.new(__FILE__).realpath.parent + 'example_data' + 'sample.mpo'
|
6
|
+
@source = path.realpath.to_s
|
7
|
+
@destination = '/tmp/'
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '.convert' do
|
11
|
+
|
12
|
+
context 'format is :stereo' do
|
13
|
+
it 'exports a jpg image' do
|
14
|
+
output_file = MpoTools.convert @source, @destination, :stereo, 1
|
15
|
+
img = Magick::Image.read(output_file).first
|
16
|
+
x_size, y_size = img.columns, img.rows
|
17
|
+
exif = MpoTools.exif_data @source
|
18
|
+
x_size.should eq(exif['ImageWidth']*2)
|
19
|
+
y_size.should eq(exif['ImageHeight'])
|
20
|
+
FileUtils.rm output_file if File.exists?(output_file)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'format is :cross_eyed' do
|
25
|
+
it 'exports a jpg image' do
|
26
|
+
output_file = MpoTools.convert @source, @destination, :cross_eyed, 1
|
27
|
+
img = Magick::Image.read(output_file).first
|
28
|
+
x_size, y_size = img.columns, img.rows
|
29
|
+
exif = MpoTools.exif_data @source
|
30
|
+
x_size.should eq(exif['ImageWidth']*2)
|
31
|
+
y_size.should eq(exif['ImageHeight'])
|
32
|
+
FileUtils.rm output_file if File.exists?(output_file)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'format is :analglyph' do
|
37
|
+
it 'exports a jpg image' do
|
38
|
+
output_file = MpoTools.convert @source, @destination, :analglyph, 1
|
39
|
+
img = Magick::Image.read(output_file).first
|
40
|
+
x_size, y_size = img.columns, img.rows
|
41
|
+
exif = MpoTools.exif_data @source
|
42
|
+
x_size.should eq(exif['ImageWidth'])
|
43
|
+
y_size.should eq(exif['ImageHeight'])
|
44
|
+
FileUtils.rm output_file if File.exists?(output_file)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'format is :wiggle' do
|
49
|
+
it 'exports a gif image' do
|
50
|
+
output_file = MpoTools.convert @source, @destination, :wiggle, 1
|
51
|
+
img = Magick::Image.read(output_file).first
|
52
|
+
x_size, y_size = img.columns, img.rows
|
53
|
+
exif = MpoTools.exif_data @source
|
54
|
+
x_size.should eq(exif['ImageWidth'])
|
55
|
+
y_size.should eq(exif['ImageHeight'])
|
56
|
+
FileUtils.rm output_file if File.exists?(output_file)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'scale is .5' do
|
61
|
+
it 'exports an image 50% of the size of the original' do
|
62
|
+
output_file = MpoTools.convert @source, @destination, :stereo, 0.5
|
63
|
+
img = Magick::Image.read(output_file).first
|
64
|
+
x_size, y_size = img.columns, img.rows
|
65
|
+
exif = MpoTools.exif_data @source
|
66
|
+
x_size.should eq(exif['ImageWidth'])
|
67
|
+
y_size.should eq(exif['ImageHeight']/2)
|
68
|
+
FileUtils.rm output_file if File.exists?(output_file)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context 'scale is [640,480]' do
|
73
|
+
it 'exports an image with a resolution of 640x480' do
|
74
|
+
output_file = MpoTools.convert @source, @destination, :stereo, [640,480]
|
75
|
+
img = Magick::Image.read(output_file).first
|
76
|
+
x_size, y_size = img.columns, img.rows
|
77
|
+
x_size.should eq(1280)
|
78
|
+
y_size.should eq(480)
|
79
|
+
FileUtils.rm output_file if File.exists?(output_file)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
describe '.exif_data' do
|
86
|
+
it 'correctly interprets the EXIF data of .mpo files' do
|
87
|
+
exif = MpoTools.exif_data @source
|
88
|
+
exif["ImageWidth"].should eq(640)
|
89
|
+
exif["ImageHeight"].should eq(480)
|
90
|
+
exif["ColorSpace"].should eq("sRGB")
|
91
|
+
exif["NumberOfImages"].should eq(2)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe '.extract_images' do
|
96
|
+
it 'returns two RMagick::Image objects' do
|
97
|
+
left, right = MpoTools.extract_images @source
|
98
|
+
left.should be_a(Magick::Image)
|
99
|
+
right.should be_a(Magick::Image)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mpo_tools
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Will Brown
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-02-07 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rmagick
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rake-notes
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
description: Tools for working with MPO format stereoscopic 3D images
|
79
|
+
email:
|
80
|
+
- mail@willbrown.name
|
81
|
+
executables:
|
82
|
+
- mpo_convert
|
83
|
+
extensions: []
|
84
|
+
extra_rdoc_files:
|
85
|
+
- README.md
|
86
|
+
files:
|
87
|
+
- .rvmrc
|
88
|
+
- Gemfile
|
89
|
+
- Gemfile.lock
|
90
|
+
- LICENSE
|
91
|
+
- README.md
|
92
|
+
- Rakefile
|
93
|
+
- bin/mpo_convert
|
94
|
+
- lib/mpo_tools.rb
|
95
|
+
- lib/version.rb
|
96
|
+
- mpo_tools.gemspec
|
97
|
+
- spec/example_data/sample.mpo
|
98
|
+
- spec/mpo_tools_spec.rb
|
99
|
+
- spec/spec_helper.rb
|
100
|
+
homepage: https://github.com/rawls/mpo_tools
|
101
|
+
licenses:
|
102
|
+
- MIT
|
103
|
+
post_install_message:
|
104
|
+
rdoc_options: []
|
105
|
+
require_paths:
|
106
|
+
- lib
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
109
|
+
requirements:
|
110
|
+
- - ! '>='
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 1.9.2
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
none: false
|
115
|
+
requirements:
|
116
|
+
- - ! '>='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
requirements: []
|
120
|
+
rubyforge_project:
|
121
|
+
rubygems_version: 1.8.19
|
122
|
+
signing_key:
|
123
|
+
specification_version: 3
|
124
|
+
summary: Tools for working with MPO format stereoscopic 3D images
|
125
|
+
test_files:
|
126
|
+
- spec/example_data/sample.mpo
|
127
|
+
- spec/mpo_tools_spec.rb
|
128
|
+
- spec/spec_helper.rb
|