Class: Libis::Format::Converter::Jp2Converter
- Defined in:
- lib/libis/format/converter/jp2_converter.rb
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
- #codeblock_size(width = 6, height = nil) ⇒ Object
- #color_xform(flag = true) ⇒ Object
- #convert(source, target, format, opts = {}) ⇒ Object
- #error_resilience(value = :ALL) ⇒ Object
-
#initialize ⇒ Jp2Converter
constructor
A new instance of Jp2Converter.
- #j2kdriver(_) ⇒ Object
- #lossless(value = true) ⇒ Object
- #progression_order(value = 'RLCP') ⇒ Object
- #tile_size(width = 1024, height = nil) ⇒ Object
Methods inherited from Base
category, #check_file_exist, inherited, using_temp, #using_temp
Constructor Details
#initialize ⇒ Jp2Converter
Returns a new instance of Jp2Converter.
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/libis/format/converter/jp2_converter.rb', line 22 def initialize super @options = { color_xform: false, error_resilience: :ALL, lossless: true, progression_order: 'RLCP', tile_size: [1024, 1024], codeblock_size: [6, 6], } end |
Class Method Details
.input_types ⇒ Object
13 14 15 |
# File 'lib/libis/format/converter/jp2_converter.rb', line 13 def self.input_types [:TIFF, :JPG, :PNG, :BMP, :GIF, :PDF] end |
.output_types(format = nil) ⇒ Object
17 18 19 20 |
# File 'lib/libis/format/converter/jp2_converter.rb', line 17 def self.output_types(format = nil) return [] unless input_types.include?(format) if format [:JP2] end |
Instance Method Details
#codeblock_size(width = 6, height = nil) ⇒ Object
59 60 61 62 |
# File 'lib/libis/format/converter/jp2_converter.rb', line 59 def codeblock_size(width = 6, height = nil) height ||= width @options[:codeblock_size] = [height, width] end |
#color_xform(flag = true) ⇒ Object
38 39 40 |
# File 'lib/libis/format/converter/jp2_converter.rb', line 38 def color_xform(flag = true) @options[:color_xform] = flag end |
#convert(source, target, format, opts = {}) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/libis/format/converter/jp2_converter.rb', line 64 def convert(source, target, format, opts = {}) super FileUtils.mkpath(File.dirname(target)) = [] @options.each do |key, value| case key when :color_xform << '--set-output-j2k-color-xform' << (value ? 'YES' : 'NO') when :error_resilience << '--set-output-j2k-error-resilience' << value.to_s when :lossless if value << '--set-output-j2k-xform' << 'R53' << '5' << '--set-output-j2k-ratio' << '0' else << '--set-output-j2k-xform' << 'I97' << '--set-output-j2k-psnr' << '46' end when :progression_order << '--set-output-j2k-progression-order' << value.to_s when :tile_size << '--set-output-j2k-tile-size' << value[0].to_s << value[1].to_s when :codeblock_size << '--set-output-j2k-codeblock-size' << value[0].to_s << value[1].to_s else #do nothing end end Libis::Tools::Command.run( Libis::Format::Config[:j2k_cmd], '--input-file-name', source, '--set-output-type', 'JP2', *, '--output-file-name', target, ) target end |
#error_resilience(value = :ALL) ⇒ Object
42 43 44 |
# File 'lib/libis/format/converter/jp2_converter.rb', line 42 def error_resilience(value = :ALL) @options[:error_resilience] = value end |
#j2kdriver(_) ⇒ Object
34 35 36 |
# File 'lib/libis/format/converter/jp2_converter.rb', line 34 def j2kdriver(_) #force usage of this converter end |
#lossless(value = true) ⇒ Object
46 47 48 |
# File 'lib/libis/format/converter/jp2_converter.rb', line 46 def lossless(value = true) @options[:lossless] = value end |
#progression_order(value = 'RLCP') ⇒ Object
50 51 52 |
# File 'lib/libis/format/converter/jp2_converter.rb', line 50 def progression_order(value = 'RLCP') @options[:progression_order] = value end |
#tile_size(width = 1024, height = nil) ⇒ Object
54 55 56 57 |
# File 'lib/libis/format/converter/jp2_converter.rb', line 54 def tile_size(width = 1024, height = nil) height ||= width @options[:tile_size] = [width, height] end |