Created
March 30, 2019 20:07
-
-
Save spagu/85e77c5067e7784bd566047440de40ff to your computer and use it in GitHub Desktop.
Converts any image to webp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/bash | |
# 1. Install ImageMagic | |
# 2.Add “image/webp webp” to the file mime.types ( it should be there already ) | |
# | |
# 3.Add to your main Nginx configuration. | |
# map $http_accept $webp_suffix { | |
# default ""; | |
# "~*webp" ".webp"; | |
# } | |
# | |
# 4. Add to your vhost | |
# location ~* ^/wp-content/.+\.(png|jpg|tiff)$ { | |
# add_header Vary Accept; | |
# try_files $uri$webp_suffix $uri =404; | |
# } | |
# | |
# Usage: | |
# ./any2webp.sh file.jpg | |
# | |
# Output: file.jpg.webp | |
convert -resize 510x340 -strip -interlace Plane -gaussian-blur 0.05 -quality 100% $1 $1.webp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment