hydra-derivatives 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +3 -0
- data/VERSION +1 -1
- data/lib/hydra/derivatives.rb +1 -0
- data/lib/hydra/derivatives/extract_metadata.rb +1 -1
- data/lib/hydra/derivatives/jpeg2k_image.rb +10 -23
- data/lib/hydra/derivatives/logger.rb +24 -0
- data/spec/lib/hydra/derivatives/extract_metadata_spec.rb +7 -3
- data/spec/spec_helper.rb +1 -1
- data/spec/units/config_spec.rb +10 -10
- data/spec/units/extract_spec.rb +1 -1
- data/spec/units/image_spec.rb +4 -4
- data/spec/units/jpeg2k_spec.rb +6 -6
- data/spec/units/logger_spec.rb +25 -0
- data/spec/units/transcoding_spec.rb +35 -36
- data/spec/units/video_spec.rb +3 -3
- metadata +28 -26
- data/lib/hydra/derivatives/jpeg2k_config.yml +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9915bdcf795eeb369e8d6d74c73ea28b6e123d7
|
4
|
+
data.tar.gz: 8324701965b3eeaafab56b3d7c4c1865c7a63523
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85e2b44fb759711a73de6a282732f919f5fc2cb6caf8bcb7f312d6e78238588b9321d174e45aca66cfd58cc01f43b4ba65207400f532be822333a5aa43031e9d
|
7
|
+
data.tar.gz: 7367297fea0431159120dca7805b16e54fd2c6e252368f6ef8b57e8bf7ce89f19931d8485fe50ce774a3500a73e3bb31b95fb591e8ed4dccfb05e0df3e6c83fc
|
data/History.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/hydra/derivatives.rb
CHANGED
@@ -30,7 +30,7 @@ module Hydra
|
|
30
30
|
|
31
31
|
def filename_for_characterization
|
32
32
|
mime_type = MIME::Types[mimeType].first
|
33
|
-
|
33
|
+
Logger.warn "Unable to find a registered mime type for #{mimeType.inspect} on #{pid}" unless mime_type
|
34
34
|
extension = mime_type ? ".#{mime_type.extensions.first}" : ''
|
35
35
|
["#{pid}-#{dsVersionID}", "#{extension}"]
|
36
36
|
end
|
@@ -8,19 +8,16 @@ module Hydra
|
|
8
8
|
include ShellBasedProcessor
|
9
9
|
|
10
10
|
def process
|
11
|
-
|
11
|
+
image = MiniMagick::Image.read(source_datastream.content)
|
12
|
+
quality = image['%[channels]'] == 'gray' ? 'gray' : 'color'
|
12
13
|
directives.each do |name, args|
|
13
|
-
|
14
|
-
|
14
|
+
long_dim = self.class.long_dim(image)
|
15
|
+
file_path = self.class.tmp_file('.tif')
|
15
16
|
to_srgb = args.fetch(:to_srgb, true)
|
16
17
|
if args[:resize] || to_srgb
|
17
|
-
image
|
18
|
-
long_dim = self.class.long_dim(image)
|
19
|
-
file_path = self.class.tmp_file('.tif')
|
20
|
-
image.write file_path
|
21
|
-
else
|
22
|
-
long_dim = self.class.long_dim(MiniMagick::Image.read(source_datastream.content))
|
18
|
+
preprocess(image, resize: args[:resize], to_srgb: to_srgb, src_quality: quality)
|
23
19
|
end
|
20
|
+
image.write file_path
|
24
21
|
recipe = self.class.kdu_compress_recipe(args, quality, long_dim)
|
25
22
|
output_datastream_name = args[:datastream] || output_datastream_id(name)
|
26
23
|
encode_datastream(output_datastream_name, recipe, file_path: file_path)
|
@@ -43,9 +40,8 @@ module Hydra
|
|
43
40
|
end
|
44
41
|
|
45
42
|
protected
|
46
|
-
def preprocess(opts={})
|
47
|
-
# resize: <geometry>, to_srgb: <bool>,src_quality: 'color'|'
|
48
|
-
image = MiniMagick::Image.read(source_datastream.content)
|
43
|
+
def preprocess(image, opts={})
|
44
|
+
# resize: <geometry>, to_srgb: <bool>, src_quality: 'color'|'gray'
|
49
45
|
image.combine_options do |c|
|
50
46
|
c.resize(opts[:resize]) if opts[:resize]
|
51
47
|
c.profile self.class.srgb_profile_path if opts[:src_quality] == 'color' && opts[:to_srgb]
|
@@ -53,15 +49,6 @@ module Hydra
|
|
53
49
|
image
|
54
50
|
end
|
55
51
|
|
56
|
-
def extract_quality_and_colorspace
|
57
|
-
xml = source_datastream.extract_metadata
|
58
|
-
doc = Nokogiri::XML(xml).remove_namespaces!
|
59
|
-
bps = doc.xpath('//bitsPerSample').first.content
|
60
|
-
quality = bps == '8 8 8' ? 'color' : 'grey'
|
61
|
-
colorspace = doc.xpath('.//colorSpace').first.content
|
62
|
-
[quality, colorspace]
|
63
|
-
end
|
64
|
-
|
65
52
|
def self.encode(path, recipe, output_file)
|
66
53
|
kdu_compress = Hydra::Derivatives.kdu_compress_path
|
67
54
|
execute "#{kdu_compress} -i #{path} -o #{output_file} #{recipe}"
|
@@ -89,7 +76,7 @@ module Hydra
|
|
89
76
|
if Hydra::Derivatives.kdu_compress_recipes.has_key? recipe
|
90
77
|
return Hydra::Derivatives.kdu_compress_recipes[recipe]
|
91
78
|
else
|
92
|
-
|
79
|
+
Logger.warn "No JP2 recipe for :#{args[:recipe].to_s} ('#{recipe}') found in configuration. Using best guess."
|
93
80
|
return Hydra::Derivatives::Jpeg2kImage.calculate_recipe(args,quality,long_dim)
|
94
81
|
end
|
95
82
|
elsif args[:recipe].is_a? String
|
@@ -104,7 +91,7 @@ module Hydra
|
|
104
91
|
rates_arg = Hydra::Derivatives::Jpeg2kImage.layer_rates(args.fetch(:layers, 8), args.fetch(:compression, 10))
|
105
92
|
tile_size = args.fetch(:tile_size, 1024)
|
106
93
|
tiles_arg = "\{#{tile_size},#{tile_size}\}"
|
107
|
-
jp2_space_arg = quality == '
|
94
|
+
jp2_space_arg = quality == 'gray' ? 'sLUM' : 'sRGB'
|
108
95
|
|
109
96
|
%Q{-rate #{rates_arg}
|
110
97
|
-jp2_space #{jp2_space_arg}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Hydra::Derivatives
|
2
|
+
class Logger
|
3
|
+
|
4
|
+
class << self
|
5
|
+
|
6
|
+
def method_missing method_name, *arguments, &block
|
7
|
+
logger.send(method_name, *arguments, &block)
|
8
|
+
rescue
|
9
|
+
super
|
10
|
+
end
|
11
|
+
|
12
|
+
def respond_to?(method_name, include_private = false)
|
13
|
+
logger.respond_to? method_name
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def logger
|
19
|
+
ActiveFedora::Base.logger || ::Logger.new(STDOUT)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -21,12 +21,16 @@ module Hydra::Derivatives
|
|
21
21
|
context '#extract_metadata' do
|
22
22
|
context 'without content' do
|
23
23
|
let(:initialization_options) { {content: '', mime_type: 'text/plain'} }
|
24
|
-
|
24
|
+
it 'should be nil' do
|
25
|
+
expect(subject.extract_metadata).to be_nil
|
26
|
+
end
|
25
27
|
end
|
26
28
|
|
27
29
|
context 'with content', unless: ENV['TRAVIS'] == 'true' do
|
28
30
|
let(:mime_type) { 'image/jpeg' }
|
29
|
-
|
31
|
+
it 'should get some XML' do
|
32
|
+
expect(subject.extract_metadata).to match "<identity format=\"Plain text\" mimetype=\"text/plain\""
|
33
|
+
end
|
30
34
|
end
|
31
35
|
end
|
32
36
|
|
@@ -36,4 +40,4 @@ module Hydra::Derivatives
|
|
36
40
|
end
|
37
41
|
end
|
38
42
|
end
|
39
|
-
end
|
43
|
+
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/units/config_spec.rb
CHANGED
@@ -4,31 +4,31 @@ describe "the configuration" do
|
|
4
4
|
subject {Hydra::Derivatives }
|
5
5
|
|
6
6
|
it "should have some configuration defaults" do
|
7
|
-
subject.ffmpeg_path.
|
8
|
-
subject.enable_ffmpeg.
|
9
|
-
subject.libreoffice_path.
|
10
|
-
subject.temp_file_base.
|
11
|
-
subject.fits_path.
|
12
|
-
subject.kdu_compress_path.
|
7
|
+
expect(subject.ffmpeg_path).to eq('ffmpeg')
|
8
|
+
expect(subject.enable_ffmpeg).to be true
|
9
|
+
expect(subject.libreoffice_path).to eq('soffice')
|
10
|
+
expect(subject.temp_file_base).to eq('/tmp')
|
11
|
+
expect(subject.fits_path).to eq('fits.sh')
|
12
|
+
expect(subject.kdu_compress_path).to eq('kdu_compress')
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should let you change the configuration" do
|
16
16
|
subject.ffmpeg_path = '/usr/local/ffmpeg-1.0/bin/ffmpeg'
|
17
|
-
subject.ffmpeg_path.
|
17
|
+
expect(subject.ffmpeg_path).to eq('/usr/local/ffmpeg-1.0/bin/ffmpeg')
|
18
18
|
|
19
19
|
subject.kdu_compress_path = '/opt/local/bin/kdu_compress'
|
20
|
-
subject.kdu_compress_path.
|
20
|
+
expect(subject.kdu_compress_path).to eq('/opt/local/bin/kdu_compress')
|
21
21
|
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should let you reset the configuration" do
|
25
25
|
subject.ffmpeg_path = '/usr/local/ffmpeg-1.0/bin/ffmpeg'
|
26
26
|
subject.reset_config!
|
27
|
-
subject.ffmpeg_path.
|
27
|
+
expect(subject.ffmpeg_path).to eq('ffmpeg')
|
28
28
|
|
29
29
|
subject.kdu_compress_path = '/usr/local/bin/kdu_compress'
|
30
30
|
subject.reset_config!
|
31
|
-
subject.kdu_compress_path.
|
31
|
+
expect(subject.kdu_compress_path).to eq('kdu_compress')
|
32
32
|
end
|
33
33
|
|
34
34
|
end
|
data/spec/units/extract_spec.rb
CHANGED
@@ -16,7 +16,7 @@ describe Hydra::Derivatives::ExtractMetadata, :unless => $in_travis do
|
|
16
16
|
xml = subject.extract_metadata
|
17
17
|
doc = Nokogiri::HTML(xml)
|
18
18
|
identity = doc.xpath('//identity').first
|
19
|
-
identity.attr('mimetype').
|
19
|
+
expect(identity.attr('mimetype')).to eq('image/png')
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
data/spec/units/image_spec.rb
CHANGED
@@ -7,8 +7,8 @@ describe Hydra::Derivatives::Image do
|
|
7
7
|
subject { Hydra::Derivatives::Image.new(object, 'content', directives)}
|
8
8
|
|
9
9
|
it "should use the string as the size and the name is autogenerated" do
|
10
|
-
subject.
|
11
|
-
ds.dsid.
|
10
|
+
expect(subject).to receive(:create_resized_image).with(an_instance_of(ActiveFedora::Datastream), "100x100>", 'png') do |ds|
|
11
|
+
expect(ds.dsid).to eq('content_thumb')
|
12
12
|
end
|
13
13
|
subject.process
|
14
14
|
end
|
@@ -17,8 +17,8 @@ describe Hydra::Derivatives::Image do
|
|
17
17
|
let(:directives) {{ :thumb => {size: "200x300>", datastream: 'thumbnail'} }}
|
18
18
|
subject { Hydra::Derivatives::Image.new(object, 'content', directives)}
|
19
19
|
it "should use the specified size and name" do
|
20
|
-
subject.
|
21
|
-
ds.dsid.
|
20
|
+
expect(subject).to receive(:create_resized_image).with(an_instance_of(ActiveFedora::Datastream), "200x300>", 'png') do |ds|
|
21
|
+
expect(ds.dsid).to eq('thumbnail')
|
22
22
|
end
|
23
23
|
subject.process
|
24
24
|
|
data/spec/units/jpeg2k_spec.rb
CHANGED
@@ -7,14 +7,14 @@ describe Hydra::Derivatives::Jpeg2kImage do
|
|
7
7
|
describe "#calculate_recipe" do
|
8
8
|
it "calculates the number of levels from a size" do
|
9
9
|
dim = 7200
|
10
|
-
Hydra::Derivatives::Jpeg2kImage.level_count_for_size(dim).
|
10
|
+
expect(Hydra::Derivatives::Jpeg2kImage.level_count_for_size(dim)).to eq(6)
|
11
11
|
end
|
12
12
|
|
13
13
|
it "calculates the compression rates for each quality layer" do
|
14
14
|
compression_num = 10
|
15
15
|
layers = 8
|
16
16
|
calc = Hydra::Derivatives::Jpeg2kImage.layer_rates(layers, compression_num)
|
17
|
-
calc.
|
17
|
+
expect(calc).to eq("2.4,1.48331273,0.91675694,0.56659885,0.3501847,0.21643059,0.13376427,0.0826726")
|
18
18
|
end
|
19
19
|
|
20
20
|
end
|
@@ -28,25 +28,25 @@ describe Hydra::Derivatives::Jpeg2kImage do
|
|
28
28
|
it "can get the recipe from a config file" do
|
29
29
|
args = { recipe: :myrecipe }
|
30
30
|
r = Hydra::Derivatives::Jpeg2kImage.kdu_compress_recipe(args, 'grey', 7200)
|
31
|
-
r.
|
31
|
+
expect(r).to eq(@sample_cfg['jp2_recipes']['myrecipe_grey'])
|
32
32
|
end
|
33
33
|
|
34
34
|
it "can take a recipe as a string" do
|
35
35
|
args = { recipe: '-my -excellent -recipe' }
|
36
36
|
r = Hydra::Derivatives::Jpeg2kImage.kdu_compress_recipe(args, 'grey', 7200)
|
37
|
-
r.
|
37
|
+
expect(r).to eq(args[:recipe])
|
38
38
|
end
|
39
39
|
|
40
40
|
it "will fall back to a #calculate_recipe if a symbol is passed but no recipe is found" do
|
41
41
|
args = { recipe: :x }
|
42
42
|
r = Hydra::Derivatives::Jpeg2kImage.kdu_compress_recipe(args, 'grey', 7200)
|
43
|
-
r.
|
43
|
+
expect(r).to eq(Hydra::Derivatives::Jpeg2kImage.calculate_recipe(args, 'grey', 7200))
|
44
44
|
end
|
45
45
|
|
46
46
|
it "will fall back to a #calculate_recipe if there is no attempt to provide one" do
|
47
47
|
args = {}
|
48
48
|
r = Hydra::Derivatives::Jpeg2kImage.kdu_compress_recipe(args, 'grey', 7200)
|
49
|
-
r.
|
49
|
+
expect(r).to eq(Hydra::Derivatives::Jpeg2kImage.calculate_recipe(args, 'grey', 7200))
|
50
50
|
end
|
51
51
|
|
52
52
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Hydra::Derivatives::Logger do
|
4
|
+
|
5
|
+
context "with log levels" do
|
6
|
+
|
7
|
+
let(:levels) { ["unknown", "fatal", "error", "warn", "info", "debug"] }
|
8
|
+
|
9
|
+
it "should respond successfully" do
|
10
|
+
levels.each do |level|
|
11
|
+
expect(Hydra::Derivatives::Logger.respond_to?(level)).to be_truthy
|
12
|
+
end
|
13
|
+
end
|
14
|
+
it "should accept messages" do
|
15
|
+
expect(Hydra::Derivatives::Logger.warn("message")).to be_truthy
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "with garbage" do
|
20
|
+
it "should raise an error" do
|
21
|
+
expect{Hydra::Derivatives::Logger.garbage}.to raise_error(NoMethodError)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -70,15 +70,15 @@ describe "Transcoder" do
|
|
70
70
|
end
|
71
71
|
|
72
72
|
it "should transcode" do
|
73
|
-
file.datastreams.key?('content_medium').
|
73
|
+
expect(file.datastreams.key?('content_medium')).to be_falsey
|
74
74
|
file.create_derivatives
|
75
|
-
file.datastreams['content_medium'].
|
76
|
-
file.datastreams['content_medium'].mimeType.
|
77
|
-
file.datastreams['content_thumb'].
|
78
|
-
file.datastreams['content_thumb'].mimeType.
|
79
|
-
file.datastreams['access'].
|
80
|
-
file.datastreams['access'].mimeType.
|
81
|
-
file.datastreams.key?('content_text').
|
75
|
+
expect(file.datastreams['content_medium']).to have_content
|
76
|
+
expect(file.datastreams['content_medium'].mimeType).to eq('image/png')
|
77
|
+
expect(file.datastreams['content_thumb']).to have_content
|
78
|
+
expect(file.datastreams['content_thumb'].mimeType).to eq('image/png')
|
79
|
+
expect(file.datastreams['access']).to have_content
|
80
|
+
expect(file.datastreams['access'].mimeType).to eq('image/jpeg')
|
81
|
+
expect(file.datastreams.key?('content_text')).to be_falsey
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
@@ -87,10 +87,10 @@ describe "Transcoder" do
|
|
87
87
|
let(:file) { GenericFile.new(mime_type: 'application/pdf').tap { |t| t.content.content = attachment; t.save } }
|
88
88
|
|
89
89
|
it "should transcode" do
|
90
|
-
file.datastreams.key?('content_thumb').
|
90
|
+
expect(file.datastreams.key?('content_thumb')).to be_falsey
|
91
91
|
file.create_derivatives
|
92
|
-
file.datastreams['content_thumb'].
|
93
|
-
file.datastreams['content_thumb'].mimeType.
|
92
|
+
expect(file.datastreams['content_thumb']).to have_content
|
93
|
+
expect(file.datastreams['content_thumb'].mimeType).to eq('image/png')
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
@@ -100,10 +100,10 @@ describe "Transcoder" do
|
|
100
100
|
|
101
101
|
it "should transcode" do
|
102
102
|
file.create_derivatives
|
103
|
-
file.datastreams['content_mp3'].
|
104
|
-
file.datastreams['content_mp3'].mimeType.
|
105
|
-
file.datastreams['content_ogg'].
|
106
|
-
file.datastreams['content_ogg'].mimeType.
|
103
|
+
expect(file.datastreams['content_mp3']).to have_content
|
104
|
+
expect(file.datastreams['content_mp3'].mimeType).to eq('audio/mpeg')
|
105
|
+
expect(file.datastreams['content_ogg']).to have_content
|
106
|
+
expect(file.datastreams['content_ogg'].mimeType).to eq('audio/ogg')
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
@@ -112,10 +112,9 @@ describe "Transcoder" do
|
|
112
112
|
let(:file) { GenericFile.new(mime_type: 'audio/wav').tap { |t| t.content.content = attachment; t.content.mimeType = 'audio/vnd.wav'; t.save } }
|
113
113
|
|
114
114
|
it "should transcode" do
|
115
|
-
expect(logger).to receive(:warn).with("Unable to find a registered mime type for \"audio/vnd.wav\" on #{file.pid}").twice
|
116
115
|
file.create_derivatives
|
117
|
-
file.datastreams['content_mp3'].
|
118
|
-
file.datastreams['content_mp3'].mimeType.
|
116
|
+
expect(file.datastreams['content_mp3']).to have_content
|
117
|
+
expect(file.datastreams['content_mp3'].mimeType).to eq('audio/mpeg')
|
119
118
|
end
|
120
119
|
end
|
121
120
|
|
@@ -125,12 +124,12 @@ describe "Transcoder" do
|
|
125
124
|
|
126
125
|
it "should transcode" do
|
127
126
|
file.create_derivatives
|
128
|
-
file.datastreams['content_mp4'].
|
129
|
-
file.datastreams['content_mp4'].mimeType.
|
130
|
-
file.datastreams['content_webm'].
|
131
|
-
file.datastreams['content_webm'].mimeType.
|
132
|
-
file.datastreams['thumbnail'].
|
133
|
-
file.datastreams['thumbnail'].mimeType.
|
127
|
+
expect(file.datastreams['content_mp4']).to have_content
|
128
|
+
expect(file.datastreams['content_mp4'].mimeType).to eq('video/mp4')
|
129
|
+
expect(file.datastreams['content_webm']).to have_content
|
130
|
+
expect(file.datastreams['content_webm'].mimeType).to eq('video/webm')
|
131
|
+
expect(file.datastreams['thumbnail']).to have_content
|
132
|
+
expect(file.datastreams['thumbnail'].mimeType).to eq('image/jpeg')
|
134
133
|
end
|
135
134
|
end
|
136
135
|
|
@@ -139,11 +138,11 @@ describe "Transcoder" do
|
|
139
138
|
let(:file) { GenericFile.new(mime_type: 'image/png', label: "special").tap { |t| t.content.content = attachment; t.save } }
|
140
139
|
|
141
140
|
it "should transcode" do
|
142
|
-
file.datastreams.key?('special_ds').
|
141
|
+
expect(file.datastreams.key?('special_ds')).to be_falsey
|
143
142
|
file.create_derivatives
|
144
|
-
file.datastreams['special_ds'].
|
145
|
-
file.datastreams['special_ds'].mimeType.
|
146
|
-
file.datastreams['special_ds'].
|
143
|
+
expect(file.datastreams['special_ds']).to have_content
|
144
|
+
expect(file.datastreams['special_ds'].mimeType).to eq('image/png')
|
145
|
+
expect(file.datastreams['special_ds']).to have_content
|
147
146
|
end
|
148
147
|
end
|
149
148
|
|
@@ -212,14 +211,14 @@ describe "Transcoder" do
|
|
212
211
|
let(:file) { GenericFile.new(mime_type: 'image/tiff').tap { |t| t.content.content = attachment; t.save } }
|
213
212
|
it "should transcode" do
|
214
213
|
file.create_derivatives
|
215
|
-
file.datastreams['content_diy'].
|
216
|
-
file.datastreams['content_diy'].mimeType.
|
217
|
-
file.datastreams['config_lookup'].
|
218
|
-
file.datastreams['config_lookup'].mimeType.
|
219
|
-
file.datastreams['resized'].
|
220
|
-
file.datastreams['resized'].mimeType.
|
221
|
-
file.datastreams['string_recipe'].
|
222
|
-
file.datastreams['string_recipe'].mimeType.
|
214
|
+
expect(file.datastreams['content_diy']).to have_content
|
215
|
+
expect(file.datastreams['content_diy'].mimeType).to eq('image/jp2')
|
216
|
+
expect(file.datastreams['config_lookup']).to have_content
|
217
|
+
expect(file.datastreams['config_lookup'].mimeType).to eq('image/jp2')
|
218
|
+
expect(file.datastreams['resized']).to have_content
|
219
|
+
expect(file.datastreams['resized'].mimeType).to eq('image/jp2')
|
220
|
+
expect(file.datastreams['string_recipe']).to have_content
|
221
|
+
expect(file.datastreams['string_recipe'].mimeType).to eq('image/jp2')
|
223
222
|
end
|
224
223
|
end
|
225
224
|
end
|
data/spec/units/video_spec.rb
CHANGED
@@ -6,7 +6,7 @@ describe Hydra::Derivatives::Video do
|
|
6
6
|
let(:directives) {{ :thumb => {format: "webm", datastream: 'thumbnail'} }}
|
7
7
|
subject { Hydra::Derivatives::Video.new(double(:obj), 'content', directives)}
|
8
8
|
it "should create a datastream with the specified name" do
|
9
|
-
subject.
|
9
|
+
expect(subject).to receive(:encode_datastream).with("thumbnail", "webm", 'video/webm', {Hydra::Derivatives::Ffmpeg::OUTPUT_OPTIONS =>"-s 320x240 -vcodec libvpx -acodec libvorbis -g 30 -b:v 345k -ac 2 -ab 96k -ar 44100", Hydra::Derivatives::Ffmpeg::INPUT_OPTIONS=>""})
|
10
10
|
subject.process
|
11
11
|
|
12
12
|
end
|
@@ -16,7 +16,7 @@ describe Hydra::Derivatives::Video do
|
|
16
16
|
let(:directives) {{ :thumb => {format: "webm"} }}
|
17
17
|
subject { Hydra::Derivatives::Video.new(double(:obj), 'content', directives)}
|
18
18
|
it "should create a datastream and infer the name" do
|
19
|
-
subject.
|
19
|
+
expect(subject).to receive(:encode_datastream).with("content_thumb", "webm", 'video/webm', {Hydra::Derivatives::Ffmpeg::OUTPUT_OPTIONS =>"-s 320x240 -vcodec libvpx -acodec libvorbis -g 30 -b:v 345k -ac 2 -ab 96k -ar 44100", Hydra::Derivatives::Ffmpeg::INPUT_OPTIONS=>""})
|
20
20
|
subject.process
|
21
21
|
|
22
22
|
end
|
@@ -26,7 +26,7 @@ describe Hydra::Derivatives::Video do
|
|
26
26
|
let(:directives) {{ :thumb => {:format => 'jpg' , datastream: 'thumbnail'} }}
|
27
27
|
subject { Hydra::Derivatives::Video.new(double(:obj), 'content', directives)}
|
28
28
|
it "should create a datastream and infer the name" do
|
29
|
-
subject.
|
29
|
+
expect(subject).to receive(:encode_datastream).with("thumbnail", "jpg", "image/jpeg", {:output_options=>"-s 320x240 -vcodec mjpeg -vframes 1 -an -f rawvideo", :input_options=>" -itsoffset -2"})
|
30
30
|
subject.process
|
31
31
|
|
32
32
|
end
|
metadata
CHANGED
@@ -1,131 +1,131 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hydra-derivatives
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Coyne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: jettywrapper
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: active-fedora
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: hydra-file_characterization
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: mini_magick
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: activesupport
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: 3.2.13
|
118
|
-
- - <
|
118
|
+
- - "<"
|
119
119
|
- !ruby/object:Gem::Version
|
120
120
|
version: '5.0'
|
121
121
|
type: :runtime
|
122
122
|
prerelease: false
|
123
123
|
version_requirements: !ruby/object:Gem::Requirement
|
124
124
|
requirements:
|
125
|
-
- -
|
125
|
+
- - ">="
|
126
126
|
- !ruby/object:Gem::Version
|
127
127
|
version: 3.2.13
|
128
|
-
- - <
|
128
|
+
- - "<"
|
129
129
|
- !ruby/object:Gem::Version
|
130
130
|
version: '5.0'
|
131
131
|
description: Derivative generation plugin for hydra
|
@@ -135,9 +135,9 @@ executables: []
|
|
135
135
|
extensions: []
|
136
136
|
extra_rdoc_files: []
|
137
137
|
files:
|
138
|
-
- .gitignore
|
139
|
-
- .rspec
|
140
|
-
- .travis.yml
|
138
|
+
- ".gitignore"
|
139
|
+
- ".rspec"
|
140
|
+
- ".travis.yml"
|
141
141
|
- CONTRIBUTING.md
|
142
142
|
- Gemfile
|
143
143
|
- History.md
|
@@ -157,8 +157,8 @@ files:
|
|
157
157
|
- lib/hydra/derivatives/extract_metadata.rb
|
158
158
|
- lib/hydra/derivatives/ffmpeg.rb
|
159
159
|
- lib/hydra/derivatives/image.rb
|
160
|
-
- lib/hydra/derivatives/jpeg2k_config.yml
|
161
160
|
- lib/hydra/derivatives/jpeg2k_image.rb
|
161
|
+
- lib/hydra/derivatives/logger.rb
|
162
162
|
- lib/hydra/derivatives/processor.rb
|
163
163
|
- lib/hydra/derivatives/railtie.rb
|
164
164
|
- lib/hydra/derivatives/shell_based_processor.rb
|
@@ -183,6 +183,7 @@ files:
|
|
183
183
|
- spec/units/extract_spec.rb
|
184
184
|
- spec/units/image_spec.rb
|
185
185
|
- spec/units/jpeg2k_spec.rb
|
186
|
+
- spec/units/logger_spec.rb
|
186
187
|
- spec/units/transcoding_spec.rb
|
187
188
|
- spec/units/video_spec.rb
|
188
189
|
homepage: https://github.com/projecthydra/hydra-derivatives
|
@@ -195,12 +196,12 @@ require_paths:
|
|
195
196
|
- lib
|
196
197
|
required_ruby_version: !ruby/object:Gem::Requirement
|
197
198
|
requirements:
|
198
|
-
- -
|
199
|
+
- - ">="
|
199
200
|
- !ruby/object:Gem::Version
|
200
201
|
version: '0'
|
201
202
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
202
203
|
requirements:
|
203
|
-
- -
|
204
|
+
- - ">="
|
204
205
|
- !ruby/object:Gem::Version
|
205
206
|
version: '0'
|
206
207
|
requirements: []
|
@@ -230,5 +231,6 @@ test_files:
|
|
230
231
|
- spec/units/extract_spec.rb
|
231
232
|
- spec/units/image_spec.rb
|
232
233
|
- spec/units/jpeg2k_spec.rb
|
234
|
+
- spec/units/logger_spec.rb
|
233
235
|
- spec/units/transcoding_spec.rb
|
234
236
|
- spec/units/video_spec.rb
|
@@ -1,20 +0,0 @@
|
|
1
|
-
defaults: &defaults
|
2
|
-
jp2_recipes:
|
3
|
-
# note that these aren't real recipes, just enough to test configuration options
|
4
|
-
myrecipe_color: >
|
5
|
-
-rate 2.4
|
6
|
-
-jp2_space sRGB
|
7
|
-
Stiles=\{1024,1024\}
|
8
|
-
myrecipe_grey: >
|
9
|
-
-rate 2.4
|
10
|
-
-jp2_space sLUM
|
11
|
-
Stiles=\{1024,1024\}
|
12
|
-
|
13
|
-
development:
|
14
|
-
<<: *defaults
|
15
|
-
|
16
|
-
test:
|
17
|
-
<<: *defaults
|
18
|
-
|
19
|
-
production:
|
20
|
-
<<: *defaults
|