Class: IiifPrint::ImageTool
- Inherits:
-
Object
- Object
- IiifPrint::ImageTool
- Defined in:
- lib/iiif_print/image_tool.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
-
#convert(destination, monochrome = false) ⇒ Object
Convert source image to image at destination path, inferring file type from destination file extension.
-
#initialize(path) ⇒ ImageTool
constructor
A new instance of ImageTool.
-
#metadata ⇒ Hash
Hash with following symbol keys, and respectively typed String and/or Integer values.
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
#path ⇒ Object
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.
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 |
#metadata ⇒ Hash
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.
20 21 22 23 |
# File 'lib/iiif_print/image_tool.rb', line 20 def return @metadata unless @metadata.nil? @metadata = jp2? ? : end |