jekyll-images 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll/images/thumbnail.rb +21 -8
- data/lib/jekyll/images/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 522e86cd58354de44d3f57ec228fccdb3a2b2872f409f0ba2c7c7602faebf885
|
4
|
+
data.tar.gz: 4839dba88514687693ecc6ca174764f9c9b3dceecb6899e00e3d40383f9ffcb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 644c96a927fabe9d74aebcc67a936d26a45302413f1ce63b7e704124c5de6d30820fa951518ce6dc62de069393e62765df8be07b0f2c8d75b4ed06c9e885b4b2
|
7
|
+
data.tar.gz: 324147f91123e3217079b6b9856e9e855852e285a9c4c3e83893488c0ad54f6a42d3dbbb826968e58dd5d1b578b99c79424f93a1917c400984cbe7bb96fe3f5b
|
@@ -8,7 +8,7 @@ module Jekyll
|
|
8
8
|
#
|
9
9
|
# We're assuming every image is going to be thumbnailed
|
10
10
|
class Thumbnail
|
11
|
-
attr_reader :site, :
|
11
|
+
attr_reader :site, :filename, :width, :height, :crop, :auto_rotate
|
12
12
|
|
13
13
|
def initialize(site, filename, **args)
|
14
14
|
unless File.exist? filename
|
@@ -20,16 +20,29 @@ module Jekyll
|
|
20
20
|
@filename = filename
|
21
21
|
@width = args[:width]
|
22
22
|
@height = args[:height]
|
23
|
-
@
|
24
|
-
@
|
25
|
-
height: height || proportional_height,
|
26
|
-
auto_rotate: args[:auto_rotate],
|
27
|
-
crop: args[:crop].to_sym
|
23
|
+
@crop = args[:crop].to_sym
|
24
|
+
@auto_rotate = args[:auto_rotate]
|
28
25
|
end
|
29
26
|
|
30
|
-
|
27
|
+
def image
|
28
|
+
@image ||= Vips::Image.new_from_file filename,
|
29
|
+
access: :sequential
|
30
|
+
end
|
31
|
+
|
32
|
+
def thumbnail
|
33
|
+
@thumbnail ||= image.thumbnail_image width,
|
34
|
+
height: height,
|
35
|
+
auto_rotate: auto_rotate,
|
36
|
+
crop: crop
|
37
|
+
end
|
38
|
+
|
39
|
+
def height
|
40
|
+
@height || proportional_height
|
41
|
+
end
|
42
|
+
|
43
|
+
# Finds a heigth that's proportional to the width
|
31
44
|
def proportional_height
|
32
|
-
@
|
45
|
+
@proportional_height ||= (image.height * (width / image.width.to_f)).round
|
33
46
|
end
|
34
47
|
|
35
48
|
# Generates a destination from filename only if we're downsizing
|
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.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- f
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-vips
|