Sha256: c2ab9bc280c057fb50041e7ebef3438799c7396b774d9c76d6dd00f58d7cb174
Contents?: true
Size: 1.62 KB
Versions: 2
Compression:
Stored size: 1.62 KB
Contents
require 'open3' module IiifPrint class TIFFDerivativeService < BaseDerivativeService self.target_extension = 'tiff'.freeze # For imagemagick commands, the output type is determined by the # output file's extension. # TIFF (LZW, 8 bit grayscale) GRAY_CMD = 'convert %<source_file>s ' \ '-depth 8 -colorspace Gray ' \ '-compress lzw %<out_file>s'.freeze # Monochrome one-bit black/white TIFF, Group 4 compressed: MONO_CMD = 'convert %<source_file>s ' \ '-depth 1 -monochrome -compress Group4 -type bilevel ' \ '%<out_file>s'.freeze # sRBG color TIFF (8 bits per channel, lzw) COLOR_CMD = 'convert %<source_file>s ' \ '-depth 24 ' \ '-compress lzw %<out_file>s'.freeze def initialize(file_set) super(file_set) end # Get conversion command; command varies on whether or not we have # JP2 source, and whether we have color or grayscale material. 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? format(template, source_file: source_path, out_file: @dest_path) end 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 end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
iiif_print-1.1.0 | lib/iiif_print/tiff_derivative_service.rb |
iiif_print-1.0.0 | lib/iiif_print/tiff_derivative_service.rb |