Class: IiifPrint::ImageTool

Inherits:
Object
  • Object
show all
Defined in:
lib/iiif_print/image_tool.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ ImageTool

Returns a new instance of ImageTool.



8
9
10
11
# File 'lib/iiif_print/image_tool.rb', line 8

def initialize(path)
  @path = path
  @metadata = nil
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



6
7
8
# File 'lib/iiif_print/image_tool.rb', line 6

def path
  @path
end

Instance Method Details

#convert(destination, monochrome = false) ⇒ Object

Convert source image to image at destination path, inferring file type

from destination file extension.  In case of JP2 files, create
intermediate file using OpenJPEG 2000 that ImageMagick can use.
Only outputs monochrome output if monochrome is true, destination
format is TIFF.

Parameters:

  • destination (String)

    Path to output / destination file

  • monochrome (Boolean) (defaults to: false)

    true if monochrome output, otherwise false



32
33
34
35
36
# File 'lib/iiif_print/image_tool.rb', line 32

def convert(destination, monochrome = false)
  raise 'JP2 output not yet supported' if destination.end_with?('jp2')
  return convert_image(jp2_to_tiff(@path), destination, monochrome) if jp2?
  convert_image(@path, destination, monochrome)
end

#metadataHash

Returns hash with following symbol keys, and respectively typed String and/or Integer values. :width, :height — both in Integer px units :color — (String enumerated from ‘gray’, ‘monochrome’, ‘color’) :num_components - Integer, number of channels :bits_per_component — Integer, bits per channel (e.g. 8 vs. 1) :content_type — RFC 2045 MIME type.

Returns:

  • (Hash)

    hash with following symbol keys, and respectively typed String and/or Integer values. :width, :height — both in Integer px units :color — (String enumerated from ‘gray’, ‘monochrome’, ‘color’) :num_components - Integer, number of channels :bits_per_component — Integer, bits per channel (e.g. 8 vs. 1) :content_type — RFC 2045 MIME type



20
21
22
23
# File 'lib/iiif_print/image_tool.rb', line 20

def 
  return @metadata unless @metadata.nil?
  @metadata = jp2? ?  : 
end