sprockets-webp 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/sprockets-webp.rb +2 -2
- data/lib/sprockets/webp/converter.rb +9 -4
- data/lib/sprockets/webp/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51ecae2261a9bde5d73f38b1425929dc7a5aa50a
|
4
|
+
data.tar.gz: 8857ccb03ec2a54b7036ffdad5d8f6c9dcf34293
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9cf48a3ac796ae6de86cd0f7697eb866c99be7ae00133dfedf87766dd6ed39e7d2b2952c9f89f4c628fa688680658f9929b3616eeb1d4efac32e6c6ae8fcd68
|
7
|
+
data.tar.gz: 491d6cd24cf9db6f531d09acf5d6dc3bdf58eff9474c268940027f764c0171732f164172554116b023ceca183ecc68c454dd8c4496e87b2fac17fc112be424eb
|
data/README.md
CHANGED
@@ -53,7 +53,7 @@ Minimal required version of Rails 3 is ```3.2.9```, because of Sprockets ```~> 2
|
|
53
53
|
|
54
54
|
You can configure encode options for webp by using `encode_options` (in example default options):
|
55
55
|
|
56
|
-
Sprockets::WebP.encode_options = { quality: 100, lossless: 1, method:
|
56
|
+
Sprockets::WebP.encode_options = { quality: 100, lossless: 1, method: 6, alpha_filtering: 2, alpha_compression: 0, alpha_quality: 100 }
|
57
57
|
|
58
58
|
More options you can find in [web-ffi readme](https://github.com/le0pard/webp-ffi#encode-webp-image).
|
59
59
|
|
data/lib/sprockets-webp.rb
CHANGED
@@ -8,13 +8,13 @@ module Sprockets
|
|
8
8
|
module WebP
|
9
9
|
# configure web encode options
|
10
10
|
#
|
11
|
-
# Sprockets::WebP.encode_options = { quality:
|
11
|
+
# Sprockets::WebP.encode_options = { quality: 100, lossless: 1, method: 6, alpha_filtering: 2, alpha_compression: 0, alpha_quality: 100 }
|
12
12
|
#
|
13
13
|
class << self
|
14
14
|
attr_writer :encode_options
|
15
15
|
|
16
16
|
def encode_options
|
17
|
-
@encode_options ||= { quality: 100, lossless: 1, method:
|
17
|
+
@encode_options ||= { quality: 100, lossless: 1, method: 6, alpha_filtering: 2, alpha_compression: 0, alpha_quality: 100 }
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -18,10 +18,7 @@ module Sprockets
|
|
18
18
|
config = app.config.assets
|
19
19
|
|
20
20
|
# If Application Assets Digests enabled - Add Digest
|
21
|
-
|
22
|
-
file_name = context.logical_path # Original File name w/o extension
|
23
|
-
file_ext = context.pathname.extname # Original File extension
|
24
|
-
webp_file = "#{file_name}#{digest}#{file_ext}.webp" # WebP File fullname
|
21
|
+
webp_file = webp_file_by_config(config, data)
|
25
22
|
|
26
23
|
# WebP File Pathname
|
27
24
|
webp_path = Pathname.new File.join(app.root, 'public', config.prefix, webp_file)
|
@@ -37,6 +34,13 @@ module Sprockets
|
|
37
34
|
|
38
35
|
private
|
39
36
|
|
37
|
+
def webp_file_by_config(config, data)
|
38
|
+
digest = config.digest ? "-#{context.environment.digest.update(data).hexdigest}" : nil
|
39
|
+
file_name = context.logical_path # Original File name w/o extension
|
40
|
+
file_ext = context.pathname.extname # Original File extension
|
41
|
+
"#{file_name}#{digest}#{file_ext}.webp" # WebP File fullname
|
42
|
+
end
|
43
|
+
|
40
44
|
def encode_to_webp(data, webp_path, webp_file = "")
|
41
45
|
# Create Temp File with Original File binary data
|
42
46
|
Tempfile.open('webp') do |file|
|
@@ -47,6 +51,7 @@ module Sprockets
|
|
47
51
|
# Encode Original File Temp copy to WebP File Pathname
|
48
52
|
begin
|
49
53
|
::WebP.encode(file.path, webp_path, Sprockets::WebP.encode_options)
|
54
|
+
logger.info "Webp converted image #{webp_path}"
|
50
55
|
rescue => e
|
51
56
|
logger.warn "Webp convertion error of image #{webp_file}. Error info: #{e.message}"
|
52
57
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sprockets-webp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max Riveiro
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sprockets
|
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
103
|
version: '0'
|
104
104
|
requirements: []
|
105
105
|
rubyforge_project:
|
106
|
-
rubygems_version: 2.2.
|
106
|
+
rubygems_version: 2.2.2
|
107
107
|
signing_key:
|
108
108
|
specification_version: 4
|
109
109
|
summary: Sprockets converter of PNG and JPEG assets to WebP
|