Class: Riiif::ImageMagickInfoExtractor

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

Overview

Get information using imagemagick to interrogate the file

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ ImageMagickInfoExtractor

Returns a new instance of ImageMagickInfoExtractor.



8
9
10
# File 'app/services/riiif/image_magick_info_extractor.rb', line 8

def initialize(path)
  @path = path
end

Instance Method Details

#extractObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/services/riiif/image_magick_info_extractor.rb', line 12

def extract
  height, width, format, channels = Riiif::CommandRunner.execute(
    "#{external_command} -format '%h %w %m %[channels]' '#{@path}[0]'"
  ).split(' ')

  {
    height: Integer(height),
    width: Integer(width),
    format: format,
    channels: channels
  }
end