|
1 | 1 | require "tiff" |
2 | 2 |
|
3 | | -module Kakadu |
| 3 | +module Grok |
4 | 4 | JP2_LEVEL_MIN = 5 |
5 | | - JP2_LAYERS = 8 |
6 | | - JP2_ORDER = "RLCP" |
7 | | - JP2_USE_SOP = "yes" |
8 | | - JP2_USE_EPH = "yes" |
9 | | - JP2_MODES = '"RESET|RESTART|CAUSAL|ERTERM|SEGMARK"' |
10 | | - JP2_SLOPE = 42_988 |
| 5 | + |
| 6 | + # Settings for grk_compress recommended from Roger Espinosa. "-slope" |
| 7 | + # is a VBR compression mode; the value of 42988 corresponds to pre-6.4 |
| 8 | + # slope of 51180, the current (as of 5/6/2011) recommended setting for |
| 9 | + # Google digifeeds. |
11 | 10 | def self.compress(source, destination, tiffinfo) |
12 | 11 | clevels = jp2_clevels(tiffinfo) |
13 | | - cmd = "kdu_compress -quiet -i #{source} -o #{destination}" \ |
14 | | - " 'Clevels=#{clevels}'" \ |
15 | | - " 'Clayers=#{JP2_LAYERS}'" \ |
16 | | - " 'Corder=#{JP2_ORDER}'" \ |
17 | | - " 'Cuse_sop=#{JP2_USE_SOP}'" \ |
18 | | - " 'Cuse_eph=#{JP2_USE_EPH}'" \ |
19 | | - " Cmodes=#{JP2_MODES}" \ |
20 | | - " -no_weights -slope '#{JP2_SLOPE}'" |
| 12 | + cmd = "grk_compress -i \"#{source}\" -o \"#{destination}\" -p RLCP -n #{clevels} -S -E -M 62 -I -q 32" |
21 | 13 | status = Command.new(cmd).run |
22 | 14 | LogEntry.info(command: cmd, time: status[:time]) |
23 | 15 | end |
@@ -213,7 +205,7 @@ def compression_type |
213 | 205 | "JP2" |
214 | 206 | end |
215 | 207 |
|
216 | | - def run(compression_tool = Kakadu) |
| 208 | + def run(compression_tool = Grok) |
217 | 209 | # We don't want any XMP metadata to be copied over on its own. If |
218 | 210 | # it's been a while since we last ran exiftool, this might take a sec. |
219 | 211 | log_it ExifTool.remove_tiff_metadata(source: image_file.path, destination: sparse_path) |
|
0 commit comments