Class: IiifPrint::TIFFDerivativeService
- Inherits:
-
BaseDerivativeService
- Object
- BaseDerivativeService
- IiifPrint::TIFFDerivativeService
- Defined in:
- lib/iiif_print/tiff_derivative_service.rb
Constant Summary collapse
- GRAY_CMD =
For imagemagick commands, the output type is determined by the
output file's extension.
TIFF (LZW, 8 bit grayscale)
'convert %<source_file>s ' \ '-depth 8 -colorspace Gray ' \ '-compress lzw %<out_file>s'.freeze
- MONO_CMD =
Monochrome one-bit black/white TIFF, Group 4 compressed:
'convert %<source_file>s ' \ '-depth 1 -monochrome -compress Group4 -type bilevel ' \ '%<out_file>s'.freeze
- COLOR_CMD =
sRBG color TIFF (8 bits per channel, lzw)
'convert %<source_file>s ' \ '-depth 24 ' \ '-compress lzw %<out_file>s'.freeze
Instance Attribute Summary
Attributes inherited from BaseDerivativeService
Instance Method Summary collapse
-
#convert_cmd ⇒ Object
Get conversion command; command varies on whether or not we have JP2 source, and whether we have color or grayscale material.
- #create_derivatives(filename) ⇒ Object
-
#initialize(file_set) ⇒ TIFFDerivativeService
constructor
A new instance of TIFFDerivativeService.
Methods inherited from BaseDerivativeService
#cleanup_derivatives, #derivative_path_factory, #identify, #im_convert, #jp2_convert, #jp2_to_intermediate, #load_destpath, #mime_type, #mime_type_for, #one_bit?, #prepare_path, #use_color?, #valid?
Constructor Details
#initialize(file_set) ⇒ TIFFDerivativeService
Returns a new instance of TIFFDerivativeService.
24 25 26 |
# File 'lib/iiif_print/tiff_derivative_service.rb', line 24 def initialize(file_set) super(file_set) end |
Instance Method Details
#convert_cmd ⇒ Object
Get conversion command; command varies on whether or not we have
JP2 source, and whether we have color or grayscale material.
30 31 32 33 34 35 36 37 38 |
# File 'lib/iiif_print/tiff_derivative_service.rb', line 30 def convert_cmd source_path = @source_path source_path += '[0]' if @source_path.ends_with?('pdf') template = use_color? ? COLOR_CMD : GRAY_CMD template = MONO_CMD if one_bit? data = format(template, source_file: source_path, out_file: @dest_path) IiifPrint.copy_derivatives_from_data_store(stream: data, directives: { url: file_set.id.to_s, container: 'service_file', mime_type: mime_type_for(target_extension) }) data end |
#create_derivatives(filename) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/iiif_print/tiff_derivative_service.rb', line 40 def create_derivatives(filename) # Base class takes care of loading @source_path, @dest_path super(filename) # no creation of TIFF deriviative if primary is TIFF return if mime_type == 'image/tiff' return jp2_convert if mime_type == 'image/jp2' # Otherwise, get, run imagemagick command to convert im_convert end |