Batch-convert pictures in command line
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.jpegSo 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