jekyll-images 0.4.0rc0 → 0.4.0rc3

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
  SHA256:
3
- metadata.gz: 7b806091563d3dfe022d4e6558631c998aa1be7cec781363b15a957bfbf09bc2
4
- data.tar.gz: f7732fba18d8ed4e84b8c6f944ef1bc857d67ea2ad704e7d0522c54ff708709a
3
+ metadata.gz: cda1839013f3926324b55c39851d9c3ed4bba23f40dfdb995499c0937303b986
4
+ data.tar.gz: d70705d09301fb8ef5092dc3480328a9119e9af9b9b6f57006804392c017b75b
5
5
  SHA512:
6
- metadata.gz: bd1d4b6b7d5ece1782928ae15c9bf59dec33414ad5c2c50928a55768429400156ea6e404467ba2679a92b40c0fe7891a40bc427b93512c894699dc8ee1964c4b
7
- data.tar.gz: 4273da19ba65f935b2f11cb1cfb06e0023fca26e4c384f9ae2a8708c5dbbdb15eb971cb90e2aa128df6565bd57b4300205e35b5a6232d45c9f3768fa70cbecf7
6
+ metadata.gz: 88c86b1471440b7e6610e3bdb22e0bd11558a8f5f997f01db17447715e7a16a7177c5118530a4171846ceac4420774bc2ba706c1c7b2e940c6d463ece0b1caf0
7
+ data.tar.gz: 951d9ff05d72d7052bbbb395e4dbcd7dce1f0922df752cd0dafa41f4827c1512a445a4dc88ef9986af7df76759263c06fdbc1f4b0bfcca083a4ecbb0c95e32af
data/README.md CHANGED
@@ -53,6 +53,8 @@ images:
53
53
  interlaced: true
54
54
  ```
55
55
 
56
+ **Note:** Interlacing sometimes won't make the images smaller.
57
+
56
58
  [^0]:
57
59
  <https://blog.cloudflare.com/parallel-streaming-of-progressive-images/>
58
60
 
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module Filters
5
+ # Liquid filter for use in templates
6
+ module Dzsave
7
+ # Generates an image pyramid
8
+ #
9
+ # @see {https://www.libvips.org/API/current/Making-image-pyramids.md.html}
10
+ def dzsave(input, layout = 'google', tile_size = 256)
11
+ return input unless input
12
+
13
+ path = @context.registers[:site].in_source_dir input
14
+
15
+ unless ::File.exist? path
16
+ Jekyll.logger.warn "File doesn't exist #{input}"
17
+ return input
18
+ end
19
+
20
+ dir = ::File.dirname(input)
21
+ image = Vips::Image.new_from_file path, access: :sequential
22
+ image.dzsave(dir, layout: layout, tile_size: tile_size)
23
+
24
+ "#{dir}/{z}/{y}/{x}.#{::File.extname input}"
25
+ rescue Vips::Error => e
26
+ Jekyll.logger.warn "Failed to process #{input}: #{e.message}"
27
+ input
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ Liquid::Template.register_filter(Jekyll::Filters::Dzsave)
@@ -26,6 +26,10 @@ module Jekyll
26
26
  def thumbnail(**args)
27
27
  @cached_thumbnails[args.hash.to_s] ||= Thumbnail.new site: site, filename: filename, image: self, **args
28
28
  end
29
+
30
+ def dzsave(**args)
31
+
32
+ end
29
33
  end
30
34
  end
31
35
  end
@@ -9,7 +9,7 @@ module Jekyll
9
9
  BINARY = 'oxipng'.freeze
10
10
 
11
11
  def command
12
- [binary, '--strip', 'all', '--quiet', '--interlace', (interlaced ? '1' : '0'), file]
12
+ [binary, '--strip', 'all', '--quiet', '--interlace', (interlaced ? %w[1 --force] : '0'), file].flatten
13
13
  end
14
14
  end
15
15
  end
data/lib/jekyll-images.rb CHANGED
@@ -11,5 +11,6 @@ require_relative 'jekyll/images/thumbnail'
11
11
  require_relative 'jekyll/filters/thumbnail'
12
12
  require_relative 'jekyll/filters/width'
13
13
  require_relative 'jekyll/filters/height'
14
+ require_relative 'jekyll/filters/dzsave'
14
15
  require_relative 'jekyll/images/oxipng'
15
16
  require_relative 'jekyll/images/jpeg_optim'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-images
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0rc0
4
+ version: 0.4.0rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - f
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-20 00:00:00.000000000 Z
11
+ date: 2022-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -64,6 +64,7 @@ files:
64
64
  - LICENSE
65
65
  - README.md
66
66
  - lib/jekyll-images.rb
67
+ - lib/jekyll/filters/dzsave.rb
67
68
  - lib/jekyll/filters/height.rb
68
69
  - lib/jekyll/filters/thumbnail.rb
69
70
  - lib/jekyll/filters/width.rb