libis-format 0.9.33 → 0.9.35
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/libis/format/identifier.rb +7 -8
- data/lib/libis/format/version.rb +1 -1
- data/spec/converter_spec.rb +44 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da9fb9519c4c34acf71a1d337b38a575be668b59
|
4
|
+
data.tar.gz: 22f23bb3cc7f5772c95891b2fa2a356bbc881d43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a6e12bd802a6f12b6367c07e08d1ad59d7c55ff53f0669ac82b11074c96930e3cb61b9dae44c0fc2590284e223efb27b2bb41b06978893620ae7abe3d5a5548
|
7
|
+
data.tar.gz: 21c025acb844ec485e65ca494b565cbc620024f77255c19f0eaf96e51739f44b57061740ecf497c532763eb9c745b5304eff56b08eed5d6bcc136ea3f5f6753f
|
@@ -40,9 +40,9 @@ module Libis
|
|
40
40
|
|
41
41
|
def get(file, options = {})
|
42
42
|
|
43
|
-
options[:droid] = true unless options[:tool] and options[:tool] != :droid
|
44
|
-
options[:fido] = true unless options[:tool] and options[:tool] != :fido
|
45
|
-
options[:file] = true unless options[:tool] and options[:tool] != :file
|
43
|
+
options[:droid] = true unless options.keys.include?(:droid) and options[:tool] and options[:tool] != :droid
|
44
|
+
options[:fido] = true unless options.keys.include?(:fido) and options[:tool] and options[:tool] != :fido
|
45
|
+
options[:file] = true unless options.keys.include?(:file) and options[:tool] and options[:tool] != :file
|
46
46
|
|
47
47
|
result = {messages: [], output: {}, formats: {}}
|
48
48
|
|
@@ -72,10 +72,6 @@ module Libis
|
|
72
72
|
|
73
73
|
process_results(result)
|
74
74
|
|
75
|
-
# result[:mimetype] ?
|
76
|
-
# log_msg(result, :info, "Identification of '#{file}': '#{result}'") :
|
77
|
-
# log_msg(result, :warn, "Could not identify MIME type of '#{file}'")
|
78
|
-
|
79
75
|
result
|
80
76
|
|
81
77
|
end
|
@@ -139,9 +135,11 @@ module Libis
|
|
139
135
|
end
|
140
136
|
|
141
137
|
def process_results(result)
|
142
|
-
result[:output].
|
138
|
+
result[:output].keys.each do |file|
|
139
|
+
output = result[:output].delete(file)
|
143
140
|
file_result = result[:formats][file] = {}
|
144
141
|
if output.empty?
|
142
|
+
log_msg(result, :warn, "Could not identify format of '#{file}'.")
|
145
143
|
file_result = {
|
146
144
|
mimetype: 'application/octet-stream',
|
147
145
|
puid: 'fmt/unknown',
|
@@ -164,6 +162,7 @@ module Libis
|
|
164
162
|
end
|
165
163
|
end
|
166
164
|
end
|
165
|
+
result.delete(:output)
|
167
166
|
end
|
168
167
|
|
169
168
|
def process_multiple_formats(file_result, format_matches, output)
|
data/lib/libis/format/version.rb
CHANGED
data/spec/converter_spec.rb
CHANGED
@@ -181,7 +181,6 @@ describe 'Converters' do
|
|
181
181
|
src_file = File.join(file_dir, 'data', 'multipage.tif')
|
182
182
|
ref_file = File.join(file_dir, 'data', 'multipage.tif.jp2')
|
183
183
|
tgt_file = File.join('', 'tmp', 'test.jp2')
|
184
|
-
diff_file = File.join('', 'tmp', 'diff.jpg')
|
185
184
|
FileUtils.mkdir_p File.dirname(tgt_file)
|
186
185
|
converter.delete_date
|
187
186
|
converter.quiet(true)
|
@@ -198,6 +197,50 @@ describe 'Converters' do
|
|
198
197
|
FileUtils.rm tgt_file, force: true
|
199
198
|
end
|
200
199
|
|
200
|
+
it 'converts TIFF to JP2' do
|
201
|
+
src_file = File.join(file_dir, 'data', 'test.tif')
|
202
|
+
tgt_file = File.join('', 'tmp', 'test.jp2')
|
203
|
+
FileUtils.mkdir_p File.dirname(tgt_file)
|
204
|
+
converter.delete_date
|
205
|
+
result = converter.convert(src_file, tgt_file, :JP2)
|
206
|
+
expect(result).to eq tgt_file
|
207
|
+
expect(File.exist?(tgt_file)).to be_truthy
|
208
|
+
end
|
209
|
+
|
210
|
+
|
211
|
+
end
|
212
|
+
|
213
|
+
context 'JP2 Converter' do
|
214
|
+
|
215
|
+
let(:converter) {Libis::Format::Converter::Jp2Converter.new}
|
216
|
+
let(:diff_file) {File.join('', 'tmp', 'diff.jpg')}
|
217
|
+
|
218
|
+
it 'converts TIFF to JP2' do
|
219
|
+
src_file = File.join(file_dir, 'data', 'test.tif')
|
220
|
+
tgt_file = File.join('', 'tmp', 'test.jp2')
|
221
|
+
FileUtils.mkdir_p File.dirname(tgt_file)
|
222
|
+
result = converter.convert(src_file, tgt_file, :JP2)
|
223
|
+
expect(result).to eq tgt_file
|
224
|
+
expect(File.exist?(tgt_file)).to be_truthy
|
225
|
+
end
|
226
|
+
|
227
|
+
it 'converts only first page of multipage TIFF to JP2' do
|
228
|
+
src_file = File.join(file_dir, 'data', 'multipage.tif')
|
229
|
+
ref_file = File.join(file_dir, 'data', 'multipage.tif.jp2')
|
230
|
+
tgt_file = File.join('', 'tmp', 'test.jp2')
|
231
|
+
FileUtils.mkdir_p File.dirname(tgt_file)
|
232
|
+
result = converter.convert(src_file, tgt_file, :JP2)
|
233
|
+
expect(result).to eq tgt_file
|
234
|
+
expect(File.exist?(tgt_file)).to be_truthy
|
235
|
+
compare = MiniMagick::Tool::Compare.new
|
236
|
+
compare << ref_file << tgt_file
|
237
|
+
compare.metric << 'MAE'
|
238
|
+
compare.fuzz << '10%'
|
239
|
+
compare << diff_file
|
240
|
+
compare.call {|_,_,status| expect(status).to be 0}
|
241
|
+
FileUtils.rm tgt_file, force: true
|
242
|
+
end
|
243
|
+
|
201
244
|
end
|
202
245
|
|
203
246
|
context 'Pdf Converter' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libis-format
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.35
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kris Dekeyser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -253,7 +253,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
253
253
|
version: '0'
|
254
254
|
requirements: []
|
255
255
|
rubyforge_project:
|
256
|
-
rubygems_version: 2.
|
256
|
+
rubygems_version: 2.5.1
|
257
257
|
signing_key:
|
258
258
|
specification_version: 4
|
259
259
|
summary: LIBIS File format format services.
|