iiif_print 3.2.3 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 63e30799cf45be6cb719486414c6ce6ffaec6742823fad504b37777891bec6a7
4
- data.tar.gz: 5c33a0f762a1ee6d74b160704f244bc0447fdabce3670878a3973e802dc01446
3
+ metadata.gz: 113eb0be5d5b6783a1c81c4b5cb9ef3c1d907f20ef86cdc24e3c3d53dcc61b15
4
+ data.tar.gz: 40810de9ff823b85a69b849aa6876eb210b68d1a0908d122b44ef2244f45f865
5
5
  SHA512:
6
- metadata.gz: 977f1e11d02f47a6ee5fd31bf42f4574179529c71e534ee175cf2d947a0f3d6684a553da7f2f68ea205f681ce8fc116b377a2de51f39c138218f6c7f268d423b
7
- data.tar.gz: 87c6d0397b7eb0c96f678e1023ce22820b82f3c543b3126b18778f1027c80b27d6a0c065a64c3dfaa3a70490af039d4d760c1f3eb1b0ab673c2af7bd8afd0790
6
+ metadata.gz: bdf04fd441bdd4fcf46380ef1f7958b28e284a826aec246c111fd6d4bba7f16db6aad80d1420a986fb8081798112f8befdad44fb4d6fc6338a458eb605d6a7a2
7
+ data.tar.gz: 3501966b7a60712c27995d3cf079510d5e52bbaf1733b944e855c613e506b3cf9d85bf15ffcc599a6366b86fb62ae57c7aa710064e4802be217bfe4da86ebc6c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /app/samvera/hyrax-webapp
3
3
  specs:
4
- iiif_print (3.2.3)
4
+ iiif_print (3.3.0)
5
5
  blacklight_iiif_search (>= 1.0, < 3.0)
6
6
  derivative-rodeo (~> 0.5)
7
7
  hyrax (>= 2.5, < 6)
data/README.md CHANGED
@@ -198,6 +198,10 @@ IiifPrint.config do |config|
198
198
  # Add configurable solr field key for searching, default key is: 'human_readable_type_sim' if
199
199
  # another key is used, make sure to adjust the config.excluded_model_name_solr_field_values to match
200
200
  config.excluded_model_name_solr_field_key = 'some_solr_field_key'
201
+
202
+ # ImageMagick options for the image Tesseract reads, in place of the default one-bit dithered TIFF.
203
+ # A light blur on grayscale keeps halftone photographs from turning into specks Tesseract reads for hours.
204
+ config.ocr_preprocess_options = '-colorspace gray -blur 0x1'
201
205
  end
202
206
  ```
203
207
 
@@ -188,6 +188,15 @@ module IiifPrint
188
188
  @additional_tesseract_options || ""
189
189
  end
190
190
 
191
+ ##
192
+ # ImageMagick options for the image Tesseract reads, in place of the
193
+ # default one-bit dithered TIFF. Dithering turns halftone photographs
194
+ # into specks Tesseract can spend hours reading as characters; a light
195
+ # blur on grayscale ("-colorspace gray -blur 0x1") avoids that.
196
+ #
197
+ # @return [String, nil]
198
+ attr_accessor :ocr_preprocess_options
199
+
191
200
  attr_writer :uv_config_path
192
201
  ##
193
202
  # According to https://github.com/samvera/hyrax/wiki/Hyrax-Management-Guide#universal-viewer-config
@@ -29,18 +29,21 @@ module IiifPrint
29
29
  # format is TIFF.
30
30
  # @param destination [String] Path to output / destination file
31
31
  # @param monochrome [Boolean] true if monochrome output, otherwise false
32
- def convert(destination, monochrome = false)
32
+ # @param options [String, nil] ImageMagick options for the output; when
33
+ # given, they replace the monochrome options
34
+ def convert(destination, monochrome = false, options: nil)
33
35
  raise 'JP2 output not yet supported' if destination.end_with?('jp2')
34
- return convert_image(jp2_to_tiff(@path), destination, monochrome) if jp2?
35
- convert_image(@path, destination, monochrome)
36
+ return convert_image(jp2_to_tiff(@path), destination, monochrome, options) if jp2?
37
+ convert_image(@path, destination, monochrome, options)
36
38
  end
37
39
 
38
40
  private
39
41
 
40
- def convert_image(source, destination, monochrome)
42
+ def convert_image(source, destination, monochrome, options)
41
43
  monochrome &&= destination.slice(-4, 4).index('tif')
42
44
  mono_opts = "-depth 1 -monochrome -compress Group4 -type bilevel "
43
45
  opts = monochrome ? mono_opts : ''
46
+ opts = "#{options} " if options.present?
44
47
  cmd = "convert #{source} #{opts}#{destination} && sync"
45
48
  `#{cmd}`
46
49
  end
@@ -81,7 +81,7 @@ module IiifPrint
81
81
  tool = IiifPrint::ImageTool.new(@path)
82
82
  return if tool.metadata[:color] == 'monochrome' && tool.metadata[:content_type] != 'image/jp2'
83
83
  intermediate_path = File.join(Dir.mktmpdir, 'monochrome-interim.tif')
84
- tool.convert(intermediate_path, true)
84
+ tool.convert(intermediate_path, true, options: IiifPrint.config.ocr_preprocess_options)
85
85
  @path = intermediate_path
86
86
  end
87
87
  end
@@ -1,3 +1,3 @@
1
1
  module IiifPrint
2
- VERSION = '3.2.3'.freeze
2
+ VERSION = '3.3.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iiif_print
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.3
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Upton