Class: Riiif::ImagemagickCommandFactory

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

Overview

Builds a command to run a transformation using Imagemagick

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, info, transformation, compression: 85, sampling_factor: '4:2:0', strip_metadata: true) ⇒ ImagemagickCommandFactory

A helper method to instantiate and invoke build

Parameters:

  • path (String)

    the location of the file

  • info (ImageInformation)

    information about the source

  • transformation (Transformation)
  • compression (Integer) (defaults to: 85)

    (85) the compression level to use (set 0 for no compression)

  • sampling_factor (String) (defaults to: '4:2:0')

    (“4:2:0”) the chroma sample factor (set 0 for no compression)

  • strip_metadata (Boolean) (defaults to: true)

    (true) do we want to strip EXIF tags?



17
18
19
20
21
22
23
24
# File 'app/services/riiif/imagemagick_command_factory.rb', line 17

def initialize(path, info, transformation, compression: 85, sampling_factor: '4:2:0', strip_metadata: true)
  @path = path
  @info = info
  @transformation = transformation
  @compression = compression
  @sampling_factor = sampling_factor
  @strip_metadata = 
end

Instance Attribute Details

#compressionObject (readonly)

Returns the value of attribute compression.



26
27
28
# File 'app/services/riiif/imagemagick_command_factory.rb', line 26

def compression
  @compression
end

#infoObject (readonly)

Returns the value of attribute info.



26
27
28
# File 'app/services/riiif/imagemagick_command_factory.rb', line 26

def info
  @info
end

#pathObject (readonly)

Returns the value of attribute path.



26
27
28
# File 'app/services/riiif/imagemagick_command_factory.rb', line 26

def path
  @path
end

#sampling_factorObject (readonly)

Returns the value of attribute sampling_factor.



26
27
28
# File 'app/services/riiif/imagemagick_command_factory.rb', line 26

def sampling_factor
  @sampling_factor
end

#strip_metadataObject (readonly)

Returns the value of attribute strip_metadata.



26
27
28
# File 'app/services/riiif/imagemagick_command_factory.rb', line 26

def 
  @strip_metadata
end

#transformationObject (readonly)

Returns the value of attribute transformation.



26
27
28
# File 'app/services/riiif/imagemagick_command_factory.rb', line 26

def transformation
  @transformation
end

Instance Method Details

#commandString

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

Returns:

  • (String)

    a command for running imagemagick to produce the requested output



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/services/riiif/imagemagick_command_factory.rb', line 29

def command
  [
    external_command,
    crop,
    size,
    rotation,
    colorspace,
    quality,
    sampling,
    ,
    alpha_channel,
    input,
    output
  ].join
end

#reduction_factorObject



45
46
47
# File 'app/services/riiif/imagemagick_command_factory.rb', line 45

def reduction_factor
  nil
end