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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +4 -0
- data/lib/iiif_print/configuration.rb +9 -0
- data/lib/iiif_print/image_tool.rb +7 -4
- data/lib/iiif_print/text_extraction/page_ocr.rb +1 -1
- data/lib/iiif_print/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 113eb0be5d5b6783a1c81c4b5cb9ef3c1d907f20ef86cdc24e3c3d53dcc61b15
|
|
4
|
+
data.tar.gz: 40810de9ff823b85a69b849aa6876eb210b68d1a0908d122b44ef2244f45f865
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bdf04fd441bdd4fcf46380ef1f7958b28e284a826aec246c111fd6d4bba7f16db6aad80d1420a986fb8081798112f8befdad44fb4d6fc6338a458eb605d6a7a2
|
|
7
|
+
data.tar.gz: 3501966b7a60712c27995d3cf079510d5e52bbaf1733b944e855c613e506b3cf9d85bf15ffcc599a6366b86fb62ae57c7aa710064e4802be217bfe4da86ebc6c
|
data/Gemfile.lock
CHANGED
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
|
-
|
|
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
|
data/lib/iiif_print/version.rb
CHANGED