About
This article shows you how to scale image in a dirctory with ffmpeg and conserve the aspect ratio.
Because ffmpeg is a video management tool, it can also modify a frame, in other word, an image.
Steps
Create a directory to get all new images
In this tutorial, we create image of 1920 width. Therefore we create a new directory called 1920.
REM cd /directory/where/you/have/your/images
mkdir 1920
Call ffmpeg for each image
Test with one image if your transformation parameters give the expected result.
For example, in this case, we scale the image down to 1920 pixles
ffmpeg -i input.jpg -vf scale=1920:-1 1920/input.png
Loop over the images and call ffmpeg for each image
In your favorite shell, use the loop structure and call the ffmpeg command
Example:
- dos and its dos for
for %v in (*.jpg) do ffmpeg -i %v -vf scale=1920:-1 1920/%v
- bash and Bash - For Statement