Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
name: Run CI

on:
push:
branches:
- $default-branch

pull_request:
on: push

jobs:
# Run tests
Expand Down Expand Up @@ -34,5 +29,8 @@ jobs:
- name: Run standard
run: docker compose run --rm test bundle exec standardrb

- name: Run tests
- name: Run minitest tests
run: docker compose run --rm test

- name: Run rspec tests
run: docker compose run --rm test bundle exec rspec
13 changes: 6 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@ ARG FEED_VERSION=feed_v1.14.1
RUN gem install bundler

WORKDIR /tmp
RUN wget https://kakadusoftware.com/wp-content/uploads/$KAKADU_FILE
RUN unzip -j -d kakadu $KAKADU_FILE
RUN mv /tmp/kakadu/*.so /usr/local/lib
RUN mv /tmp/kakadu/kdu* /usr/local/bin
RUN echo "/usr/local/lib" > /etc/ld.so.conf.d/kakadu.conf
RUN ldconfig

RUN curl https://apt.lib.umich.edu/mlibrary-archive-keyring.gpg -o /etc/apt/keyrings/mlibrary-archive-keyring.gpg
RUN echo "deb [signed-by=/etc/apt/keyrings/mlibrary-archive-keyring.gpg] https://apt.lib.umich.edu bookworm main" > /etc/apt/sources.list.d/mlibrary.list

RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends \
libtiff-tools\
exiftool \
netpbm
netpbm\
grokj2k


ENV APP_PATH=/usr/src/app
RUN mkdir -p $APP_PATH
Expand Down
24 changes: 8 additions & 16 deletions lib/compressor.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
require "tiff"

module Kakadu
module Grok
JP2_LEVEL_MIN = 5
JP2_LAYERS = 8
JP2_ORDER = "RLCP"
JP2_USE_SOP = "yes"
JP2_USE_EPH = "yes"
JP2_MODES = '"RESET|RESTART|CAUSAL|ERTERM|SEGMARK"'
JP2_SLOPE = 42_988

# Settings for grk_compress recommended from Roger Espinosa. "-slope"
# is a VBR compression mode; the value of 42988 corresponds to pre-6.4
# slope of 51180, the current (as of 5/6/2011) recommended setting for
# Google digifeeds.
def self.compress(source, destination, tiffinfo)
clevels = jp2_clevels(tiffinfo)
cmd = "kdu_compress -quiet -i #{source} -o #{destination}" \
" 'Clevels=#{clevels}'" \
" 'Clayers=#{JP2_LAYERS}'" \
" 'Corder=#{JP2_ORDER}'" \
" 'Cuse_sop=#{JP2_USE_SOP}'" \
" 'Cuse_eph=#{JP2_USE_EPH}'" \
" Cmodes=#{JP2_MODES}" \
" -no_weights -slope '#{JP2_SLOPE}'"
cmd = "grk_compress -i \"#{source}\" -o \"#{destination}\" -p RLCP -n #{clevels} -S -E -M 62 -I -q 32"
status = Command.new(cmd).run
LogEntry.info(command: cmd, time: status[:time])
end
Expand Down Expand Up @@ -213,7 +205,7 @@ def compression_type
"JP2"
end

def run(compression_tool = Kakadu)
def run(compression_tool = Grok)
# We don't want any XMP metadata to be copied over on its own. If
# it's been a while since we last ran exiftool, this might take a sec.
log_it ExifTool.remove_tiff_metadata(source: image_file.path, destination: sparse_path)
Expand Down
2 changes: 1 addition & 1 deletion lib/stage/dlxs_compressor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def pgm_to_bitonal(dir)

# Expand existing jp2 into tif in temp directory
def expand_jp2(src, dest)
cmd = "kdu_expand -quiet -i '#{src}' -o '#{dest}'"
cmd = "grk_decompress -i '#{src}' -o '#{dest}'"
status = Command.new(cmd).run
log cmd, status[:time]
end
Expand Down
2 changes: 1 addition & 1 deletion spec/compressor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def tiffinfo(path)

it "runs the compression tool" do
compressor.run
expect(log.entries).to include(match("kdu_compress"))
expect(log.entries).to include(match("grk_compress"))
end

it "copies original metadata to the jpeg2000" do
Expand Down