Few days ago I wrote about how to Resize all pictures in a folder and create animated GIF in Linux Bash with ImageMagick. Checking the page speed with Google Lighthouse the speed score was terrible. So I followed the instructions and tried to do better. Here are the commands for creating WebP
format rather than GIF
. I am still not able to embed the WebP
format in an easy way on this blog. But I will try to do so next time.
Install ffmpeg
sudo apt install imagemagick sudo apt install ffmpeg
Resize all JPG images starting with PXL in a originals folder to 30% of its original size to downscaled folder
cd ~/downloads convert originals/PXL*.jpg -resize 30% downscaled/PXL.jpg
Create ffmpeg-list.txt file as a list of files for ffmpeg
ls downscaled/*.jpg | sort -V | xargs -I {} echo "file '{}'" > ffmpeg-list.txt
Create a WebM of all JPG images
ffmpeg -r 25 -f concat -i ffmpeg-list.txt -c:v libvpx-vp9 -pix_fmt yuva420p wooden-house-construction.webm