Class: Riiif::VipsTransformer

Inherits:
AbstractTransformer show all
Includes:
ActiveSupport::Benchmarkable
Defined in:
app/transformers/riiif/vips_transformer.rb

Instance Attribute Summary collapse

Attributes inherited from AbstractTransformer

#image_info, #transformation

Instance Method Summary collapse

Methods inherited from AbstractTransformer

#command_builder, transform

Constructor Details

#initialize(path, image_info, transformation, compression: 85, subsample: true, strip_metadata: true) ⇒ VipsTransformer

Returns a new instance of VipsTransformer.

Parameters:

  • path (String)

    The path of the source image file

  • image_info (ImageInformation)

    information about the source

  • transformation (IIIF::Image::Transformation)


15
16
17
18
19
20
21
# File 'app/transformers/riiif/vips_transformer.rb', line 15

def initialize(path, image_info, transformation, compression: 85, subsample: true, strip_metadata: true)
  super(path, image_info, transformation)
  @image = ::Vips::Image.new_from_file(path.to_s)
  @compression = compression
  @subsample = subsample
  @strip_metadata = 
end

Instance Attribute Details

#compressionObject (readonly)

Returns the value of attribute compression.



23
24
25
# File 'app/transformers/riiif/vips_transformer.rb', line 23

def compression
  @compression
end

#imageObject (readonly)

Returns the value of attribute image.



23
24
25
# File 'app/transformers/riiif/vips_transformer.rb', line 23

def image
  @image
end

#pathObject (readonly)

Returns the value of attribute path.



23
24
25
# File 'app/transformers/riiif/vips_transformer.rb', line 23

def path
  @path
end

#strip_metadataObject (readonly)

Returns the value of attribute strip_metadata.



23
24
25
# File 'app/transformers/riiif/vips_transformer.rb', line 23

def 
  @strip_metadata
end

#subsampleObject (readonly)

Returns the value of attribute subsample.



23
24
25
# File 'app/transformers/riiif/vips_transformer.rb', line 23

def subsample
  @subsample
end

Instance Method Details

#transformString

Returns all the image data.

Returns:

  • (String)

    all the image data



26
27
28
29
30
# File 'app/transformers/riiif/vips_transformer.rb', line 26

def transform
  benchmark("Riiif transformed image using vips") do
    transform_image.write_to_buffer(".#{format}#{format_options}")
  end
end