libis-format 1.0.1 → 1.0.2
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/lib/libis/format/converter/image_converter.rb +12 -15
- data/lib/libis/format/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21f527308cef3b9865c24c956f5a76cf67973400
|
4
|
+
data.tar.gz: 19c867aef5d28da24a3354025b11fc718b885a7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3af22a3b301bc89a0839215a96a571d729478c61f3d414ee144e7f011d16443f4e604efd8f6afb0b40d2dd02dc77ca65878dfba7b29a6f4bc186beec8373b437
|
7
|
+
data.tar.gz: 81bebc7836625f251e9365100bfdb4a13d3ec4424a26a536521bb1776a11d96472645af1e360077ff64d5ef4e6f08671e0c87330d8fa32f5230b390509a016ce
|
@@ -29,6 +29,10 @@ module Libis
|
|
29
29
|
[:TIFF, :JPG, :PNG, :BMP, :GIF, :PDF, :JP2]
|
30
30
|
end
|
31
31
|
|
32
|
+
def self.multipage?(format)
|
33
|
+
[:PDF, :TIFF, :GIF, :PBM, :PGM, :PPM].include?(format)
|
34
|
+
end
|
35
|
+
|
32
36
|
def initialize
|
33
37
|
@wm_image = nil
|
34
38
|
super
|
@@ -142,24 +146,13 @@ module Libis
|
|
142
146
|
FileUtils.mkpath(File.dirname(target))
|
143
147
|
|
144
148
|
if source.is_a? Array
|
145
|
-
sources = source
|
146
|
-
|
147
|
-
unless [:PDF, :TIFF, :GIF, :PBM, :PGM, :PPM].include? format
|
148
|
-
error 'Can ony assemble multiple images into multi-page/layer format'
|
149
|
-
return nil
|
150
|
-
end
|
151
149
|
|
152
|
-
assemble_and_convert(
|
150
|
+
assemble_and_convert(source, target, format)
|
153
151
|
|
154
152
|
elsif File.directory?(source)
|
155
|
-
|
153
|
+
source_list = Dir[File.join(source, '**', '*')].reject { |p| File.directory? p }
|
156
154
|
|
157
|
-
|
158
|
-
error 'Can ony assemble multiple images into multi-page/layer format'
|
159
|
-
return nil
|
160
|
-
end
|
161
|
-
|
162
|
-
assemble_and_convert(sources, target, format)
|
155
|
+
assemble_and_convert(source_list, target, format)
|
163
156
|
|
164
157
|
else
|
165
158
|
|
@@ -181,12 +174,15 @@ module Libis
|
|
181
174
|
end
|
182
175
|
|
183
176
|
def assemble_and_convert(sources, target, format)
|
177
|
+
|
178
|
+
warn 'Received multiple images as input and single page format as target.' unless self.class.multipage?(format)
|
184
179
|
converted_pages = sources.inject([]) do |list, path|
|
185
180
|
converted = Tempfile.new(['page-', ".#{Libis::Format::TypeDatabase.type_extentions(format).first}"])
|
186
181
|
convert_image(path, converted.path, format)
|
187
182
|
list << converted
|
188
183
|
end
|
189
184
|
MiniMagick::Tool::Convert.new do |b|
|
185
|
+
b.append unless self.class.multipage?(format)
|
190
186
|
converted_pages.each { |page| b << page.path }
|
191
187
|
b << target
|
192
188
|
end
|
@@ -200,7 +196,8 @@ module Libis
|
|
200
196
|
|
201
197
|
def convert_image(source, target, format)
|
202
198
|
|
203
|
-
image_info =
|
199
|
+
image_info = nil
|
200
|
+
image_info = MiniMagick::Image::Info.new(source) if @wm_image
|
204
201
|
|
205
202
|
MiniMagick::Tool::Convert.new do |convert|
|
206
203
|
if @wm_image
|
data/lib/libis/format/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libis-format
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kris Dekeyser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|