jekyll-webp-resize 1.0.5 → 1.0.6
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e29312d6b9c70ffe5a5c804d7cedb9a90192430
|
4
|
+
data.tar.gz: 5c61ee26c770716fb9a273330d2998aca7b3ff20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ff5e320e9fae957dce08b6e68b729ea987d5b3f03961d4d600123be5c3ba2a94b284dc9a9488fc635b53e2eda6ec1875f290e188cd03cbd61d44ee145e8c670
|
7
|
+
data.tar.gz: f2ca6c8ab116dc68db4ea08e5d5dfe485b633d6e7f84fa9d48ca4f9c339f1028f35e0f57ab01090488437a4fc6734bb2e79e8d11b5bb92b8f4192a7a4bab5710
|
data/jekyll-webp-resize.gemspec
CHANGED
@@ -23,5 +23,6 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.5"
|
24
24
|
spec.add_development_dependency "rake", "~> 1.5"
|
25
25
|
spec.add_development_dependency "minitest", '~> 5.4', '>= 5.4.3'
|
26
|
-
spec.
|
26
|
+
spec.add_runtime_dependency "fastimage", '~> 2.1'
|
27
|
+
# spec.add_runtime_dependency "rmagick", "~> 2.16"
|
27
28
|
end
|
@@ -4,6 +4,26 @@ require 'fastimage'
|
|
4
4
|
module Jekyll
|
5
5
|
module Webp
|
6
6
|
class WebpExec
|
7
|
+
def self.run_cmd(cmd)
|
8
|
+
# Execute the command
|
9
|
+
exit_code = 0
|
10
|
+
error = ""
|
11
|
+
output = ""
|
12
|
+
Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
|
13
|
+
stdin.close # we don't pass any input to the process
|
14
|
+
output = stdout.gets
|
15
|
+
error = stderr.gets
|
16
|
+
exit_code = wait_thr.value
|
17
|
+
end
|
18
|
+
|
19
|
+
if exit_code != 0
|
20
|
+
Jekyll.logger.error("WebP:","command returned #{exit_code} with error #{error}")
|
21
|
+
end
|
22
|
+
|
23
|
+
# Return any captured return value
|
24
|
+
return [output, error]
|
25
|
+
end
|
26
|
+
|
7
27
|
# Runs the WebP executable for the given input parameters
|
8
28
|
# the function detects the OS platform and architecture automatically
|
9
29
|
def self.run(input_file, output_file, flags, size)
|
@@ -36,23 +56,18 @@ module Jekyll
|
|
36
56
|
end
|
37
57
|
cmd += "-o \"#{output_file}\""
|
38
58
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
exit_code = wait_thr.value
|
48
|
-
end
|
49
|
-
|
50
|
-
if exit_code != 0
|
51
|
-
Jekyll.logger.error("WebP:","cwebp returned #{exit_code} with error #{error}")
|
59
|
+
run_cmd(cmd)
|
60
|
+
extension = File.extname(output_file)
|
61
|
+
basename = File.basename(output_file, extension)
|
62
|
+
path = File.dirname(output_file)
|
63
|
+
new_output_file = path + "/" + basename + ".jpg"
|
64
|
+
cmd = "convert \"#{input_file}\" -quality 92% "
|
65
|
+
if size != 0
|
66
|
+
cmd += "-resize \"#{size.to_s}>\" "
|
52
67
|
end
|
53
|
-
|
54
|
-
|
55
|
-
|
68
|
+
cmd += " #{new_output_file}"
|
69
|
+
Jekyll.logger.info(cmd)
|
70
|
+
run_cmd(cmd)
|
56
71
|
end #function run
|
57
72
|
|
58
73
|
# Returns the correct executable name depending on the OS platform and OS architecture
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-webp-resize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sverrir Sigmundarson
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '2.1'
|
83
|
-
type: :
|
83
|
+
type: :runtime
|
84
84
|
prerelease: false
|
85
85
|
version_requirements: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|