Class: Riiif::File

Inherits:
Object
  • Object
show all
Defined in:
app/models/riiif/file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input_path, tempfile = nil) ⇒ File

Returns a new instance of File.

Parameters:

  • input_path (String)

    The location of an image file



10
11
12
13
# File 'app/models/riiif/file.rb', line 10

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

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'app/models/riiif/file.rb', line 3

def path
  @path
end

Instance Method Details

#extract(transformation, image_info = info) ⇒ String

Returns the processed image data.

Parameters:

  • transformation (Transformation)
  • image_info (ImageInformation) (defaults to: info)

Returns:

  • (String)

    the processed image data



18
19
20
# File 'app/models/riiif/file.rb', line 18

def extract(transformation, image_info = info)
  transformer.transform(path, image_info, transformation)
end

#infoObject



30
31
32
# File 'app/models/riiif/file.rb', line 30

def info
  @info ||= info_extractor.extract
end

#info_extractorObject



34
35
36
# File 'app/models/riiif/file.rb', line 34

def info_extractor
  @info_extractor ||= info_extractor_class.new(path)
end

#transformerObject



22
23
24
25
26
27
28
# File 'app/models/riiif/file.rb', line 22

def transformer
  if Riiif.kakadu_enabled? && path.ends_with?('.jp2')
    KakaduTransformer
  else
    ImagemagickTransformer
  end
end