libis-format 0.9.25 → 0.9.27
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cadc47b943e364c4c6434923afbfb3dc27e54d78
|
4
|
+
data.tar.gz: c84123018a48a1b2397ad7e7e4fc3b7d759a38b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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(
|
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
|
-
|
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("#{
|
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("#{
|
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,#{
|
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
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
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
|
data/lib/libis/format/version.rb
CHANGED