Class: Riiif::File
- Inherits:
-
Object
- Object
- Riiif::File
- Defined in:
- app/models/riiif/file.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
-
.info_extractor_class ⇒ Object
TODO: add alternative that uses kdu_jp2info.
Instance Method Summary collapse
-
#extract(transformation, image_info = info) ⇒ String
The processed image data.
- #info ⇒ Object
- #info_extractor ⇒ Object
-
#initialize(input_path, tempfile = nil) ⇒ File
constructor
A new instance of File.
- #transformer ⇒ Object
Constructor Details
#initialize(input_path, tempfile = nil) ⇒ File
Returns a new instance of File.
17 18 19 20 |
# File 'app/models/riiif/file.rb', line 17 def initialize(input_path, tempfile = nil) @path = input_path @tempfile = tempfile # ensures that the tempfile will stick around until this file is garbage collected. end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'app/models/riiif/file.rb', line 3 def path @path end |
Class Method Details
.info_extractor_class ⇒ Object
TODO: add alternative that uses kdu_jp2info
8 9 10 11 12 13 14 |
# File 'app/models/riiif/file.rb', line 8 def self.info_extractor_class if Riiif.use_vips? VipsInfoExtractor else ImageMagickInfoExtractor end end |
Instance Method Details
#extract(transformation, image_info = info) ⇒ String
Returns the processed image data.
25 26 27 |
# File 'app/models/riiif/file.rb', line 25 def extract(transformation, image_info = info) transformer.transform(path, image_info, transformation) end |
#info ⇒ Object
39 40 41 |
# File 'app/models/riiif/file.rb', line 39 def info @info ||= info_extractor.extract end |
#info_extractor ⇒ Object
43 44 45 |
# File 'app/models/riiif/file.rb', line 43 def info_extractor @info_extractor ||= info_extractor_class.new(path) end |
#transformer ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'app/models/riiif/file.rb', line 29 def transformer if Riiif.use_vips? VipsTransformer elsif Riiif.kakadu_enabled? && path.ends_with?('.jp2') KakaduTransformer else ImagemagickTransformer end end |