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: 2e9dff223f4761869e7f5402374348a5e827837d
4
- data.tar.gz: 35c2334fb968df5c8ef1149057e07673c8025525
3
+ metadata.gz: 3e29312d6b9c70ffe5a5c804d7cedb9a90192430
4
+ data.tar.gz: 5c61ee26c770716fb9a273330d2998aca7b3ff20
5
5
  SHA512:
6
- metadata.gz: b65563476de4a21ecedea13cf14ad690b2284ea8328344e49571fb4bb302ebb900b733ca74346473e88ef9117b7e763c37762625d152e865c18cde39239615ad
7
- data.tar.gz: ac5fe30d7ad575b259f7cf3f10bbd7d3d9d93f19d2303bd27e46986e2496e6baaca44c9b56d97795fcbb650d906e7c97fcb2533a5cb56fd6a925a14cbfc8700c
6
+ metadata.gz: 6ff5e320e9fae957dce08b6e68b729ea987d5b3f03961d4d600123be5c3ba2a94b284dc9a9488fc635b53e2eda6ec1875f290e188cd03cbd61d44ee145e8c670
7
+ data.tar.gz: f2ca6c8ab116dc68db4ea08e5d5dfe485b633d6e7f84fa9d48ca4f9c339f1028f35e0f57ab01090488437a4fc6734bb2e79e8d11b5bb92b8f4192a7a4bab5710
@@ -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.add_development_dependency "fastimage", '~> 2.1'
26
+ spec.add_runtime_dependency "fastimage", '~> 2.1'
27
+ # spec.add_runtime_dependency "rmagick", "~> 2.16"
27
28
  end
@@ -1,6 +1,6 @@
1
1
  module Jekyll
2
2
  module Webp
3
- VERSION = "1.0.5"
3
+ VERSION = "1.0.6"
4
4
  # When modifying remember to issue a new tag command in git before committing, then push the new tag
5
5
  # git tag -a v0.1.0 -m "Gem v0.1.0"
6
6
  # git push origin --tags
@@ -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
- # Execute the command
40
- exit_code = 0
41
- error = ""
42
- output = ""
43
- Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
44
- stdin.close # we don't pass any input to the process
45
- output = stdout.gets
46
- error = stderr.gets
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
- # Return any captured return value
55
- return [output, error]
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
@@ -91,6 +91,10 @@ module Jekyll
91
91
  site.dest,
92
92
  File.join(imgdir, prefix),
93
93
  File.basename(output))
94
+ site.static_files << WebpFile.new(site,
95
+ site.dest,
96
+ File.join(imgdir, prefix),
97
+ File.basename(output).sub("webp", "jpg"))
94
98
  end
95
99
  end
96
100
  end # dir.foreach
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.5
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: :development
83
+ type: :runtime
84
84
  prerelease: false
85
85
  version_requirements: !ruby/object:Gem::Requirement
86
86
  requirements: