Home โ How to resize all JPGs in a folder to PNGs with a maximum width using FFmpeg?
How to resize all JPGs in a folder to PNGs with a maximum width using FFmpeg?
By Alexander Kuzmenok ยท Node.js & JavaScript developer
Published November 2, 2023
FFmpeg is not only for converting videos, you know? I'll go straight to the point, here's how I use it.
This one command will get all JPGs in a folder, convert to PNGs and downscale it if it's more than 512px width:
for i in *.jpg; do ffmpeg -y -i "$i" -vf "scale='min(512,iw)':-1" -sws_flags bilinear "${i%.*}.png"; done