Class: Riiif::KakaduCommandFactory

Inherits:
Object
  • Object
show all
Defined in:
app/services/riiif/kakadu_command_factory.rb

Overview

Builds a command to run a transformation using Kakadu

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, info, transformation) ⇒ KakaduCommandFactory

A helper method to instantiate and invoke build

Parameters:

  • path (String)

    the location of the file

  • info (ImageInformation)

    information about the source

  • transformation (Transformation)


13
14
15
16
17
# File 'app/services/riiif/kakadu_command_factory.rb', line 13

def initialize(path, info, transformation)
  @path = path
  @info = info
  @transformation = transformation
end

Instance Attribute Details

#infoObject (readonly)

Returns the value of attribute info.



19
20
21
# File 'app/services/riiif/kakadu_command_factory.rb', line 19

def info
  @info
end

#pathObject (readonly)

Returns the value of attribute path.



19
20
21
# File 'app/services/riiif/kakadu_command_factory.rb', line 19

def path
  @path
end

#transformationObject (readonly)

Returns the value of attribute transformation.



19
20
21
# File 'app/services/riiif/kakadu_command_factory.rb', line 19

def transformation
  @transformation
end

Instance Method Details

#command(tmp_file) ⇒ String

Returns a command for running kdu_expand to produce the requested output.

Parameters:

  • tmp_file (String)

    the path to the temporary file

Returns:

  • (String)

    a command for running kdu_expand to produce the requested output



23
24
25
# File 'app/services/riiif/kakadu_command_factory.rb', line 23

def command(tmp_file)
  [external_command, quiet, input, threads, region, reduce, output(tmp_file)].join
end

#reduction_factorObject



27
28
29
# File 'app/services/riiif/kakadu_command_factory.rb', line 27

def reduction_factor
  @reduction_factor ||= Resize.new(transformation.size, info).reduction_factor
end