go-webp
v1.3.1
Published
go-webp is a tool that helps develop convert all images (.png,.jpg and .jpeg) to webp image format by just one simple command line
Downloads
64
Readme
go-webp
go-webp is a tool that helps develop convert all images (.png,.jpg and .jpeg) to webp image format by just one simple command line
why use webp image format
- provides superior lossless and lossy compression for images on the web.
- create smaller, richer images that make the web faster
- WebP lossless images are 26% smaller in size compared to PNGs. WebP lossy images are 25-34% smaller than comparable JPEG images at equivalent SSIM quality index.
- Lossless WebP supports transparency (also known as alpha channel) at a cost of just 22% additional bytes.
why use go-webp package
instead of go to online services and upload you images and convert it to webp then change images name in files where use its
go-webp with one simple line in package.json:
- convert all images (.png, .jpg, .jpeg) to webp format
- remove old format of images (.png, .jpg, .jpeg)
- change images names in files where you use its
Installation
Either through cloning with git or by using npm (the recommended way):
npm install -g go-webp # or using yarn: yarn global add go-webp
And go-webp will be installed globally to your system path.
You can also install go-webp as a development dependency:
npm install --save-dev go-webp # or using yarn: yarn add go-webp -D
With a local installation, go-webp will not be available in your system path or you can't use it directly from the command line. Instead, the local installation of go-webp can be run by calling it from within an npm script (such as npm start
) like the example below or using npx go-webp
.
{
"name": "...",
"version": "0.1.0",
"dependencies": {
"...":"..."
},
"scripts": {
"...": "...",
"webp": "go-webp remove=true change=true"
}
}
then you use
npm run webp # or using yarn: yarn run webp
Usage
By default go-webp change images names in files where you use its but not remove old images format (.png, .jpg, .jpeg) and
go-webp
For CLI options
- use the
remove=true
argument to remove old images format (.png, .jpg, .jpeg)
go-webp remove=true
- use the
change=false
argument to not change images names in files where you use its
go-webp change=false
- you can also combine them
remove=true change=true
to remove old images format (.png, .jpg, .jpeg) and change images names in files where you use its
go-webp remove=true change=true
- use the
excludeFolders="public,api"
argument to exclude folders from convertion
go-webp excludeFolders="public,api"
- use the
excludeFiles="logo.png,favicon.ico,thumbnail.jpeg"
argument to exclude files from convertion
go-webp excludeFiles="logo.png,favicon.ico,thumbnail.jpeg"
Bonus For React Developers: use exclude files for logo192.png, logo512.png, and favicon.ico
{
"name": "...",
"version": "0.1.0",
"dependencies": {
"...":"..."
},
"scripts": {
"...": "...",
"webp": "go-webp remove=true change=true excludeFiles=\"logo192.png,logo512.png,favicon.ico\""
}
}
Support
This package costs me time to make and maintain every time.
[I am very 😀 about every coffee!]