multistockphoto 0.1.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +14 -0
- data/Manifest.txt +1 -0
- data/bin/multistockphoto +181 -16
- data/config/hoe.rb +9 -8
- data/config.yaml +3 -0
- data/lib/multistockphoto/photo.rb +54 -1
- data/lib/multistockphoto/site_photocase.rb +94 -0
- data/lib/multistockphoto/site_zoonar.rb +7 -0
- data/lib/multistockphoto/version.rb +2 -2
- data/lib/multistockphoto.rb +2 -0
- data/test/test_multistockphoto.rb +90 -15
- data/website/index.html +92 -5
- data/website/index.txt +77 -3
- metadata +3 -2
data/History.txt
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
== 0.3.0 2008-05-10
|
2
|
+
* 5 major enhancements:
|
3
|
+
* Site in Lauf deaktivieren, wenn zu viele Fehler
|
4
|
+
* Schalter '--total-per-site=N'
|
5
|
+
* Schalter '--total-transfers=N' - Nur N Uploads insgsamte pro Session
|
6
|
+
* Schalter '--check-orientation'
|
7
|
+
* Schalter '--rotate'
|
8
|
+
* 1 bug fix
|
9
|
+
* kurze Optionsschalter nur noch 1 Zeichen lang und anders benannt
|
10
|
+
|
11
|
+
== 0.2.0 2008-05-08
|
12
|
+
* 1 major enhancement:
|
13
|
+
* new site www.photocase.de
|
14
|
+
|
1
15
|
== 0.1.1 2008-05-07
|
2
16
|
|
3
17
|
* 1 bug fix:
|
data/Manifest.txt
CHANGED
@@ -14,6 +14,7 @@ lib/multistockphoto/version.rb
|
|
14
14
|
lib/multistockphoto/generic_site.rb
|
15
15
|
lib/multistockphoto/site_fotolia.rb
|
16
16
|
lib/multistockphoto/site_zoonar.rb
|
17
|
+
lib/multistockphoto/site_photocase.rb
|
17
18
|
lib/multistockphoto/site_aldi.rb
|
18
19
|
lib/multistockphoto/photo.rb
|
19
20
|
script/console
|
data/bin/multistockphoto
CHANGED
@@ -3,6 +3,20 @@
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'choice'
|
5
5
|
require 'multistockphoto'
|
6
|
+
require 'RMagick'
|
7
|
+
include Magick
|
8
|
+
require 'exifr'
|
9
|
+
|
10
|
+
def all_sites_done(sites,n)
|
11
|
+
p sites
|
12
|
+
result = true
|
13
|
+
sites.each {|entry|
|
14
|
+
if entry[1] < n
|
15
|
+
result = false
|
16
|
+
end
|
17
|
+
}
|
18
|
+
result
|
19
|
+
end
|
6
20
|
|
7
21
|
version = Multistockphoto::VERSION::STRING
|
8
22
|
Choice.options do
|
@@ -13,7 +27,7 @@ Choice.options do
|
|
13
27
|
separator 'Common options: '
|
14
28
|
|
15
29
|
option :help do
|
16
|
-
short '-h'
|
30
|
+
#short '-h'
|
17
31
|
long '--help'
|
18
32
|
desc 'Show this message'
|
19
33
|
end
|
@@ -29,41 +43,192 @@ Choice.options do
|
|
29
43
|
end
|
30
44
|
|
31
45
|
option :send_all do
|
32
|
-
short '-
|
46
|
+
short '-a'
|
33
47
|
long '--send-all'
|
34
48
|
desc 'Send all files'
|
35
49
|
action do
|
36
50
|
$send_all=true
|
37
|
-
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
option :total_transfers do
|
55
|
+
short '-t'
|
56
|
+
long '--total-transfers'
|
57
|
+
desc 'dont\'t send more than N photos in total'
|
58
|
+
cast Integer
|
59
|
+
default 999
|
60
|
+
action do
|
61
|
+
$send_all = true
|
62
|
+
$total_transfers = true
|
63
|
+
#Choice.choices[:total_transfers] #.to_i
|
64
|
+
p $total_transfers
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
option :total_per_site do
|
69
|
+
short '-s'
|
70
|
+
long '--total-per-site'
|
71
|
+
desc 'send no more than N photos per site'
|
72
|
+
cast Integer
|
73
|
+
default 999
|
74
|
+
action do
|
75
|
+
#$send_all = true
|
76
|
+
$total_per_site = true
|
77
|
+
#Choice.choices[:total_transfers] #.to_i
|
78
|
+
p $total_per_site
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
option :check_orientation do
|
83
|
+
short '-o'
|
84
|
+
long '--check-orientation'
|
85
|
+
desc 'displays the orientiation of photo files'
|
86
|
+
action do
|
87
|
+
$check_orientation_loop = true
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
option :rotate do
|
92
|
+
short '-r'
|
93
|
+
long '--rotate'
|
94
|
+
desc 'rotate a photo file 90 degrees to the left'
|
95
|
+
action do
|
96
|
+
$rotate_photos = true
|
38
97
|
end
|
39
98
|
end
|
40
99
|
end
|
41
100
|
|
42
101
|
def send_all
|
102
|
+
total_transfers = 0
|
103
|
+
total = {}
|
104
|
+
errors = {}
|
105
|
+
sites = [:fotolia, :zoonar, :photocase]
|
106
|
+
sites.each {|site|
|
107
|
+
total[site] = 0
|
108
|
+
errors[site] = 0
|
109
|
+
}
|
110
|
+
p total
|
43
111
|
puts 'sending all unsent photos'
|
44
112
|
Dir.glob('upload/*').each {|filename|
|
113
|
+
next if File.basename(filename)[0,4] == 'rot_'
|
114
|
+
#puts "rot_ uebersprungen"
|
45
115
|
if filename.upcase =~ /.PNG|.JPG|.GIF|.JPEG/
|
46
116
|
#puts filename
|
117
|
+
total_per_site_flag = $total_per_site
|
118
|
+
#p total_per_site_flag
|
47
119
|
# Fotolia
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
120
|
+
if errors[:fotolia] < 3
|
121
|
+
if $send_all or (total_per_site_flag and total[:fotolia] < Choice.choices[:total_per_site])
|
122
|
+
site = Fotolia.new("Fotolia")
|
123
|
+
photo = Photo.new(filename)
|
124
|
+
begin
|
125
|
+
result = site.transfer(photo)
|
126
|
+
if result != :duplicate
|
127
|
+
total_transfers += 1
|
128
|
+
total[:fotolia] += 1
|
129
|
+
end
|
130
|
+
if result != :duplicate
|
131
|
+
errors[:fotolia] = 0
|
132
|
+
end
|
133
|
+
break if result != :duplicate && total_transfers >= Choice.choices[:total_transfers]
|
134
|
+
break if all_sites_done(total,Choice.choices[:total_per_site])
|
135
|
+
rescue Net::FTPTempError
|
136
|
+
errors[:fotolia] += 1
|
137
|
+
if errors[:fotolia] >= 3
|
138
|
+
puts "too many errors. giving up."
|
139
|
+
end
|
140
|
+
puts "FTP-Fehler beim Senden an Fotolia aufgetreten. Ggf. Konfiguration ueberpruefen oder spaeter erneut vesuchen"
|
141
|
+
end
|
142
|
+
end
|
54
143
|
end
|
144
|
+
|
55
145
|
# Zoonar
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
146
|
+
if errors[:zoonar] < 3
|
147
|
+
if $send_all or (total_per_site_flag and total[:zoonar] < Choice.choices[:total_per_site])
|
148
|
+
site = Zoonar.new("Zoonar")
|
149
|
+
photo = Photo.new(filename)
|
150
|
+
begin
|
151
|
+
result = site.transfer(photo)
|
152
|
+
if result != :duplicate
|
153
|
+
total_transfers += 1
|
154
|
+
total[:zoonar] += 1
|
155
|
+
end
|
156
|
+
if result != :duplicate
|
157
|
+
errors[:zoonar] = 0
|
158
|
+
end
|
159
|
+
break if result != :duplicate && total_transfers >= Choice.choices[:total_transfers]
|
160
|
+
break if all_sites_done(total,Choice.choices[:total_per_site])
|
161
|
+
rescue
|
162
|
+
errors[:zoonar] += 1
|
163
|
+
if errors[:zoonar] >= 3
|
164
|
+
puts "too many errors. giving up."
|
165
|
+
end
|
166
|
+
puts "Fehler beim Senden an Zoonar aufgetreten"
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
# Photocase
|
172
|
+
if errors[:photocase] < 3
|
173
|
+
if $send_all or (total_per_site_flag and total[:photocase] < Choice.choices[:total_per_site])
|
174
|
+
site = Photocase.new("Photocase")
|
175
|
+
photo = Photo.new(filename)
|
176
|
+
begin
|
177
|
+
result = site.transfer(photo)
|
178
|
+
|
179
|
+
if result != :duplicate
|
180
|
+
total_transfers += 1
|
181
|
+
total[:photocase] += 1
|
182
|
+
end
|
183
|
+
if result != :duplicate
|
184
|
+
errors[:photocase] = 0
|
185
|
+
end
|
186
|
+
|
187
|
+
break if result != :duplicate && total_transfers >= Choice.choices[:total_transfers]
|
188
|
+
break if all_sites_done(total, Choice.choices[:total_per_site])
|
189
|
+
rescue
|
190
|
+
errors[:photocase] += 1
|
191
|
+
if errors[:photocase] >= 3
|
192
|
+
puts "too many errors. giving up."
|
193
|
+
end
|
194
|
+
puts "Fehler beim Senden an Photocase aufgetreten"
|
195
|
+
end
|
196
|
+
end
|
62
197
|
end
|
63
198
|
end
|
64
199
|
}
|
200
|
+
puts "#{total_transfers} photos sent."
|
65
201
|
end
|
66
202
|
|
67
|
-
|
203
|
+
def check_orientation_loop
|
204
|
+
ARGV.each {|fn|
|
205
|
+
if fn[0,1] != '-'
|
206
|
+
pic = ImageList.new(fn)
|
207
|
+
puts "#{fn}:\t#{pic.orientation}"
|
208
|
+
end
|
209
|
+
}
|
210
|
+
end
|
211
|
+
|
212
|
+
def rotate_photos
|
213
|
+
ARGV.each {|fn|
|
214
|
+
if fn[0,1] != '-'
|
215
|
+
pic = ImageList.new(fn)
|
216
|
+
pic.rotate!(-90)
|
217
|
+
#pic.display
|
218
|
+
puts "writing to #{fn}"
|
219
|
+
pic.write(fn)
|
220
|
+
end
|
221
|
+
}
|
222
|
+
end
|
223
|
+
|
224
|
+
if $send_all or $total_per_site
|
68
225
|
send_all
|
69
226
|
end
|
227
|
+
|
228
|
+
if $check_orientation_loop
|
229
|
+
check_orientation_loop
|
230
|
+
end
|
231
|
+
|
232
|
+
if $rotate_photos
|
233
|
+
rotate_photos
|
234
|
+
end
|
data/config/hoe.rb
CHANGED
@@ -8,11 +8,12 @@ RUBYFORGE_PROJECT = 'multistockphoto' # The unix name for your project
|
|
8
8
|
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
9
9
|
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
10
10
|
EXTRA_DEPENDENCIES = [
|
11
|
-
# ['activesupport', '>= 1.3.1']
|
11
|
+
# ['activesupport', '>= 1.3.1']
|
12
12
|
['mechanize', '>= 0.7.5'], # mein aktuelles release
|
13
13
|
['choice', '>= 0.1.2'], # mein aktuelles release
|
14
14
|
['grep', '>= 0.0.1'], # mein aktuelles release
|
15
|
-
|
15
|
+
['exifr', '>= 0.10.6'], # mein aktuelles release
|
16
|
+
['rmagick', '>= 0.0.1'],
|
16
17
|
] # An array of rubygem dependencies [name, version]
|
17
18
|
|
18
19
|
@config_file = "~/.rubyforge/user-config.yml"
|
@@ -40,10 +41,10 @@ REV = nil
|
|
40
41
|
# REV = YAML.load(`svn info`)['Revision']
|
41
42
|
VERS = Multistockphoto::VERSION::STRING + (REV ? ".#{REV}" : "")
|
42
43
|
RDOC_OPTS = ['--quiet', '--title', 'multistockphoto documentation',
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
"--opname", "index.html",
|
45
|
+
"--line-numbers",
|
46
|
+
"--main", "README",
|
47
|
+
"--inline-source"]
|
47
48
|
|
48
49
|
class Hoe
|
49
50
|
def extra_deps
|
@@ -67,8 +68,8 @@ $hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
|
67
68
|
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
68
69
|
#p.extra_deps = EXTRA_DEPENDENCIES
|
69
70
|
|
70
|
-
|
71
|
-
|
71
|
+
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
72
|
+
end
|
72
73
|
|
73
74
|
CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
|
74
75
|
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
data/config.yaml
CHANGED
@@ -1,7 +1,60 @@
|
|
1
|
+
require 'RMagick'
|
2
|
+
include Magick
|
3
|
+
require 'exifr'
|
4
|
+
|
1
5
|
class Photo
|
2
6
|
attr_reader :filename
|
3
7
|
|
4
8
|
def initialize(filename)
|
5
9
|
@filename = filename
|
6
10
|
end
|
7
|
-
|
11
|
+
|
12
|
+
# ist Bild im Hochformat
|
13
|
+
# TODO: ziemlich dummer Test, verbessern!
|
14
|
+
def hochformat
|
15
|
+
pic = ImageList.new(@filename)
|
16
|
+
if pic.orientation == LeftBottomOrientation
|
17
|
+
return true
|
18
|
+
else
|
19
|
+
return false
|
20
|
+
end
|
21
|
+
|
22
|
+
if false
|
23
|
+
require 'rubygems'
|
24
|
+
|
25
|
+
require 'RMagick'
|
26
|
+
include Magick
|
27
|
+
|
28
|
+
pic = ImageList.new("/home/tp/multistockphoto/upload/IMG_3453.JPG")
|
29
|
+
pic2 = ImageList.new("/home/tp/multistockphoto/upload/IMG_3464.JPG")
|
30
|
+
puts pic.orientation
|
31
|
+
puts pic2.orientation
|
32
|
+
#pic2 = pic.auto_orient
|
33
|
+
#pic.display
|
34
|
+
#pic2.display
|
35
|
+
if pic.orientation == LeftBottomOrientation
|
36
|
+
pic.auto_orient!
|
37
|
+
pic.write("/tmp/rLALA1234.JPG")
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
# width = EXIFR::JPEG.new(@filename).width
|
42
|
+
# height = EXIFR::JPEG.new(@filename).height
|
43
|
+
# #return (width < height)
|
44
|
+
# false
|
45
|
+
end
|
46
|
+
|
47
|
+
def drehen
|
48
|
+
pic = ImageList.new(@filename)
|
49
|
+
if pic.orientation == LeftBottomOrientation
|
50
|
+
b = File.basename(@filename)
|
51
|
+
tmpname = @filename.sub(b,'') +'rot_' + b
|
52
|
+
if not File.exist? tmpname
|
53
|
+
pic.auto_orient!
|
54
|
+
puts "rotating picture, writing to #{tmpname}"
|
55
|
+
pic.write(tmpname)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'mechanize'
|
3
|
+
require 'grep'
|
4
|
+
include Grep
|
5
|
+
|
6
|
+
class Photocase < GenericSite
|
7
|
+
|
8
|
+
attr_accessor :user, :password
|
9
|
+
|
10
|
+
def initialize(name)
|
11
|
+
super
|
12
|
+
if ENV['MSP_CONFIG']
|
13
|
+
@config = YAML.load_file(ENV['MSP_CONFIG'])
|
14
|
+
else
|
15
|
+
@config = YAML.load_file("config.yaml")
|
16
|
+
end
|
17
|
+
@user = @config[:photocase][:user]
|
18
|
+
@password = @config[:photocase][:password]
|
19
|
+
end
|
20
|
+
|
21
|
+
def transfer(photo)
|
22
|
+
sav_photo_filename = photo.filename.dup
|
23
|
+
# falls nicht in config Datei eingetragen dann nicht senden
|
24
|
+
if @user == nil or @password == nil
|
25
|
+
return
|
26
|
+
end
|
27
|
+
|
28
|
+
unless photo.class == Photo
|
29
|
+
raise 'not a Photo object'
|
30
|
+
end
|
31
|
+
unless File.exist?(photo.filename)
|
32
|
+
raise "file #{photo.filename} does not exist"
|
33
|
+
end
|
34
|
+
print "photocase:#{photo.filename} ... "
|
35
|
+
$stdout.flush
|
36
|
+
g = grep("sendeliste.dat", /photocase\t#{photo.filename}/)
|
37
|
+
if g.size > 0
|
38
|
+
puts 'already sent'
|
39
|
+
return :duplicate
|
40
|
+
end
|
41
|
+
if photo.hochformat
|
42
|
+
photo.drehen
|
43
|
+
end
|
44
|
+
agent = WWW::Mechanize.new
|
45
|
+
agent.user_agent_alias = 'Linux Mozilla'
|
46
|
+
page = agent.get 'http://www.photocase.de/en/login.asp'
|
47
|
+
if !page.body.include?('Log in')
|
48
|
+
raise 'not at the login page'
|
49
|
+
end
|
50
|
+
form = page.forms.first #TODO: besser nach Name
|
51
|
+
# form['loginForm[Username]'] = @config[:zoonar][:user]
|
52
|
+
# form['loginForm[Password]'] = @config[:zoonar][:password]
|
53
|
+
form['UserName'] = @config[:photocase][:user]
|
54
|
+
form['UserPassword'] = @config[:photocase][:password]
|
55
|
+
#UserName
|
56
|
+
#UserPassword
|
57
|
+
page = agent.submit form
|
58
|
+
raise "login error" if ! page.body.include?("Login successful")
|
59
|
+
page = agent.click page.links.text('Upload')
|
60
|
+
raise "no Upload a photo" if ! page.body.include?('Upload a photo')
|
61
|
+
form = page.form('Form')
|
62
|
+
if photo.hochformat
|
63
|
+
|
64
|
+
b = File.basename(photo.filename)
|
65
|
+
newfilename = photo.filename.sub(b,'')+'rot_'+b
|
66
|
+
# form.file_uploads.first.file_name = 'r' + photo.filename
|
67
|
+
form.file_uploads.first.file_name = newfilename
|
68
|
+
else
|
69
|
+
form.file_uploads.first.file_name = photo.filename
|
70
|
+
end
|
71
|
+
#TODO:
|
72
|
+
# 2 Checkboxen
|
73
|
+
#UploadDisclaimerAccepted
|
74
|
+
#HasCopyright
|
75
|
+
form.checkboxes.name('UploadDisclaimerAccepted').check
|
76
|
+
form.checkboxes.name('HasCopyright').check
|
77
|
+
page = agent.submit form
|
78
|
+
if !page.body.include?('Your photo was uploaded successfully.')
|
79
|
+
raise "not successfully uploaded"
|
80
|
+
end
|
81
|
+
if page.body.include?('Your photo was uploaded successfully.')
|
82
|
+
puts "OK"
|
83
|
+
end
|
84
|
+
#'Your photo was uploaded successfully.'
|
85
|
+
if sav_photo_filename != photo.filename
|
86
|
+
raise "photo.filenames has been changed!"
|
87
|
+
end
|
88
|
+
|
89
|
+
File.open('sendeliste.dat','a') {|f|
|
90
|
+
f.puts "photocase\t#{photo.filename}\t#{Time.now}"
|
91
|
+
}
|
92
|
+
true
|
93
|
+
end
|
94
|
+
end
|
@@ -5,6 +5,8 @@ include Grep
|
|
5
5
|
|
6
6
|
class Zoonar < GenericSite
|
7
7
|
|
8
|
+
@@errors = 0
|
9
|
+
|
8
10
|
attr_accessor :user, :password
|
9
11
|
|
10
12
|
def initialize(name)
|
@@ -58,9 +60,14 @@ class Zoonar < GenericSite
|
|
58
60
|
if page.body.include?("Das Bild ist zu klein.")
|
59
61
|
raise "Bild zu klein. Muss mind. 6 MP sein"
|
60
62
|
else
|
63
|
+
@@errors += 1
|
64
|
+
if @@errors > 3
|
65
|
+
raise "too many errors"
|
66
|
+
end
|
61
67
|
raise "Fehler beim Upload"
|
62
68
|
end
|
63
69
|
end
|
70
|
+
@@errors = 0
|
64
71
|
"Es ist ein Fehler aufgetreten!
|
65
72
|
|
66
73
|
Bei der Übertragung des Bildes ist ein Fehler aufgetreten.
|
data/lib/multistockphoto.rb
CHANGED
@@ -6,6 +6,8 @@ include Grep
|
|
6
6
|
class TestMultistockphoto < Test::Unit::TestCase
|
7
7
|
|
8
8
|
REAL_TRANSFER = false
|
9
|
+
BIN = 'bin/' # Test
|
10
|
+
# BIN = '' # real
|
9
11
|
|
10
12
|
def setup
|
11
13
|
@fotolia_user = ENV['FOTOLIA_USER']
|
@@ -16,11 +18,35 @@ class TestMultistockphoto < Test::Unit::TestCase
|
|
16
18
|
@zoonar_password = ENV['ZOONAR_PASSWORD']
|
17
19
|
@aldi_user = ENV['ALDI_USER']
|
18
20
|
@aldi_password = ENV['ALDI_PASSWORD']
|
21
|
+
@photocase_user = ENV['PHOTOCASE_USER']
|
22
|
+
@photocase_password = ENV['PHOTOCASE_PASSWORD']
|
19
23
|
end
|
20
24
|
|
25
|
+
def test_bin_help
|
26
|
+
expected = "Usage: multistockphoto [-vatsor]
|
21
27
|
|
22
|
-
|
23
|
-
|
28
|
+
Specific options:
|
29
|
+
|
30
|
+
Common options:
|
31
|
+
--help Show this message
|
32
|
+
-v, --version Show version
|
33
|
+
-a, --send-all Send all files
|
34
|
+
-t, --total-transfers dont't send more than N photos in total
|
35
|
+
-s, --total-per-site send no more than N photos per site
|
36
|
+
-o, --check-orientation displays the orientiation of photo files
|
37
|
+
-r, --rotate rotate a photo file 90 degrees to the left\n"
|
38
|
+
result = `#{BIN}multistockphoto -h`
|
39
|
+
assert_equal expected, result
|
40
|
+
result = `#{BIN}multistockphoto --help`
|
41
|
+
assert_equal expected, result
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_bin_version
|
45
|
+
expected = "multistockphoto 0.2.0\n"
|
46
|
+
result = `#{BIN}multistockphoto -v`
|
47
|
+
assert_equal expected, result
|
48
|
+
result = `#{BIN}multistockphoto --version`
|
49
|
+
assert_equal expected, result
|
24
50
|
end
|
25
51
|
|
26
52
|
def test_transfer_all
|
@@ -153,28 +179,41 @@ sending foto3.jpg ... OK
|
|
153
179
|
#kein ftp assert_equal @zoonar_ftp_user, zoonar.ftp_user
|
154
180
|
#kein ftp assert_equal @zoonar_ftp_password, zoonar.ftp_password
|
155
181
|
end
|
182
|
+
|
183
|
+
def test_config_params_photocase
|
184
|
+
photocase = Photocase.new("photocase Site")
|
185
|
+
assert photocase.user
|
186
|
+
assert photocase.password
|
187
|
+
assert_equal @photocase_user, photocase.user
|
188
|
+
assert_equal @photocase_password, photocase.password
|
189
|
+
#kein ftp assert_equal @photocase_ftp_user, photocase.ftp_user
|
190
|
+
#kein ftp assert_equal @photocase_ftp_password, photocase.ftp_password
|
191
|
+
end
|
156
192
|
|
157
193
|
def test_aldi
|
158
|
-
|
194
|
+
after Date.new(2008,5,15) do
|
195
|
+
site = Aldi.new("ALDI")
|
159
196
|
|
160
|
-
|
161
|
-
|
197
|
+
assert_kind_of Aldi, site
|
198
|
+
assert_equal "ALDI", site.name
|
162
199
|
|
163
|
-
|
164
|
-
|
200
|
+
site.user = @aldi_user
|
201
|
+
site.password = @aldi_password
|
165
202
|
|
166
|
-
|
167
|
-
|
203
|
+
assert site.user
|
204
|
+
assert site.password
|
168
205
|
|
169
|
-
|
170
|
-
|
206
|
+
assert_equal @aldi_user, site.user
|
207
|
+
assert_equal @aldi_password, site.password
|
208
|
+
end
|
171
209
|
end
|
172
210
|
|
173
211
|
def test_aldi_transfer
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
212
|
+
after Date.new(2008,5,15) do
|
213
|
+
site = Aldi.new("ALDI")
|
214
|
+
photo = Photo.new("/media/LACIE/private/CF-Card/DCIM/119CANON/IMG_3267_zugeschnitten_blank_names.jpg")
|
215
|
+
site.transfer(photo)
|
216
|
+
end
|
178
217
|
end
|
179
218
|
|
180
219
|
def test_grep
|
@@ -194,4 +233,40 @@ sending foto3.jpg ... OK
|
|
194
233
|
assert_equal 0, grep(file,/fotolia\tIMG3.jpg/).size
|
195
234
|
end
|
196
235
|
|
236
|
+
def test_photocase_transfer_1
|
237
|
+
after Date.new(2008,5,30) do
|
238
|
+
photocase = Photocase.new("Photocase")
|
239
|
+
photocase.user = @photocase_user
|
240
|
+
photocase.password = @photocase_password
|
241
|
+
photo = Photo.new("test/1234.jpg")
|
242
|
+
photocase.transfer(photo)
|
243
|
+
if REAL_TRANSFER
|
244
|
+
#assert fotolia.transfer(photo)
|
245
|
+
#TODO: zwei Gruende, warum das fehlschlagen kann:
|
246
|
+
# 1. Datei nicht vorhanden
|
247
|
+
# 2. Argument kein Photo-Objekt
|
248
|
+
# => bessere Tests
|
249
|
+
# assert_raise (RuntimeError) {
|
250
|
+
# fotolia.transfer("123.jpg")
|
251
|
+
# }
|
252
|
+
end
|
253
|
+
end # after
|
254
|
+
end
|
255
|
+
|
256
|
+
def test_config_params_pixelio
|
257
|
+
after Date.new(2008,5,15) do
|
258
|
+
pixelio = Pixelio.new("Pixelio Site")
|
259
|
+
assert pixelio.user
|
260
|
+
assert pixelio.password
|
261
|
+
assert_equal @pixelio_user, pixelio.user
|
262
|
+
assert_equal @pixelio_password, pixelio.password
|
263
|
+
#kein ftp assert_equal @pixelio_ftp_user, pixelio.ftp_user
|
264
|
+
#kein ftp assert_equal @pixelio_ftp_password, pixelio.ftp_password
|
265
|
+
end # after
|
266
|
+
end
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
#Shutterstock, iStockphoto , StockXpert , Dreamstime , Bigstockphoto , 123rf und Panthermedia finden Sie auf unserer Partnerseite Fotos kaufen.de
|
271
|
+
|
197
272
|
end
|
data/website/index.html
CHANGED
@@ -33,7 +33,7 @@
|
|
33
33
|
<h1>multistockphoto</h1>
|
34
34
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/multistockphoto"; return false'>
|
35
35
|
<p>Get Version</p>
|
36
|
-
<a href="http://rubyforge.org/projects/multistockphoto" class="numbers">0.
|
36
|
+
<a href="http://rubyforge.org/projects/multistockphoto" class="numbers">0.3.0</a>
|
37
37
|
</div>
|
38
38
|
<h1>→ ‘multistockphoto’</h1>
|
39
39
|
|
@@ -112,6 +112,28 @@ einmal gesendet.</p>
|
|
112
112
|
oder Kleinschreibung ist egal.</p>
|
113
113
|
|
114
114
|
|
115
|
+
<p>Das Programm kann Photos, die im Hochformat aufgenommen wurden, automatisch
|
116
|
+
drehen, falls die Kamera dies erkennen kann und in den Photo-Dateien speichert.
|
117
|
+
In diesem Fall wird das Photo zuerst gedreht und dann auf die entsprechende Site
|
118
|
+
hochgeladen. Hierbei werden Dateien in diesem Directory erzeugt, die mit ‘rot_’
|
119
|
+
(für rotiert, wer hätte es gedacht?) beginnen.</p>
|
120
|
+
|
121
|
+
|
122
|
+
<p>Da es theoretisch auch möglich wäre, daß die entsprechende Photo-Site das Drehen
|
123
|
+
von sich aus beherrscht, ist vorgesehen, in zukünfigen Programm-Versionen das
|
124
|
+
Drehen vorab bei Bedarf zu deaktivieren.</p>
|
125
|
+
|
126
|
+
|
127
|
+
<p>Achtung: Beim normalen Hochladen werden diese Dateien nicht berücksichtigt,
|
128
|
+
du solltest also möglichst keine echten Photo hochladen wollen, die mit ‘rot_’
|
129
|
+
beginnen. In der Praxis dürfte dies kein großes Problem sein. Falls der Dateiname
|
130
|
+
doch mit ‘rot_’ (die Farbe) beginnen sollte, benenne sie einfach in ‘Rot_…’ um,
|
131
|
+
dann wird diese Datei auch hochgeladen. Die rotierten
|
132
|
+
Dateien dürfen gefahrlos gelöscht werden, ist aber im normalen Betrieb für die
|
133
|
+
Funktionsweise dieses Programm nicht notwendig, da die gedrehten Dateien bei
|
134
|
+
Bedarf einfach neu angelegt werden.</p>
|
135
|
+
|
136
|
+
|
115
137
|
<p>Das Programm erstellt (im Directory multistockphoto) eine Datei namens
|
116
138
|
‘sendeliste.dat’, in der die erfolgreichen Uploads mit Site, Dateiname und
|
117
139
|
Datum/Uhrzeit protokolliert werden. Diese Datei darf nicht gelöscht werden,
|
@@ -130,11 +152,26 @@ Daten zu den einzelnen Bildern eintragen.</p>
|
|
130
152
|
<p>Einzelne Sites handhaben dies unterschiedlich.</p>
|
131
153
|
|
132
154
|
|
155
|
+
<p>Diese Nachbearbeitung auf der jeweiligen Seite ist derzeit noch nötig, es ist aber
|
156
|
+
geplant, daß auch z.B. die Schlagworte von diesem Programm schon gesetzt werden
|
157
|
+
können.</p>
|
158
|
+
|
159
|
+
|
160
|
+
<p>Desweiteren können Kriterien, z. B. Mindestauflösunge eines Bildes in Zukunft
|
161
|
+
schon vor des Hochladen überprüft werden. Dies ist jedoch noch nicht implementiert.</p>
|
162
|
+
|
163
|
+
|
164
|
+
<h3>fotolia.de</h3>
|
165
|
+
|
166
|
+
|
133
167
|
<p>Beispiel: Bei fotolia.de mußt du deine Photos hochladen, dann noch Stichworte
|
134
168
|
und verschiedene Vertragsbedingungen festlegen. Dann erst werden deine Bilder
|
135
169
|
geprüft und entweder angenommen oder abgelehnt.</p>
|
136
170
|
|
137
171
|
|
172
|
+
<h3>zoonar.de</h3>
|
173
|
+
|
174
|
+
|
138
175
|
<p>Bei zoonar.de wiederum läuft es so, daß du erst nur die Bilder hochlädst, dann
|
139
176
|
werden sie begutachtet; angenommen oder abgelehnt und erst wenn sie
|
140
177
|
angenommen wurden, kannst du Schlagworte vergeben. Dies hat natürlich den
|
@@ -142,9 +179,18 @@ Vorteil, daß man für abgelehnte Photos erst gar keine Schlagworte vergeben mu
|
|
142
179
|
(kann).</p>
|
143
180
|
|
144
181
|
|
145
|
-
<
|
146
|
-
|
147
|
-
|
182
|
+
<h3>photocase.de</h3>
|
183
|
+
|
184
|
+
|
185
|
+
<p>Bei photocase.de lädst du ebenfalls zuerst deinen Photos hoch, diese werden
|
186
|
+
dann entweder angenommen oder abgelehnt. Bei angenommenen Bilder bearbeitest
|
187
|
+
du diese auf deren Seite weiter (eigentlich wie bei zoonar.de). Als nettes
|
188
|
+
Gimmick bei photocase kannst du bei deinen Photos sehen, an welchem Platz
|
189
|
+
sie sich aktuell in der Warteschlage der zu begutachtenden Photos befinden.</p>
|
190
|
+
|
191
|
+
|
192
|
+
<p><i>Click on the Browse button to search your computer for the photo you’d like to upload. We accept <span class="caps">JPG</span> and <span class="caps">TIFF</span> files. Please pay close attention to the minimum resolution requirement of 1600×1200 pixels, the image quality (e.g. not overly compressed) and the content of the image itself (e.g. it does not contain any material that you don’t hold the copyright to).
|
193
|
+
</i></p>
|
148
194
|
|
149
195
|
|
150
196
|
<h2>Demonstration of usage</h2>
|
@@ -191,6 +237,47 @@ Starte dann einfach das Programm am nächsten Tag noch einmal, um den Rest der
|
|
191
237
|
Photos hochzuladen!</p>
|
192
238
|
|
193
239
|
|
240
|
+
<h3>Hoch- und Querformat</h3>
|
241
|
+
|
242
|
+
|
243
|
+
<p>Einige Digitalkameras können erkennen, ob ein Bild im Hoch- oder Querformat
|
244
|
+
aufgenommmen wurde.
|
245
|
+
Falls dieses Programm erkennt, daß die Kamera ins Hochformat gedreht wurde,
|
246
|
+
so wird automatisch ein um 90 Grad nach links gedrehtes Bild erzeugt und dieses
|
247
|
+
hochgeladen. Da die Photosites dies theoretisch auch anhand der Exif-Daten in
|
248
|
+
der Bilddatei erkennen und das Bild automatisch drehen könnten, wird es in Zukunft
|
249
|
+
auch einen Schalter geben, um die automatische Drehung im Programm auszuschalten,
|
250
|
+
da dies dann nicht notwendig ist.</p>
|
251
|
+
|
252
|
+
|
253
|
+
<p>Die Photo-Sites, mit denen ich bis jetzt zu tun hatte, ignorieren dies aber
|
254
|
+
anscheinend bis jetzt.</p>
|
255
|
+
|
256
|
+
|
257
|
+
<p>Um dieses Verhalten in der Digitalkamera einzuschalten, mußte ich bei der Canon
|
258
|
+
<span class="caps">EOS 400 D</span> die Einstellung ‘automatisch rotieren’ aktivieren. Bei anderen Kameras
|
259
|
+
mag dies ähnlich sein. Bei der <span class="caps">EOS 400 D</span> kann man wählen, ob automatisch
|
260
|
+
für nur im Display der Kamera, im Display und auf dem PC oder überhaupt nicht
|
261
|
+
gedreht werden soll. Relevant ist hier die Einstellung ‘auf dem PC drehen’. Wenn
|
262
|
+
man zusätzlich noch ‘auf dem Display drehen’ anwählt, heißt dies, daß zusätzlich
|
263
|
+
auch auf dem Display der Kamera das Bild gedreht angezeigt werden soll.</p>
|
264
|
+
|
265
|
+
|
266
|
+
<p>Um zu testen, in welcher ‘orientation’ ein Bild vorliegt kannst du das Programm
|
267
|
+
mit dem Schalter ‘—check-orientation Bild1.jpg Bild2.jpg ..’ aufrufen.</p>
|
268
|
+
|
269
|
+
|
270
|
+
<p>Falls ein Bild mit der falsche Orientation vorliegt, kannst du das Bild mit
|
271
|
+
dem Schalter ‘—rotate bild1.jpg [bild2.jpg ..]’ um 90 Grad nach links drehen.
|
272
|
+
Achtung: dabei wird die Originaldatei mit dem gedrehten Bild überschrieben – falls
|
273
|
+
du das nicht willst, lege vorher eine Kopie an!</p>
|
274
|
+
|
275
|
+
|
276
|
+
<p>Wenn deine Kamera nicht erkennen kann, ob ein Photo im Hochformat aufgenommen
|
277
|
+
wurde, dann drehe das Bild vor dem Hochladen mit dem Schalter ‘—rotate’ oder
|
278
|
+
einen anderen Programm, welches Bilde drehen kann!</p>
|
279
|
+
|
280
|
+
|
194
281
|
<h2>Forum</h2>
|
195
282
|
|
196
283
|
|
@@ -258,7 +345,7 @@ rake install_gem</pre>
|
|
258
345
|
<p>Comments are welcome. Send an email to <a href="mailto:thopre@gmail.com">Thomas Preymesser</a> email
|
259
346
|
or via the <a href="http://groups.google.com/group/multistockphoto">forum</a></p>
|
260
347
|
<p class="coda">
|
261
|
-
<a href="FIXME email">FIXME full name</a>,
|
348
|
+
<a href="FIXME email">FIXME full name</a>, 10th May 2008<br>
|
262
349
|
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
263
350
|
</p>
|
264
351
|
</div>
|
data/website/index.txt
CHANGED
@@ -64,6 +64,26 @@ einmal gesendet.
|
|
64
64
|
Alle Dateien mit den Endungen .PNG, .JPG, .GIF, .JPEG werden hochgeladen. Groß-
|
65
65
|
oder Kleinschreibung ist egal.
|
66
66
|
|
67
|
+
Das Programm kann Photos, die im Hochformat aufgenommen wurden, automatisch
|
68
|
+
drehen, falls die Kamera dies erkennen kann und in den Photo-Dateien speichert.
|
69
|
+
In diesem Fall wird das Photo zuerst gedreht und dann auf die entsprechende Site
|
70
|
+
hochgeladen. Hierbei werden Dateien in diesem Directory erzeugt, die mit 'rot_'
|
71
|
+
(für rotiert, wer hätte es gedacht?) beginnen.
|
72
|
+
|
73
|
+
Da es theoretisch auch möglich wäre, daß die entsprechende Photo-Site das Drehen
|
74
|
+
von sich aus beherrscht, ist vorgesehen, in zukünfigen Programm-Versionen das
|
75
|
+
Drehen vorab bei Bedarf zu deaktivieren.
|
76
|
+
|
77
|
+
Achtung: Beim normalen Hochladen werden diese Dateien nicht berücksichtigt,
|
78
|
+
du solltest also möglichst keine echten Photo hochladen wollen, die mit 'rot_'
|
79
|
+
beginnen. In der Praxis dürfte dies kein großes Problem sein. Falls der Dateiname
|
80
|
+
doch mit 'rot_' (die Farbe) beginnen sollte, benenne sie einfach in 'Rot_...' um,
|
81
|
+
dann wird diese Datei auch hochgeladen. Die rotierten
|
82
|
+
Dateien dürfen gefahrlos gelöscht werden, ist aber im normalen Betrieb für die
|
83
|
+
Funktionsweise dieses Programm nicht notwendig, da die gedrehten Dateien bei
|
84
|
+
Bedarf einfach neu angelegt werden.
|
85
|
+
|
86
|
+
|
67
87
|
Das Programm erstellt (im Directory multistockphoto) eine Datei namens
|
68
88
|
'sendeliste.dat', in der die erfolgreichen Uploads mit Site, Dateiname und
|
69
89
|
Datum/Uhrzeit protokolliert werden. Diese Datei darf nicht gelöscht werden,
|
@@ -79,19 +99,39 @@ Daten zu den einzelnen Bildern eintragen.
|
|
79
99
|
|
80
100
|
Einzelne Sites handhaben dies unterschiedlich.
|
81
101
|
|
102
|
+
Diese Nachbearbeitung auf der jeweiligen Seite ist derzeit noch nötig, es ist aber
|
103
|
+
geplant, daß auch z.B. die Schlagworte von diesem Programm schon gesetzt werden
|
104
|
+
können.
|
105
|
+
|
106
|
+
Desweiteren können Kriterien, z. B. Mindestauflösunge eines Bildes in Zukunft
|
107
|
+
schon vor des Hochladen überprüft werden. Dies ist jedoch noch nicht implementiert.
|
108
|
+
|
109
|
+
h3. fotolia.de
|
110
|
+
|
82
111
|
Beispiel: Bei fotolia.de mußt du deine Photos hochladen, dann noch Stichworte
|
83
112
|
und verschiedene Vertragsbedingungen festlegen. Dann erst werden deine Bilder
|
84
113
|
geprüft und entweder angenommen oder abgelehnt.
|
85
114
|
|
115
|
+
h3. zoonar.de
|
116
|
+
|
86
117
|
Bei zoonar.de wiederum läuft es so, daß du erst nur die Bilder hochlädst, dann
|
87
118
|
werden sie begutachtet; angenommen oder abgelehnt und erst wenn sie
|
88
119
|
angenommen wurden, kannst du Schlagworte vergeben. Dies hat natürlich den
|
89
120
|
Vorteil, daß man für abgelehnte Photos erst gar keine Schlagworte vergeben muß
|
90
121
|
(kann).
|
91
122
|
|
92
|
-
|
93
|
-
|
94
|
-
|
123
|
+
h3. photocase.de
|
124
|
+
|
125
|
+
Bei photocase.de lädst du ebenfalls zuerst deinen Photos hoch, diese werden
|
126
|
+
dann entweder angenommen oder abgelehnt. Bei angenommenen Bilder bearbeitest
|
127
|
+
du diese auf deren Seite weiter (eigentlich wie bei zoonar.de). Als nettes
|
128
|
+
Gimmick bei photocase kannst du bei deinen Photos sehen, an welchem Platz
|
129
|
+
sie sich aktuell in der Warteschlage der zu begutachtenden Photos befinden.
|
130
|
+
|
131
|
+
<i>Click on the Browse button to search your computer for the photo you’d like to upload. We accept JPG and TIFF files. Please pay close attention to the minimum resolution requirement of 1600x1200 pixels, the image quality (e.g. not overly compressed) and the content of the image itself (e.g. it does not contain any material that you don’t hold the copyright to).
|
132
|
+
</i>
|
133
|
+
|
134
|
+
|
95
135
|
|
96
136
|
h2. Demonstration of usage
|
97
137
|
|
@@ -132,6 +172,40 @@ konnte. Dies ist dann kein Fehler dieses Programms.
|
|
132
172
|
Starte dann einfach das Programm am nächsten Tag noch einmal, um den Rest der
|
133
173
|
Photos hochzuladen!
|
134
174
|
|
175
|
+
h3. Hoch- und Querformat
|
176
|
+
|
177
|
+
Einige Digitalkameras können erkennen, ob ein Bild im Hoch- oder Querformat
|
178
|
+
aufgenommmen wurde.
|
179
|
+
Falls dieses Programm erkennt, daß die Kamera ins Hochformat gedreht wurde,
|
180
|
+
so wird automatisch ein um 90 Grad nach links gedrehtes Bild erzeugt und dieses
|
181
|
+
hochgeladen. Da die Photosites dies theoretisch auch anhand der Exif-Daten in
|
182
|
+
der Bilddatei erkennen und das Bild automatisch drehen könnten, wird es in Zukunft
|
183
|
+
auch einen Schalter geben, um die automatische Drehung im Programm auszuschalten,
|
184
|
+
da dies dann nicht notwendig ist.
|
185
|
+
|
186
|
+
Die Photo-Sites, mit denen ich bis jetzt zu tun hatte, ignorieren dies aber
|
187
|
+
anscheinend bis jetzt.
|
188
|
+
|
189
|
+
Um dieses Verhalten in der Digitalkamera einzuschalten, mußte ich bei der Canon
|
190
|
+
EOS 400 D die Einstellung 'automatisch rotieren' aktivieren. Bei anderen Kameras
|
191
|
+
mag dies ähnlich sein. Bei der EOS 400 D kann man wählen, ob automatisch
|
192
|
+
für nur im Display der Kamera, im Display und auf dem PC oder überhaupt nicht
|
193
|
+
gedreht werden soll. Relevant ist hier die Einstellung 'auf dem PC drehen'. Wenn
|
194
|
+
man zusätzlich noch 'auf dem Display drehen' anwählt, heißt dies, daß zusätzlich
|
195
|
+
auch auf dem Display der Kamera das Bild gedreht angezeigt werden soll.
|
196
|
+
|
197
|
+
Um zu testen, in welcher 'orientation' ein Bild vorliegt kannst du das Programm
|
198
|
+
mit dem Schalter '--check-orientation Bild1.jpg Bild2.jpg ..' aufrufen.
|
199
|
+
|
200
|
+
Falls ein Bild mit der falsche Orientation vorliegt, kannst du das Bild mit
|
201
|
+
dem Schalter '--rotate bild1.jpg [bild2.jpg ..]' um 90 Grad nach links drehen.
|
202
|
+
Achtung: dabei wird die Originaldatei mit dem gedrehten Bild überschrieben - falls
|
203
|
+
du das nicht willst, lege vorher eine Kopie an!
|
204
|
+
|
205
|
+
Wenn deine Kamera nicht erkennen kann, ob ein Photo im Hochformat aufgenommen
|
206
|
+
wurde, dann drehe das Bild vor dem Hochladen mit dem Schalter '--rotate' oder
|
207
|
+
einen anderen Programm, welches Bilde drehen kann!
|
208
|
+
|
135
209
|
h2. Forum
|
136
210
|
|
137
211
|
"http://groups.google.com/group/multistockphoto":http://groups.google.com/group/multistockphoto
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multistockphoto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Preymesser
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-05-
|
12
|
+
date: 2008-05-10 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -44,6 +44,7 @@ files:
|
|
44
44
|
- lib/multistockphoto/generic_site.rb
|
45
45
|
- lib/multistockphoto/site_fotolia.rb
|
46
46
|
- lib/multistockphoto/site_zoonar.rb
|
47
|
+
- lib/multistockphoto/site_photocase.rb
|
47
48
|
- lib/multistockphoto/site_aldi.rb
|
48
49
|
- lib/multistockphoto/photo.rb
|
49
50
|
- script/console
|