Skip to content

Commit fdee843

Browse files
committed
Initial commit of the webp gem project
0 parents  commit fdee843

17 files changed

+483
-0
lines changed

.travis.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
language: ruby
2+
cache: bundler
3+
sudo: false
4+
rvm:
5+
- 2.2
6+
before_script: bundle update
7+
notifications:
8+
email:
9+
on_success: never
10+
on_failure: never

CODE_OF_CONDUCT.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, gender identity and expression, level of experience,
9+
nationality, personal appearance, race, religion, or sexual identity and
10+
orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at [[email protected]](mailto:[email protected]). All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at [http://contributor-covenant.org/version/1/4][version]
72+
73+
[homepage]: http://contributor-covenant.org
74+
[version]: http://contributor-covenant.org/version/1/4/

Gemfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
source 'https://rubygems.org'
2+
3+
# Specify your gem's dependencies in jekyll-webp.gemspec
4+
gemspec
5+
6+
if ENV["JEKYLL_VERSION"]
7+
gem "jekyll", "~> #{ENV["JEKYLL_VERSION"]}"
8+
end

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 Sverrir Sigmundarson
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

README.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
2+
# WebP Generator for Jekyll
3+
WebP Image Generator for Jekyll Sites can automatically generate WebP images for all images on your static site and serve them when possible.
4+
> Read more about this tool on my blog at <a href="https://blog.sverrirs.com/2016/06/webp-generator-for-jekyll-sites.html" target="_blank">blog.sverrirs.com</a>
5+
6+
## Installation
7+
8+
```
9+
gem install jekyll-webp
10+
```
11+
12+
The release includes all necessary files to run, including the WebP redistributable executable files.
13+
14+
> Currently the release includes the v0.5.1 version of the WebP utilities for Windows, Linux and Mac OS X 10.9 (Mountain Lion). Other versions and releases can be downloaded directly from <a href="https://developers.google.com/speed/webp/docs/precompiled" target="_blank">the Google page</a>.
15+
16+
Add the gem to your `Gemfile` and to Jekyll's `_config.yml` then run `jekyll serve` again and you should see the generator run during site generation.
17+
18+
## Configuration
19+
The plugin can be configured in the site's `_config.yml` file by including the `webp` configuration element
20+
21+
``` yml
22+
############################################################
23+
# Site configuration for the WebP Generator Plugin
24+
# The values here represent the defaults if nothing is set
25+
webp:
26+
enabled: true
27+
28+
# The quality of the webp conversion 0 to 100 (where 100 is least lossy)
29+
quality: 75
30+
31+
# List of directories containing images to optimize, nested directories will not be checked
32+
# By default the generator will search for a folder called `/img` under the site root and process all jpg, png and tiff image files found there.
33+
img_dir: ["/img"]
34+
35+
# add ".gif" to the format list to generate webp for animated gifs as well
36+
formats: [".jpeg", ".jpg", ".png", ".tiff"]
37+
38+
# File extensions for animated gif files
39+
gifs: [".gif"]
40+
41+
# Set to true to always regenerate existing webp files
42+
regenerate: false
43+
44+
# Local path to the WebP utilities to use (relative or absolute)
45+
# Omit or leave as nil to use the utilities shipped with the gem, override only to use your local install
46+
webp_path: nil
47+
48+
# List of files or directories to exclude
49+
# e.g. custom or hand generated webp conversion files
50+
exclude: []
51+
############################################################
52+
```
53+
54+
## Simplest use: HTML
55+
In case you don't have control over your webserver then using the `<picture>` element and specifying all image formats available is the best option. This way the browser will decide which format to use based on its own capabilities.
56+
57+
``` html
58+
<picture>
59+
<source srcset="/path/to/image.webp" type="image/webp">
60+
<img src="/path/to/image.jpg" alt="">
61+
</picture>
62+
```
63+
64+
## Advanced use: Webserver Configuration
65+
If you can then configuring your webserver to serve your new _.webp_ files to clients that support the format is probably the least problematic approach. This way you don't need to make any changes to your HTML files as your webserver will automatically serve WebP images when the client supports them.
66+
67+
Below is an example for a .htaccess configuration section in an Apache web-server. It will redirect users to webp images whenever possible.
68+
69+
```
70+
####################
71+
# Attempt to redirect images to WebP if one exists
72+
# and the client supports the file format
73+
####################
74+
# check if browser accepts webp
75+
RewriteCond %{HTTP_ACCEPT} image/webp
76+
77+
# check if file is jpg or png
78+
RewriteCond %{REQUEST_FILENAME} (.*)\.(jpe?g|png)$
79+
80+
# check if corresponding webp file exists image.png -> image.webp
81+
RewriteCond %1\.webp -f
82+
83+
# serve up webp instead
84+
RewriteRule (.+)\.(jpe?g|png)$ $1.webp [T=image/webp,E=accept:1]
85+
86+
AddType image/webp .webp
87+
```
88+
89+
> Depending on other configurations in your `.htaccess` file you might have to update your `ExpiresByType`, `ExpiresDefault` and `Header set Cache-Control` directives to include the webp format as well.
90+

Rakefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
require 'rake'
2+
require 'rake/testtask'
3+
4+
Rake::TestTask.new do |t|
5+
t.libs.push 'lib'
6+
t.libs.push 'specs'
7+
t.verbose = true
8+
t.pattern = "spec/*_spec.rb"
9+
t.test_files = FileList['spec/*_spec.rb']
10+
end
11+
12+
desc "Run tests"
13+
task :default => [:test]

bin/linux-x64-cwebp

1.48 MB
Binary file not shown.

bin/linux-x86-cwebp

1.15 MB
Binary file not shown.

bin/osx-cwebp

1.23 MB
Binary file not shown.

bin/win-x64-cwebp.exe

585 KB
Binary file not shown.

0 commit comments

Comments
 (0)