Class: Hydra::Derivatives::Image
Instance Attribute Summary
Attributes inherited from Processor
#directives, #object, #output_file_service, #source_file_service, #source_name
Instance Method Summary
collapse
Methods inherited from Processor
#initialize, #output_file, #output_file_id, #source_file
Instance Method Details
#output_filename_for(name, opts = {}) ⇒ Object
29
30
31
32
33
34
|
# File 'lib/hydra/derivatives/image.rb', line 29
def output_filename_for(name, opts = {})
if opts.has_key? :datastream
Deprecation.warn Hydra::Derivatives::Image, 'The :datastream option is deprecated and will be removed in a future release.'
end
opts.fetch(:datastream, output_file_id(name))
end
|
#process ⇒ Object
8
9
10
|
# File 'lib/hydra/derivatives/image.rb', line 8
def process
timeout ? process_with_timeout : process_without_timeout
end
|
#process_with_timeout ⇒ Object
12
13
14
15
16
17
18
|
# File 'lib/hydra/derivatives/image.rb', line 12
def process_with_timeout
status = Timeout::timeout(timeout) do
process_without_timeout
end
rescue Timeout::Error => ex
raise Hydra::Derivatives::TimeoutError, "Unable to process image derivative\nThe command took longer than #{timeout} seconds to execute"
end
|
#process_without_timeout ⇒ Object
20
21
22
23
24
25
26
27
|
# File 'lib/hydra/derivatives/image.rb', line 20
def process_without_timeout
directives.each do |name, args|
opts = args.kind_of?(Hash) ? args : {size: args}
format = opts.fetch(:format, 'png')
destination_name = output_filename_for(name, opts)
create_resized_image(destination_name, opts[:size], format)
end
end
|