Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

Batch-convert pictures in command line

Writer Andrew Henderson

I would like to convert a large number of pictures in Konsole. I need pictures resized in order to make a video.

I can do it for one picture; I am satisfied with this command:

convert video000001.png -filter Lanczos -resize 50% toto000001.jpeg

So my question is how can treat the case with a lot of pictures?

1 Answer

You can do it with a simple script. Just create a folder with all the images you want to convert and launch the following script in the same folder :

img_convert.sh

#!/bin/bash
FILES=*.png
mkdir -p ./converted
for i in $FILES
do echo "Processing image $i..." /usr/bin/convert "$i" -filter Lanczos -resize 50% ./converted/converted_"$i".jpeg
done 

Edit:

@pzkpfw pointed out you can simply run this command in your shell for the same result :

for i in *.png; do convert "$i" -filter Lanczos -resize 50% converted_"$i".jpeg;
3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy