fix_iphone_picture_orientation 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +92 -0
- data/Guardfile +18 -0
- data/LICENSE.txt +7 -0
- data/README.md +29 -0
- data/Rakefile +66 -0
- data/bin/fix_iphone_picture_orientation +52 -0
- data/features/fix_iphone_picture_orientation.feature +15 -0
- data/features/step_definitions/fix_iphone_picture_orientation_steps.rb +1 -0
- data/features/support/env.rb +16 -0
- data/fix_iphone_picture_orientation.gemspec +44 -0
- data/lib/fix_iphone_picture_orientation.rb +54 -0
- data/lib/fix_iphone_picture_orientation/cmd_runner.rb +12 -0
- data/lib/fix_iphone_picture_orientation/version.rb +3 -0
- data/spec/lib/fix_iphone_picture_orientation/cmd_runner_spec.rb +27 -0
- data/spec/lib/fix_iphone_picture_orientation_spec.rb +63 -0
- data/spec/spec_helper.rb +25 -0
- data/spec/support/test_data/test1.jpg +0 -0
- data/spec/support/test_data/test2.jpg +0 -0
- data/spec/support/test_data/test2.jpg_original +0 -0
- data/spec/support/test_data/test3.jpg +0 -0
- data/spec/support/test_data/test3.jpg_original +0 -0
- data/spec/support/test_data/test4.jpg +0 -0
- data/spec/support/test_data/test4.jpg_original +0 -0
- metadata +236 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a8c2a6e3447b279aa4ef079d3ac8d2b473f40959
|
4
|
+
data.tar.gz: 50f481b244a4f6d33289f4105257cd46356fd072
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b120471b0223f03792f2597012864119143c57f4d144733c520fd0b7f1ad22558de5f3b992c0bafe22bdfc6d1a3c84d8472389eeaeb21323343587e7aadd8ece
|
7
|
+
data.tar.gz: 6300bd83b5bb06daf533d2291ec9199dfcc76b707aac4e6246c440dc85daa358338224db40db05e0592c80de83c034bac867ee4da94d4918615f0bba9191c762
|
data/.rspec
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
fix_iphone_picture_orientation (0.0.1)
|
5
|
+
methadone (~> 1.3.1)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
aruba (0.5.3)
|
11
|
+
childprocess (>= 0.3.6)
|
12
|
+
cucumber (>= 1.1.1)
|
13
|
+
rspec-expectations (>= 2.7.0)
|
14
|
+
builder (3.2.2)
|
15
|
+
celluloid (0.15.2)
|
16
|
+
timers (~> 1.1.0)
|
17
|
+
childprocess (0.3.9)
|
18
|
+
ffi (~> 1.0, >= 1.0.11)
|
19
|
+
coderay (1.0.9)
|
20
|
+
cucumber (1.3.9)
|
21
|
+
builder (>= 2.1.2)
|
22
|
+
diff-lcs (>= 1.1.3)
|
23
|
+
gherkin (~> 2.12)
|
24
|
+
multi_json (>= 1.7.5, < 2.0)
|
25
|
+
multi_test (>= 0.0.2)
|
26
|
+
diff-lcs (1.2.5)
|
27
|
+
ffi (1.9.3)
|
28
|
+
formatador (0.2.4)
|
29
|
+
gherkin (2.12.2)
|
30
|
+
multi_json (~> 1.3)
|
31
|
+
guard (2.2.3)
|
32
|
+
formatador (>= 0.2.4)
|
33
|
+
listen (~> 2.1)
|
34
|
+
lumberjack (~> 1.0)
|
35
|
+
pry (>= 0.9.12)
|
36
|
+
thor (>= 0.18.1)
|
37
|
+
guard-bundler (2.0.0)
|
38
|
+
bundler (~> 1.0)
|
39
|
+
guard (~> 2.2)
|
40
|
+
guard-cucumber (1.4.0)
|
41
|
+
cucumber (>= 1.2.0)
|
42
|
+
guard (>= 1.1.0)
|
43
|
+
guard-rspec (4.0.3)
|
44
|
+
guard (>= 2.1.1)
|
45
|
+
rspec (~> 2.14)
|
46
|
+
json (1.8.1)
|
47
|
+
listen (2.2.0)
|
48
|
+
celluloid (>= 0.15.2)
|
49
|
+
rb-fsevent (>= 0.9.3)
|
50
|
+
rb-inotify (>= 0.9)
|
51
|
+
lumberjack (1.0.4)
|
52
|
+
methadone (1.3.1)
|
53
|
+
bundler
|
54
|
+
method_source (0.8.2)
|
55
|
+
multi_json (1.8.2)
|
56
|
+
multi_test (0.0.2)
|
57
|
+
pry (0.9.12.2)
|
58
|
+
coderay (~> 1.0.5)
|
59
|
+
method_source (~> 0.8)
|
60
|
+
slop (~> 3.4)
|
61
|
+
rake (10.1.0)
|
62
|
+
rb-fsevent (0.9.3)
|
63
|
+
rb-inotify (0.9.2)
|
64
|
+
ffi (>= 0.5.0)
|
65
|
+
rdoc (4.0.1)
|
66
|
+
json (~> 1.4)
|
67
|
+
rspec (2.14.1)
|
68
|
+
rspec-core (~> 2.14.0)
|
69
|
+
rspec-expectations (~> 2.14.0)
|
70
|
+
rspec-mocks (~> 2.14.0)
|
71
|
+
rspec-core (2.14.7)
|
72
|
+
rspec-expectations (2.14.4)
|
73
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
74
|
+
rspec-mocks (2.14.4)
|
75
|
+
slop (3.4.6)
|
76
|
+
thor (0.18.1)
|
77
|
+
timers (1.1.0)
|
78
|
+
|
79
|
+
PLATFORMS
|
80
|
+
ruby
|
81
|
+
|
82
|
+
DEPENDENCIES
|
83
|
+
aruba
|
84
|
+
bundler (~> 1.3)
|
85
|
+
fix_iphone_picture_orientation!
|
86
|
+
guard
|
87
|
+
guard-bundler
|
88
|
+
guard-cucumber
|
89
|
+
guard-rspec
|
90
|
+
rake
|
91
|
+
rdoc
|
92
|
+
rspec
|
data/Guardfile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
guard :bundler do
|
2
|
+
watch('Gemfile')
|
3
|
+
watch(/^.+\.gemspec/)
|
4
|
+
end
|
5
|
+
|
6
|
+
guard 'cucumber', cli: "--format pretty" do
|
7
|
+
watch(%r{^features/.+\.feature$})
|
8
|
+
watch(%r{^features/support/.+$}) { 'features' }
|
9
|
+
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
|
10
|
+
watch(%r{^bin/fix_iphone_picture_orientation}) {'features'}
|
11
|
+
end
|
12
|
+
|
13
|
+
guard :rspec, all_on_start: true, all_after_pass: true, cmd: "bundle exec rspec -f doc -c" do
|
14
|
+
watch(%r{^spec/.+_spec\.rb$})
|
15
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
16
|
+
watch('spec/spec_helper.rb') { "spec" }
|
17
|
+
end
|
18
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright (c) 2013 YOUR NAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# FixIphonePictureOrientation
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'fix_iphone_picture_orientation'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install fix_iphone_picture_orientation
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
def dump_load_path
|
2
|
+
puts $LOAD_PATH.join("\n")
|
3
|
+
found = nil
|
4
|
+
$LOAD_PATH.each do |path|
|
5
|
+
if File.exists?(File.join(path,"rspec"))
|
6
|
+
puts "Found rspec in #{path}"
|
7
|
+
if File.exists?(File.join(path,"rspec","core"))
|
8
|
+
puts "Found core"
|
9
|
+
if File.exists?(File.join(path,"rspec","core","rake_task"))
|
10
|
+
puts "Found rake_task"
|
11
|
+
found = path
|
12
|
+
else
|
13
|
+
puts "!! no rake_task"
|
14
|
+
end
|
15
|
+
else
|
16
|
+
puts "!!! no core"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
if found.nil?
|
21
|
+
puts "Didn't find rspec/core/rake_task anywhere"
|
22
|
+
else
|
23
|
+
puts "Found in #{path}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
require 'bundler'
|
27
|
+
require 'rake/clean'
|
28
|
+
|
29
|
+
begin
|
30
|
+
require 'rspec/core/rake_task'
|
31
|
+
rescue LoadError
|
32
|
+
dump_load_path
|
33
|
+
raise
|
34
|
+
end
|
35
|
+
|
36
|
+
require 'cucumber'
|
37
|
+
require 'cucumber/rake/task'
|
38
|
+
gem 'rdoc' # we need the installed RDoc gem, not the system one
|
39
|
+
require 'rdoc/task'
|
40
|
+
|
41
|
+
include Rake::DSL
|
42
|
+
|
43
|
+
Bundler::GemHelper.install_tasks
|
44
|
+
|
45
|
+
|
46
|
+
RSpec::Core::RakeTask.new do |t|
|
47
|
+
# Put spec opts in a file named .rspec in root
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
CUKE_RESULTS = 'results.html'
|
52
|
+
CLEAN << CUKE_RESULTS
|
53
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
54
|
+
t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty --no-source -x"
|
55
|
+
t.fork = false
|
56
|
+
end
|
57
|
+
|
58
|
+
Rake::RDocTask.new do |rd|
|
59
|
+
|
60
|
+
rd.main = "README.rdoc"
|
61
|
+
|
62
|
+
rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
|
63
|
+
end
|
64
|
+
|
65
|
+
task :default => [:spec,:features]
|
66
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'methadone'
|
5
|
+
require 'fix_iphone_picture_orientation.rb'
|
6
|
+
|
7
|
+
class App
|
8
|
+
include Methadone::Main
|
9
|
+
include Methadone::CLILogging
|
10
|
+
|
11
|
+
main do |directory|
|
12
|
+
logger.level=Logger::WARN if options[:quiet]
|
13
|
+
logger.error_level = Logger::DEBUG if options[:debug]
|
14
|
+
|
15
|
+
directory ||= Dir.pwd
|
16
|
+
|
17
|
+
FixIphonePictureOrientation.run(directory) or
|
18
|
+
warn "Not all files processed"
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
# supplemental methods here
|
23
|
+
|
24
|
+
# Declare command-line interface here
|
25
|
+
|
26
|
+
description "Fix iPhone photos with bad orientations"
|
27
|
+
|
28
|
+
# Accept flags via:
|
29
|
+
# on("--flag VAL","Some flag")
|
30
|
+
# options[flag] will contain VAL
|
31
|
+
#
|
32
|
+
# Specify switches via:
|
33
|
+
# on("--[no-]switch","Some switch")
|
34
|
+
on("--quiet","Run silently unless there are errors")
|
35
|
+
on("--debug","Turn on debugging info")
|
36
|
+
|
37
|
+
|
38
|
+
# Or, just call OptionParser methods on opts
|
39
|
+
#
|
40
|
+
# Require an argument
|
41
|
+
# arg :some_arg
|
42
|
+
|
43
|
+
# # Make an argument optional
|
44
|
+
# arg :optional_arg, :optional
|
45
|
+
arg :directory,:optional, "Directory to run conversion upon.","Default is current directory."
|
46
|
+
|
47
|
+
version FixIphonePictureOrientation::VERSION
|
48
|
+
|
49
|
+
use_log_level_option
|
50
|
+
|
51
|
+
go!
|
52
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Feature: My bootstrapped app kinda works
|
2
|
+
In order to get going on coding my awesome app
|
3
|
+
I want to have aruba and cucumber setup
|
4
|
+
So I don't have to do it myself
|
5
|
+
|
6
|
+
Scenario: App just runs
|
7
|
+
When I get help for "fix_iphone_picture_orientation"
|
8
|
+
Then the exit status should be 0
|
9
|
+
And the banner should be present
|
10
|
+
And the banner should document that this app takes options
|
11
|
+
And the following options should be documented:
|
12
|
+
|--version|
|
13
|
+
|--quiet|
|
14
|
+
And the banner should document that this app's arguments are:
|
15
|
+
|directory|
|
@@ -0,0 +1 @@
|
|
1
|
+
# Put your step definitions here
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'aruba/cucumber'
|
2
|
+
require 'methadone/cucumber'
|
3
|
+
|
4
|
+
ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
|
5
|
+
LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'..','..','lib')
|
6
|
+
|
7
|
+
Before do
|
8
|
+
# Using "announce" causes massive warnings on 1.9.2
|
9
|
+
@puts = true
|
10
|
+
@original_rubylib = ENV['RUBYLIB']
|
11
|
+
ENV['RUBYLIB'] = LIB_DIR + File::PATH_SEPARATOR + ENV['RUBYLIB'].to_s
|
12
|
+
end
|
13
|
+
|
14
|
+
After do
|
15
|
+
ENV['RUBYLIB'] = @original_rubylib
|
16
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'fix_iphone_picture_orientation/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "fix_iphone_picture_orientation"
|
8
|
+
spec.version = FixIphonePictureOrientation::VERSION
|
9
|
+
spec.authors = ["Tamara Temple"]
|
10
|
+
spec.email = ["tamouse@gmail.com"]
|
11
|
+
spec.description = %q{Convert iPhone images to have a useful Orientation tag value
|
12
|
+
and be internally correctly oriented.
|
13
|
+
|
14
|
+
The iPhone has used the EXIF tag Orientation to store the actual
|
15
|
+
orientation of the camera. A lot of programs and libraries don't
|
16
|
+
seem to understand this, especially online photo galleries such
|
17
|
+
as Flickr and Gallery.
|
18
|
+
|
19
|
+
This program will modify the image to rotate it internally according
|
20
|
+
to the iPhone's orientation value, and then set the EXIF orientation
|
21
|
+
tag to "Horizontal (normal)" thus removing the confusion.
|
22
|
+
}
|
23
|
+
spec.summary = %q{Convert iPhone images to proper internal orientation and change Orientation tag to Horizontal}
|
24
|
+
spec.homepage = "http://github.com/tamouse/fix_iphone_orientation.git"
|
25
|
+
spec.license = "MIT"
|
26
|
+
|
27
|
+
spec.files = `git ls-files`.split($/)
|
28
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
29
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
spec.add_dependency 'methadone', '~> 1.3.1'
|
33
|
+
|
34
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
35
|
+
spec.add_development_dependency "rake"
|
36
|
+
spec.add_development_dependency 'rdoc'
|
37
|
+
spec.add_development_dependency 'aruba'
|
38
|
+
spec.add_development_dependency 'rspec'
|
39
|
+
spec.add_development_dependency 'guard'
|
40
|
+
spec.add_development_dependency 'guard-rspec'
|
41
|
+
spec.add_development_dependency 'guard-cucumber'
|
42
|
+
spec.add_development_dependency 'guard-bundler'
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'json'
|
2
|
+
require "fix_iphone_picture_orientation/version"
|
3
|
+
require "fix_iphone_picture_orientation/cmd_runner"
|
4
|
+
require 'methadone'
|
5
|
+
|
6
|
+
|
7
|
+
module FixIphonePictureOrientation
|
8
|
+
|
9
|
+
extend Methadone::CLILogging
|
10
|
+
|
11
|
+
def self.run(dir)
|
12
|
+
rotate_pictures(dir,build_work_list(dir)).empty?
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
def self.build_work_list(dir)
|
17
|
+
Dir.chdir(dir) do |dir|
|
18
|
+
o, e, st = CmdRunner.run("exiftool -j -ORIENTATION #{file_list(dir).join(" ")}")
|
19
|
+
raise "exiftool failed: #{st.exitstatus} #{e}" unless st.success?
|
20
|
+
list = ::JSON.parse(o)
|
21
|
+
list.map!{|i| ::OpenStruct.new(i)}
|
22
|
+
list.reject!{|i| i.Orientation == "Horizontal (normal)"}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.rotate_pictures(dir,list)
|
27
|
+
Dir.chdir(dir) do |dir|
|
28
|
+
list.each do |image|
|
29
|
+
rotate = 0
|
30
|
+
case image.Orientation
|
31
|
+
when /90 CW/
|
32
|
+
rotate = 90
|
33
|
+
when /180/
|
34
|
+
rotate = 180
|
35
|
+
when /270 CW/
|
36
|
+
rotate = -90
|
37
|
+
end
|
38
|
+
info "Converting #{image.SourceFile}"
|
39
|
+
o,e,st = CmdRunner.run("mogrify -verbose -rotate '#{rotate}' '#{image.SourceFile}'")
|
40
|
+
raise "mogrify failed: #{st.exitstatus} #{e}" unless st.success?
|
41
|
+
o,e,st = CmdRunner.run("exiftool -ORIENTATION=\"Horizontal (normal)\" '#{image.SourceFile}'")
|
42
|
+
raise "exiftool failed: #{st.exitstatus} #{e}" unless st.success?
|
43
|
+
end
|
44
|
+
build_work_list(dir)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.file_list(dir=Dir.pwd)
|
49
|
+
Dir.chdir(dir) do |dir|
|
50
|
+
Dir["*.JPG","*.jpg","*.PNG","*.png","*.JEPG","*.jpeg"]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module FixIphonePictureOrientation
|
4
|
+
|
5
|
+
describe CmdRunner do
|
6
|
+
it{should respond_to(:run)}
|
7
|
+
context "running a simple command" do
|
8
|
+
let(:result){CmdRunner.run('ls')}
|
9
|
+
it {result.should be_an Array}
|
10
|
+
it {result.length.should eq 3}
|
11
|
+
it {result.last.success?.should be_true}
|
12
|
+
end
|
13
|
+
context "running a complex command" do
|
14
|
+
let(:result){CmdRunner.run('ls','-l','-A','-F')}
|
15
|
+
it {result.should be_an Array}
|
16
|
+
it {result.length.should eq 3}
|
17
|
+
it {result.last.success?.should be_true}
|
18
|
+
end
|
19
|
+
|
20
|
+
context "running a bogus command" do
|
21
|
+
it {expect{CmdRunner.run("blahblahblah")}.to raise_error Errno::ENOENT}
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module FixIphonePictureOrientation
|
5
|
+
|
6
|
+
describe "Version" do
|
7
|
+
it{FixIphonePictureOrientation::VERSION.should_not be_nil}
|
8
|
+
end
|
9
|
+
|
10
|
+
describe FixIphonePictureOrientation do
|
11
|
+
let(:dir){File.expand_path("../../support/test_data",__FILE__)}
|
12
|
+
before do
|
13
|
+
Dir.chdir(dir) do |dir|
|
14
|
+
FileUtils.rm(Dir["*"])
|
15
|
+
system "convert rose: test1.jpg"
|
16
|
+
system "exiftool -ORIENTATION=\"Horizontal (normal)\" test1.jpg >/dev/null"
|
17
|
+
system "convert rose: test2.jpg"
|
18
|
+
system "exiftool -ORIENTATION=\"Rotate 90 CW\" test2.jpg >/dev/null"
|
19
|
+
system "convert rose: test3.jpg"
|
20
|
+
system "exiftool -ORIENTATION=\"Rotate 180\" test3.jpg >/dev/null"
|
21
|
+
system "convert rose: test4.jpg"
|
22
|
+
system "exiftool -ORIENTATION=\"Rotate 270 CW\" test4.jpg >/dev/null"
|
23
|
+
FileUtils.rm(Dir["*_original"])
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it "dir should exist" do
|
28
|
+
Dir.exists?(dir).should be_true
|
29
|
+
end
|
30
|
+
|
31
|
+
context "file_list" do
|
32
|
+
let(:result){FixIphonePictureOrientation.file_list(dir)}
|
33
|
+
let(:expected){%w[test1.jpg test2.jpg test3.jpg test4.jpg]}
|
34
|
+
it{result.length.should eq 4}
|
35
|
+
it "should return expected list of files" do
|
36
|
+
(result-expected).should be_empty
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
context "build_work_list" do
|
42
|
+
let(:result){FixIphonePictureOrientation.build_work_list(dir)}
|
43
|
+
let(:expected){%w[test2.jpg test3.jpg test4.jpg]}
|
44
|
+
it{result.should be_an Array}
|
45
|
+
it{result.length.should eq 3}
|
46
|
+
it "should return only the non-horizontal files" do
|
47
|
+
(result.map(&:SourceFile)-expected).should be_empty
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context "rotate_pictures" do
|
52
|
+
let(:list){FixIphonePictureOrientation.build_work_list(dir)}
|
53
|
+
let(:result){FixIphonePictureOrientation.rotate_pictures(dir,list)}
|
54
|
+
it{result.should be_empty}
|
55
|
+
end
|
56
|
+
|
57
|
+
context "run" do
|
58
|
+
let(:result){FixIphonePictureOrientation.run(dir)}
|
59
|
+
it{result.should be_true}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
|
+
config.run_all_when_everything_filtered = true
|
10
|
+
config.filter_run :focus
|
11
|
+
|
12
|
+
# Run specs in random order to surface order dependencies. If you find an
|
13
|
+
# order dependency and want to debug it, you can fix the order by providing
|
14
|
+
# the seed, which is printed after each run.
|
15
|
+
# --seed 1234
|
16
|
+
# config.order = 'random'
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'methadone'
|
20
|
+
|
21
|
+
require 'fix_iphone_picture_orientation'
|
22
|
+
module FixIphoneOrientation
|
23
|
+
extend Methadone::CLILogging
|
24
|
+
logger.error_level = Logger::DEBUG
|
25
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,236 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fix_iphone_picture_orientation
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tamara Temple
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: methadone
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.3.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.3.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rdoc
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: aruba
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: guard
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: guard-rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: guard-cucumber
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: guard-bundler
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - '>='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - '>='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
description: |
|
154
|
+
Convert iPhone images to have a useful Orientation tag value
|
155
|
+
and be internally correctly oriented.
|
156
|
+
|
157
|
+
The iPhone has used the EXIF tag Orientation to store the actual
|
158
|
+
orientation of the camera. A lot of programs and libraries don't
|
159
|
+
seem to understand this, especially online photo galleries such
|
160
|
+
as Flickr and Gallery.
|
161
|
+
|
162
|
+
This program will modify the image to rotate it internally according
|
163
|
+
to the iPhone's orientation value, and then set the EXIF orientation
|
164
|
+
tag to "Horizontal (normal)" thus removing the confusion.
|
165
|
+
email:
|
166
|
+
- tamouse@gmail.com
|
167
|
+
executables:
|
168
|
+
- fix_iphone_picture_orientation
|
169
|
+
extensions: []
|
170
|
+
extra_rdoc_files: []
|
171
|
+
files:
|
172
|
+
- .gitignore
|
173
|
+
- .rspec
|
174
|
+
- Gemfile
|
175
|
+
- Gemfile.lock
|
176
|
+
- Guardfile
|
177
|
+
- LICENSE.txt
|
178
|
+
- README.md
|
179
|
+
- Rakefile
|
180
|
+
- bin/fix_iphone_picture_orientation
|
181
|
+
- features/fix_iphone_picture_orientation.feature
|
182
|
+
- features/step_definitions/fix_iphone_picture_orientation_steps.rb
|
183
|
+
- features/support/env.rb
|
184
|
+
- fix_iphone_picture_orientation.gemspec
|
185
|
+
- lib/fix_iphone_picture_orientation.rb
|
186
|
+
- lib/fix_iphone_picture_orientation/cmd_runner.rb
|
187
|
+
- lib/fix_iphone_picture_orientation/version.rb
|
188
|
+
- spec/lib/fix_iphone_picture_orientation/cmd_runner_spec.rb
|
189
|
+
- spec/lib/fix_iphone_picture_orientation_spec.rb
|
190
|
+
- spec/spec_helper.rb
|
191
|
+
- spec/support/test_data/test1.jpg
|
192
|
+
- spec/support/test_data/test2.jpg
|
193
|
+
- spec/support/test_data/test2.jpg_original
|
194
|
+
- spec/support/test_data/test3.jpg
|
195
|
+
- spec/support/test_data/test3.jpg_original
|
196
|
+
- spec/support/test_data/test4.jpg
|
197
|
+
- spec/support/test_data/test4.jpg_original
|
198
|
+
homepage: http://github.com/tamouse/fix_iphone_orientation.git
|
199
|
+
licenses:
|
200
|
+
- MIT
|
201
|
+
metadata: {}
|
202
|
+
post_install_message:
|
203
|
+
rdoc_options: []
|
204
|
+
require_paths:
|
205
|
+
- lib
|
206
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
207
|
+
requirements:
|
208
|
+
- - '>='
|
209
|
+
- !ruby/object:Gem::Version
|
210
|
+
version: '0'
|
211
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - '>='
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
requirements: []
|
217
|
+
rubyforge_project:
|
218
|
+
rubygems_version: 2.0.3
|
219
|
+
signing_key:
|
220
|
+
specification_version: 4
|
221
|
+
summary: Convert iPhone images to proper internal orientation and change Orientation
|
222
|
+
tag to Horizontal
|
223
|
+
test_files:
|
224
|
+
- features/fix_iphone_picture_orientation.feature
|
225
|
+
- features/step_definitions/fix_iphone_picture_orientation_steps.rb
|
226
|
+
- features/support/env.rb
|
227
|
+
- spec/lib/fix_iphone_picture_orientation/cmd_runner_spec.rb
|
228
|
+
- spec/lib/fix_iphone_picture_orientation_spec.rb
|
229
|
+
- spec/spec_helper.rb
|
230
|
+
- spec/support/test_data/test1.jpg
|
231
|
+
- spec/support/test_data/test2.jpg
|
232
|
+
- spec/support/test_data/test2.jpg_original
|
233
|
+
- spec/support/test_data/test3.jpg
|
234
|
+
- spec/support/test_data/test3.jpg_original
|
235
|
+
- spec/support/test_data/test4.jpg
|
236
|
+
- spec/support/test_data/test4.jpg_original
|