sverrirs / jekyll-webp Goto Github PK
View Code? Open in Web Editor NEWWebP image generator gem for Jekyll websites
Home Page: https://rubygems.org/gems/jekyll-webp
License: MIT License
WebP image generator gem for Jekyll websites
Home Page: https://rubygems.org/gems/jekyll-webp
License: MIT License
If if nested: false
set to true, it still does not travel directories nested within the image folder.
webp:
enabled: true
# The quality of the webp conversion 0 to 100 (where 100 is least lossy)
quality: 75
# List of directories containing images to optimize, nested directories will only be checked if `nested` is true
# 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.
img_dir: ["/assets/images"]
# Whether to search in nested directories or not
nested: true
# add ".gif" to the format list to generate webp for animated gifs as well
formats: [".jpeg", ".jpg", ".png", ".tiff"]
# File extensions for animated gif files
gifs: [".gif"]
# Set to true to always regenerate existing webp files
regenerate: true
# Local path to the WebP utilities to use (relative or absolute)
# Omit or leave as nil to use the utilities shipped with the gem, override only to use your local install
webp_path: nil
# List of files or directories to exclude
# e.g. custom or hand generated webp conversion files
exclude: []
# append '.webp' to filename after original extension rather than replacing it.
# Default transforms `image.png` to `image.webp`, while changing to true transforms `image.png` to `image.png.webp`
append_ext: true
############################################################
How can i generate .webp
images only on build, or in production environment?
I see quality can be controlled up to 100 (least lossy) but webp has two different "modes" and 100% quality is not the same as lossless and in fact for areas where a transparent png is the best non-webp format, usually webp lossless is superior (file size and quality) to webp lossy 100%.
Is there a way to enable lossless?
It might also be good to be able to configure webp settings per file type - so I can have different settings for my pngs (graphics) than for my jpegs (photos) as it is likely there is not a single set of rules that would compress both types well.
I've been trying to use jekyll-webp to automatically generate webp versions of my images for my jekyll blog, running on GitHub pages.
Unfortunately, the GitHub action shows a convertion error for every single file:
WebP: Conversion for image /github/workspace/images/myimage.png failed, no webp version could be created for this image
Seems like this is related to some other open issues (eg, #15) and jekyll-webp just isn't usable in GitHub actions.
Too bad - I'll have to convert my images manually then...
With append_ext: true, it is expected that images will be generated in the format image.png.webp
. However, that is not the case
I'm using this GitHub action https://github.com/helaili/jekyll-action which enables third-party gems support on GitHub Pages. I can confirm that other third-party gems that I use work fine but this one doesn't. It fails with following error:
WebP: Change to source image file /github/workspace/images/1.jpg detected, regenerating WebP
WebP: Conversion for image /github/workspace/images/1.jpg failed, no webp version could be created for this image
Using some debug logging statements, I noticed 'Permission denied' errors, but sudo doesn't work either.
From the GitHub Actions docs:
The Linux and macOS virtual machines both run using passwordless sudo. When you need to execute commands or install tools that require more privileges than the current user, you can use sudo without needing to provide a password.
Any suggestions on how to proceed?
BTW I also had to add require 'date'
to the jekyll-webp.gemspec file because it wasn't imported automatically.
Moreover, the gem that is installed via gem install jekyll-webp
doesn't seem to work (even locally) which is why I'm pulling the GitHub version of this gem directly.
Hello!
Please, let me ask several questions about your plugin:
All WebP images generated by the plugin will be stored in the same folder, where is the main .jpg image?
If I optimize all my .jpg images using Photoshop. Should I off image optimization (serve) function of the plugin?
And all generated WebP images will be less size, that original .jpg images, right? Because WebP newer and should be less size. than .jpg.
Sorry sir for my bad English. Hello from Kazakhstan! And thank you for your work!
Link to my Gemfile. To reproduce, clone my site and use img_dir: ["/assets/img/posts/"]
and nested: true
.
For quite a while now, I've been manually converting my images to WebP using the cwebp
CLI tool, so I was pretty excited when I found this gem!
Unfortunately, it doesn't appear to work... I see the output saying that it's detected changes to my images and is regenerating their corresponding webp formats:
WebP: Generator Complete: 107 file(s) generated
But... it doesn't actually generate any new files. Or if it does, it's dumping them somewhere else. Git doesn't report any new files, so ๐คทโโ
I'm on Windows 10 and using WSL, if that makes any difference.
Steps to reproduce:
".gif"
to the list of file formats.."gif"
as the gif extension. Conversion for image someImage.gif failed, no webp version could be created for this image
Here's my config:
webp:
enabled: true
# The quality of the webp conversion 0 to 100 (where 100 is least lossy)
quality: 75
# List of directories containing images to optimize, nested directories will only be checked if `nested` is true
# 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.
img_dir: ["/assets/img/"]
# Whether to search in nested directories or not
nested: true
# add ".gif" to the format list to generate webp for animated gifs as well
formats: [".jpg", ".png", ".gif"]
# File extensions for animated gif files
gifs: [".gif"]
# Set to true to always regenerate existing webp files
regenerate: true
# Local path to the WebP utilities to use (relative or absolute)
# Omit or leave as nil to use the utilities shipped with the gem, override only to use your local install
webp_path: nil
All other file formats work.
In your README it says
# List of files or directories to exclude
# e.g. custom or hand generated webp conversion files
exclude: []
but it seems it was never implemented:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.