obf 0.9.8.17 → 0.9.8.18
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/obf/pdf.rb +2 -1
- data/lib/obf/utils.rb +17 -7
- 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: 68e9d9642a7a14c4324b0518f7f45b599009d40d1caaa6f414b1deeaab377ca1
|
|
4
|
+
data.tar.gz: 3d6ae2cada6b30884bdd964a09ea90c6d7281393aa3781f51d693c35d2d2ec17
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6772974b0b9f4d842dba7f7ca6e8bbfafc34dab19816ee4ef0e3239c31626ab9247b5cccb3899dc0b91ca09363bb30acccd788b776764ec83260f87c7e209032
|
|
7
|
+
data.tar.gz: a2f165e74c25da9d3102dc5b968d21efdad12b40f94680489778d52d87e53843e05ea83edc8d35a9c52cf2faa8212de20f975e6be5a40cd51776bc9a2100321f
|
data/lib/obf/pdf.rb
CHANGED
|
@@ -273,7 +273,8 @@ module OBF::PDF
|
|
|
273
273
|
elsif options['symbol_background'] == 'black'
|
|
274
274
|
bg = 'black'
|
|
275
275
|
end
|
|
276
|
-
image_local_path = image &&
|
|
276
|
+
image_local_path = image['local_path'] if image && image['local_path'] && File.exist?(image['local_path'])
|
|
277
|
+
image_local_path ||= image && OBF::Utils.save_image(image, options['zipper'], bg)
|
|
277
278
|
if image_local_path && File.exist?(image_local_path)
|
|
278
279
|
pdf.image(image_local_path, :fit => [button_width - 10, button_height - text_height - 5], :position => :center, :vposition => :center) rescue nil
|
|
279
280
|
File.unlink image_local_path
|
data/lib/obf/utils.rb
CHANGED
|
@@ -160,7 +160,7 @@ module OBF::Utils
|
|
|
160
160
|
end
|
|
161
161
|
|
|
162
162
|
def self.hydra
|
|
163
|
-
Typhoeus::Hydra.new(max_concurrency:
|
|
163
|
+
Typhoeus::Hydra.new(max_concurrency: 20)
|
|
164
164
|
end
|
|
165
165
|
|
|
166
166
|
def self.save_image(image, zipper=nil, background=nil)
|
|
@@ -217,10 +217,15 @@ module OBF::Utils
|
|
|
217
217
|
if image['content_type'] && image['content_type'].match(/svg/)
|
|
218
218
|
cmd = "convert -background \"#{background}\" -density 300 -resize #{size}x#{size} -gravity center -extent #{size}x#{size} #{file.path} -flatten #{file.path}.jpg"
|
|
219
219
|
OBF::Utils.log " #{cmd}"
|
|
220
|
-
image['local_path'] = "#{file.path}.jpg"
|
|
221
220
|
if image['threadable']
|
|
222
|
-
thr =
|
|
223
|
-
|
|
221
|
+
thr = Thread.new do
|
|
222
|
+
pid = Process.spawn(cmd)
|
|
223
|
+
Process.wait(pid)
|
|
224
|
+
if $?.exitstatus == 0 && File.exist?("#{file.path}.jpg")
|
|
225
|
+
image['local_path'] = "#{file.path}.jpg"
|
|
226
|
+
end
|
|
227
|
+
end
|
|
228
|
+
return {thread: thr, image: image, type: 'svg'}
|
|
224
229
|
else
|
|
225
230
|
`#{cmd}`
|
|
226
231
|
end
|
|
@@ -229,10 +234,15 @@ module OBF::Utils
|
|
|
229
234
|
else
|
|
230
235
|
cmd = "convert #{path} -density 300 -resize #{size}x#{size} -background \"#{background}\" -gravity center -extent #{size}x#{size} -flatten #{path}.jpg"
|
|
231
236
|
OBF::Utils.log " #{cmd}"
|
|
232
|
-
image['local_path'] = "#{path}.jpg"
|
|
233
237
|
if image['threadable']
|
|
234
|
-
thr =
|
|
235
|
-
|
|
238
|
+
thr = Thread.new do
|
|
239
|
+
pid = Process.spawn(cmd)
|
|
240
|
+
Process.wait(pid)
|
|
241
|
+
if $?.exitstatus == 0 && File.exist?("#{path}.jpg")
|
|
242
|
+
image['local_path'] = "#{path}.jpg"
|
|
243
|
+
end
|
|
244
|
+
end
|
|
245
|
+
return {thread: thr, image: image, type: 'not_svg'}
|
|
236
246
|
else
|
|
237
247
|
`#{cmd}`
|
|
238
248
|
end
|