Class: DerivativeRodeo::Services::ImageIdentifyService

Inherits:
BaseService
  • Object
show all
Defined in:
lib/derivative_rodeo/services/image_identify_service.rb

Overview

This module is responsible for extracting technical_metadata for a given path.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ ImageIdentifyService

Returns a new instance of ImageIdentifyService.



21
22
23
24
25
26
# File 'lib/derivative_rodeo/services/image_identify_service.rb', line 21

def initialize(path)
  super()
  @path = path
  # The first 23 characters of a file contains the magic.
  @initial_file_contents = File.read(@path, 23, 0)
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



27
28
29
# File 'lib/derivative_rodeo/services/image_identify_service.rb', line 27

def path
  @path
end

Class Method Details

.technical_metadata_for(path:) ⇒ Derivative::Rodeo::TechnicalMetadata

Parameters:

  • path (String)

Returns:

  • (Derivative::Rodeo::TechnicalMetadata)


17
18
19
# File 'lib/derivative_rodeo/services/image_identify_service.rb', line 17

def self.(path:)
  new(path).
end

Instance Method Details

#technical_metadataObject

Return metadata by means of imagemagick identify



30
31
32
33
34
35
36
37
38
39
# File 'lib/derivative_rodeo/services/image_identify_service.rb', line 30

def 
   = TechnicalMetadata.new
  lines = im_identify
  width, height = im_identify_geometry(lines)
  .width = width
  .height = height
  .content_type = im_mime(lines)
  populate_im_color!(lines, )
  
end