Class: IiifPrint::PDFDerivativeService
- Inherits:
-
BaseDerivativeService
- Object
- BaseDerivativeService
- IiifPrint::PDFDerivativeService
- Defined in:
- lib/iiif_print/pdf_derivative_service.rb
Constant Summary collapse
- GRAY_PDF_CMD =
PDF (JPEG, 8 bit grayscale), 150ppi
'convert %<source_file>s ' \ '-resize 1800 -density 150 ' \ '-depth 8 -colorspace Gray ' \ '-compress jpeg %<out_file>s'.freeze
- COLOR_PDF_CMD =
sRBG color PDF (JPEG, 8 bits per channel), 150ppi
'convert %<source_file>s ' \ '-resize 1800 -density 150 ' \ '-depth 8 ' \ '-compress jpeg %<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) ⇒ PDFDerivativeService
constructor
A new instance of PDFDerivativeService.
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) ⇒ PDFDerivativeService
Returns a new instance of PDFDerivativeService.
19 20 21 |
# File 'lib/iiif_print/pdf_derivative_service.rb', line 19 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.
25 26 27 28 29 30 |
# File 'lib/iiif_print/pdf_derivative_service.rb', line 25 def convert_cmd template = use_color? ? COLOR_PDF_CMD : GRAY_PDF_CMD 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
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/iiif_print/pdf_derivative_service.rb', line 32 def create_derivatives(filename) # Base class takes care of loading @source_path, @dest_path super(filename) # no creation if pdf master return if mime_type == 'application/pdf' # Get and run conversion command return jp2_convert if mime_type == 'image/jp2' im_convert end |