omg_image 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/omg_image/application_helper.rb +8 -4
- data/app/models/omg_image/image.rb +1 -1
- data/lib/omg_image/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: 6d11fbb19b0784a35ae4e855a0d2426c74b2d3f297aec6fa37e007e1d0f8455a
|
4
|
+
data.tar.gz: 15fde70c74210d1d1359d41a03967808a07fd8e1e2dfeb120f8163157c3ff5ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd5e145b67e6e6384634907cb84dd0a31a8c745753853e64fdcc0e7e3fada226395168492c29c6f1194d84eaec9c7d7a388ffd86bd23e767ca6db8c82ae67e19
|
7
|
+
data.tar.gz: 7ed59bc149b69d64e6efd0a583c31b8c6dce8e9863a4d88cdeede60908689b911dc472a0f4dccc8dd4e6d46d08500c9cfde057dbd7f9c79552a087e2e4475815
|
@@ -13,6 +13,7 @@ module OmgImage
|
|
13
13
|
options[:key] ||= options.to_s
|
14
14
|
|
15
15
|
image = OmgImage::Image.find_by(key: options[:key])
|
16
|
+
log_smt " found #{image.present?}"
|
16
17
|
if image && !image.file.attached?
|
17
18
|
image.destroy
|
18
19
|
image = nil
|
@@ -37,8 +38,8 @@ module OmgImage
|
|
37
38
|
|
38
39
|
output = BetterTempfile.new("image.png")
|
39
40
|
|
40
|
-
|
41
|
-
command = build_chrome_command(
|
41
|
+
cli_options = { file: output, size: options[:size], path: input.path }
|
42
|
+
command = build_chrome_command(cli_options)
|
42
43
|
log_smt " => #{command}"
|
43
44
|
|
44
45
|
start = Time.now
|
@@ -46,13 +47,16 @@ module OmgImage
|
|
46
47
|
process = open4.spawn(command, timeout: 10)
|
47
48
|
rescue Timeout::Error
|
48
49
|
Process.kill('KILL', process.pid) rescue nil
|
50
|
+
log_smt "omg error: please retry. options: #{options}"
|
51
|
+
return nil
|
49
52
|
end
|
50
53
|
log_smt " to_image: #{(Time.now - start).round(2)}"
|
51
54
|
|
52
|
-
image
|
55
|
+
image = OmgImage::Image.find_by(key: options[:key])
|
56
|
+
image ||= OmgImage::Image.new(key: options[:key])
|
53
57
|
if !image.file.attached?
|
54
58
|
image.file.attach(io: File.open(output.path), filename: "image.png", content_type: "image/png")
|
55
|
-
image.save
|
59
|
+
image.save!
|
56
60
|
end
|
57
61
|
|
58
62
|
image.file
|
data/lib/omg_image/version.rb
CHANGED