Skip to content

Instantly share code, notes, and snippets.

@flavienbwk
Last active September 19, 2021 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flavienbwk/c10bc4bb398c8e28732d96abe855eee5 to your computer and use it in GitHub Desktop.
Save flavienbwk/c10bc4bb398c8e28732d96abe855eee5 to your computer and use it in GitHub Desktop.
JPG to WEBp conversion in Linux Ubuntu. A good practice for lighter images on websites.
#First install the webp converter by this
sudo apt-get install webp
#go inside the directory where all images are there
#make sure all images are in RGB color mode, otherwise you will get error for CMYK images.
#Convert all images to RGB by this command (you should install ImageMagik to do that)
for f in *.jpg; do convert -colorspace RGB "$f" "${f}"; done
#finally convert all images to Webp format
for f in *.jpg; do cwebp -q 90 "$f" -o "${f%%.*}".webp; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment