imagelib 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 +17 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +34 -0
- data/Rakefile +1 -0
- data/bin/add2exif +15 -0
- data/bin/copy2lib +3 -0
- data/imagelib.gemspec +24 -0
- data/lib/imagelib/copy2lib.rb +109 -0
- data/lib/imagelib/version.rb +3 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e6ac09b219d320efef386cd72a6c953a65cc9e09
|
4
|
+
data.tar.gz: 7b0ee743f8edb37fccb0eab49dfd4fa79f2f8dff
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a56914f5462c6f5d86b77ed37f79b6ae118876883790ad71c93e3654077b58f14107b7f59685f299167baf2737e582cef2903bc0b21fb635b6f0fe74fc7457cf
|
7
|
+
data.tar.gz: 13e71dbdd994862ef120cfd6fcdf2efe94f6885a97dcca59bee3c7faa70b12cfb266a13afd20f23a04ef9ed454180bb6508a30f7a06bc2792d355f3dbfdfce4a
|
data/.gitignore
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
imagelib
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.1
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Christian Köstlin
|
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,34 @@
|
|
1
|
+
# Imagelib
|
2
|
+
|
3
|
+
This is a little gem to support my photo workflow.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
gem install imagelib
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
You just have to add a .imagelib file to your home which is a yaml file describing
|
12
|
+
where images can be found and what prefix images from these source should get.
|
13
|
+
example:
|
14
|
+
|
15
|
+
-
|
16
|
+
path: /Volumes/MyGoodCam
|
17
|
+
prefix: hq_
|
18
|
+
-
|
19
|
+
path: /Volumes/MyLittleCam
|
20
|
+
prefix: lq_
|
21
|
+
|
22
|
+
this means that pictures that can be found in /Volumes/MyGoodCam are copied to ~/Pictures/ImageLib with the prefix hq_ and pictures that can be found in /Volumes/MyLittleCam are copied to ~/Pictures/ImageLib with the prefix lq_.
|
23
|
+
|
24
|
+
After that you are ready to launch the executable
|
25
|
+
|
26
|
+
$ copy2lib
|
27
|
+
|
28
|
+
## Contributing
|
29
|
+
|
30
|
+
1. Fork it
|
31
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
32
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
33
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
34
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/add2exif
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
if ARGV.length != 5
|
4
|
+
raise 'Usage add2exif pattern yDelta mDelta dDelta hDelta'
|
5
|
+
end
|
6
|
+
|
7
|
+
pattern = ARGV[0]
|
8
|
+
delta = ARGV[1..4]
|
9
|
+
Dir.glob(pattern).each do | file |
|
10
|
+
if ((file != '.') && (file != '..')) then
|
11
|
+
exe = '/Users/gizmo/_projects/_sg3/trunk/rake/target/exes/add2exif.exe'
|
12
|
+
puts "Working on #{file}"
|
13
|
+
system(exe, file, delta[0], delta[1], delta[2], delta[3])
|
14
|
+
end
|
15
|
+
end
|
data/bin/copy2lib
ADDED
data/imagelib.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'imagelib/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "imagelib"
|
8
|
+
spec.version = Imagelib::VERSION
|
9
|
+
spec.authors = ["Christian Köstlin"]
|
10
|
+
spec.email = ["christian.koestlin@esrlabs.com"]
|
11
|
+
spec.description = %q{gem to support my photo workflow}
|
12
|
+
spec.summary = %q{gem to support my photo workflow}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "progressbar"
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
HOME = ENV['HOME']
|
3
|
+
OUT_DIR = "#{HOME}/Pictures/ImageLib"
|
4
|
+
PATTERN = '**/*.{jpg,JPG,avi,AVI,wav,WAV,CR2}'
|
5
|
+
require 'FileUtils'
|
6
|
+
require 'rubygems'
|
7
|
+
gem 'progressbar'
|
8
|
+
require 'progressbar'
|
9
|
+
require 'yaml'
|
10
|
+
|
11
|
+
class Copy
|
12
|
+
attr_reader :filename, :prefix, :creation_date, :target_path
|
13
|
+
def initialize(filename, prefix)
|
14
|
+
@filename = filename
|
15
|
+
@prefix = prefix
|
16
|
+
@creation_date = File.mtime(filename)
|
17
|
+
@target_path = sprintf("%s/%d/%02d/%d-%02d-%02d",
|
18
|
+
OUT_DIR,
|
19
|
+
@creation_date.year,
|
20
|
+
@creation_date.month,
|
21
|
+
@creation_date.year,
|
22
|
+
@creation_date.month,
|
23
|
+
@creation_date.day)
|
24
|
+
@target_filename = "#{@target_path}/#{@prefix}#{File.basename(@filename)}"
|
25
|
+
@flag_filename = "#{@filename}.#{ENV['LOGNAME']}"
|
26
|
+
end
|
27
|
+
|
28
|
+
def prepare
|
29
|
+
FileUtils::mkdir_p(@target_path)
|
30
|
+
end
|
31
|
+
|
32
|
+
def copy
|
33
|
+
if (work_to_do?)
|
34
|
+
puts "#{@filename} -> #{@target_filename}"
|
35
|
+
FileUtils::cp(@filename, @target_filename, :preserve=>true )
|
36
|
+
File.open(@flag_filename, 'w') { |file| }
|
37
|
+
return @target_filename
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def work_to_do?
|
42
|
+
return !(File.exists?(@target_filename) or
|
43
|
+
File.exists?(@flag_filename))
|
44
|
+
end
|
45
|
+
|
46
|
+
def to_s
|
47
|
+
return "#{@filename} with #{prefix}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
def collect_images(configs)
|
53
|
+
images = []
|
54
|
+
configs.each do |config|
|
55
|
+
path = config['path'].strip
|
56
|
+
files = Dir.glob("#{path}/#{PATTERN}")
|
57
|
+
files.each do |file|
|
58
|
+
images << Copy.new(file, config['prefix'])
|
59
|
+
end
|
60
|
+
end
|
61
|
+
return images
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
def copy_images(images)
|
66
|
+
progress = ProgressBar.new("copy #{images.length} files", images.size)
|
67
|
+
copied_images = Array.new
|
68
|
+
images.each do | copy |
|
69
|
+
copy.prepare
|
70
|
+
res = copy.copy
|
71
|
+
if res
|
72
|
+
copied_images << res
|
73
|
+
end
|
74
|
+
progress.inc
|
75
|
+
end
|
76
|
+
progress.finish
|
77
|
+
return copied_images
|
78
|
+
end
|
79
|
+
|
80
|
+
def process_commandline(args)
|
81
|
+
configs = []
|
82
|
+
if (args.size == 0) then
|
83
|
+
configs = YAML::load_file("#{HOME}/.imagelib")
|
84
|
+
else
|
85
|
+
i = 0
|
86
|
+
while i < args.size
|
87
|
+
path = args[i]
|
88
|
+
prefix = args[i+1]
|
89
|
+
configs << {'path' => path, 'prefix' => prefix}
|
90
|
+
i = i + 2
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def report_result(copied_images)
|
96
|
+
puts "copied images: #{copied_images.size}"
|
97
|
+
copied_images.sort.each do | i |
|
98
|
+
puts "copied #{i}"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def copy_to_lib(args)
|
103
|
+
configs = process_commandline(args)
|
104
|
+
images = collect_images(configs)
|
105
|
+
images = images.sort{ |a,b| a.filename <=> b.filename }
|
106
|
+
images = images.select{ |copy| copy.work_to_do? }
|
107
|
+
copied_images = copy_images(images)
|
108
|
+
report_result(copied_images)
|
109
|
+
end
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: imagelib
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Christian Köstlin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: progressbar
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
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
|
+
description: gem to support my photo workflow
|
56
|
+
email:
|
57
|
+
- christian.koestlin@esrlabs.com
|
58
|
+
executables:
|
59
|
+
- add2exif
|
60
|
+
- copy2lib
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- ".gitignore"
|
65
|
+
- ".ruby-gemset"
|
66
|
+
- ".ruby-version"
|
67
|
+
- Gemfile
|
68
|
+
- LICENSE.txt
|
69
|
+
- README.md
|
70
|
+
- Rakefile
|
71
|
+
- bin/add2exif
|
72
|
+
- bin/copy2lib
|
73
|
+
- imagelib.gemspec
|
74
|
+
- lib/imagelib/copy2lib.rb
|
75
|
+
- lib/imagelib/version.rb
|
76
|
+
homepage: ''
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
metadata: {}
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 2.2.2
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: gem to support my photo workflow
|
100
|
+
test_files: []
|