libis-format 0.9.25 → 0.9.27

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
  SHA1:
3
- metadata.gz: 3fd8793200e3cb32f5a45fcae74e20e2894b770d
4
- data.tar.gz: 75723f33d4d2f3bbca14d8a2f7c39061a267907d
3
+ metadata.gz: cadc47b943e364c4c6434923afbfb3dc27e54d78
4
+ data.tar.gz: c84123018a48a1b2397ad7e7e4fc3b7d759a38b0
5
5
  SHA512:
6
- metadata.gz: 74deb6b251df7739c4102e523a596cfcf4fc1b677e15c7c006375ced4d808487268e27c49909fa57cb0309422e50508bd5cafa35a91098283dff06b94472e919
7
- data.tar.gz: cbda0fac457af285cf3a6d393388295fce204e5868312c8ea29a39a61d48b2e305376f0d4b00d1882864f3d0361b765ffd7f770269c911cb6ad5e383178c3f6d
6
+ metadata.gz: 41c4d4af2379031e1e01437403a31e441aae602789ca3c28ef74ebd4da5a66ac419669b0924e2cacfaf6ee24b1a7edd631c113aebcd1ae02d0680d3a7767d5ea
7
+ data.tar.gz: f2d028224f694e701749b1421b23c29dd49f173be140b65cf9a55587ad3d872f057116f9844235b9f18d2daf37fe505dced601466b943875245ea7c5de4ad9d4
@@ -86,14 +86,14 @@ module Libis
86
86
  # @param [Hash] options Hash of options for watermark creation.
87
87
  def watermark(options = {})
88
88
  text = options[:text] || '© LIBIS'
89
- image = options[:file] || (Dir::Tmpname.create(%w(wm_image .png)) { |_|})
90
89
  @wm_size = (options[:size] || '4').to_i
91
90
  @wm_opacity = ((options[:opacity] || 0.1).to_f * 100).to_i
92
91
  @wm_composition = options[:composition] || 'modulate'
93
92
  gap = ((options[:gap] || 0.2).to_f * 100).to_i
94
93
  rotation = 360 - (options[:rotation] || 30).to_i
95
- @wm_image = MiniMagick::Image.new(image)
96
- unless @wm_image.valid?
94
+ @wm_image = MiniMagick::Image.new(options[:file]) if options[:file]
95
+ unless @wm_image && @wm_image.valid?
96
+ image = options[:file] || (Dir::Tmpname.create(%w(wm_image .png)) { |_|})
97
97
  # noinspection RubyResolve
98
98
  MiniMagick::Tool::Convert.new do |convert|
99
99
  # noinspection RubyLiteralArrayInspection
@@ -182,13 +182,13 @@ module Libis
182
182
 
183
183
  def convert_image(source, target, format)
184
184
 
185
- image = MiniMagick::Image.new(source)
185
+ image_info = MiniMagick::Image.Info.new(source)
186
186
 
187
187
  MiniMagick::Tool::Convert.new do |convert|
188
188
  if @wm_image
189
189
  convert << @wm_image.path
190
190
  convert.filter('Lagrange')
191
- convert.resize("#{image.width / @wm_size}x#{image.height / @wm_size}").write('mpr:watermark').delete.+
191
+ convert.resize("#{image_info['width'] / @wm_size}x#{image_info['height'] / @wm_size}").write('mpr:watermark').delete.+
192
192
  end
193
193
 
194
194
  convert << source
@@ -196,10 +196,10 @@ module Libis
196
196
  if @wm_image
197
197
  # noinspection RubyResolve
198
198
  convert.stack do |stack|
199
- stack.size("#{image.width}x#{image.height}")
199
+ stack.size("#{image_info['width']}x#{image_info['height']}")
200
200
  stack << 'xc:transparent'
201
201
  stack.tile('mpr:watermark')
202
- stack.draw "rectangle 0,0,#{image.width},#{image.height}"
202
+ stack.draw "rectangle 0,0,#{image_info['width']},#{image_info['height']}"
203
203
  end
204
204
  convert.compose(@wm_composition).define("compose:args=#{@wm_opacity}").composite
205
205
  end
@@ -103,14 +103,13 @@ module Libis
103
103
 
104
104
  result = nil
105
105
 
106
- unless @options.empty?
107
-
108
- if (quality = @options.delete('optimize'))
109
- result = optimize_pdf(source, target, quality)
110
- return nil unless result
111
- source = result
112
- end
106
+ if (quality = @options.delete('optimize'))
107
+ result = optimize_pdf(source, target, quality)
108
+ return nil unless result
109
+ source = result
110
+ end
113
111
 
112
+ unless @options.empty?
114
113
  result = convert_pdf(source, target)
115
114
  return nil unless result
116
115
  source = result
@@ -1,5 +1,5 @@
1
1
  module Libis
2
2
  module Format
3
- VERSION = '0.9.25'
3
+ VERSION = '0.9.27'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libis-format
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.25
4
+ version: 0.9.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kris Dekeyser