Class: DerivativeRodeo::Services::PdfSplitter::TiffPage

Inherits:
Base
  • Object
show all
Defined in:
lib/derivative_rodeo/services/pdf_splitter/tiff_page.rb

Overview

The purpose of this class is to split the PDF into constituent tiff files.

Instance Attribute Summary

Attributes inherited from Base

#ghost_script_output_file_template

Instance Method Summary collapse

Methods inherited from Base

#each, #initialize, #invalid_pdf?

Constructor Details

This class inherits a constructor from DerivativeRodeo::Services::PdfSplitter::Base

Instance Method Details

#color_bpc(color, bpc) ⇒ Object



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

def color_bpc(color, bpc)
  return unless color == 'gray'

  # CCITT Group 4 Black and White, if applicable:
  if bpc == 1
    self.compression = 'g4'
    'tiffg4'
  elsif bpc > 1
    # 8 Bit Grayscale, if applicable:
    'tiffgray'
  end
end

#colordevice(channels, bpc) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/derivative_rodeo/services/pdf_splitter/tiff_page.rb', line 42

def colordevice(channels, bpc)
  bits = bpc * channels
  # will be either 8bpc/16bpd color TIFF,
  #   with any CMYK source transformed to 8bpc RBG
  bits = 24 unless [24, 48].include? bits
  "tiff#{bits}nc"
end

#gsdeviceString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String)


16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/derivative_rodeo/services/pdf_splitter/tiff_page.rb', line 16

def gsdevice
  return @gsdevice if defined?(@gsdevice)

  color = pdf_pages_summary.color_description
  channels = pdf_pages_summary.channels
  bpc = pdf_pages_summary.bits_per_channel

  @gsdevice = color_bpc(color, bpc)

  # otherwise color:
  @gsdevice ||= colordevice(channels, bpc)
end