HomeHow 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?

Published: 11/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

About Code with Node.js

This is a personal blog and reference point of a Node.js developer.

I write and explain how different Node and JavaScript aspects work, as well as research popular and cool packages, and of course fail time to time.

How to resize all JPGs in a folder to PNGs with a maximum width using FFmpeg? | Code With Node.js