jekyll-images 0.4.0rc1 → 0.4.0rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll/filters/dzsave.rb +33 -0
- data/lib/jekyll/images/image.rb +4 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8fb884679503e21d7cec255f22cd496b338ee6783b763249b94df7c9f719ec2
|
4
|
+
data.tar.gz: d2103b9d5ac82b643c5099e5a7f2a9ddb813951c81f429a0dd41822a4450e865
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 106b016d8420dcd171cc7676715b3bf3ba6f272e0cd678f369b3b9f264697dd4734ba2d62b30ff532023553c0467abf37762c3f4945bb32b3c2f05a400ae8d81
|
7
|
+
data.tar.gz: e895b2a0c9f623050ab911dc829ce22696ee72a0477944c260cc1ff0a7396a2cbcb24b06c9c16ee0a737c5513c9fb6d577510c1c86d66b5dbe07809f13f41b1c
|
@@ -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)
|
data/lib/jekyll/images/image.rb
CHANGED
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.
|
4
|
+
version: 0.4.0rc2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- f
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-06-
|
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
|