Tetsu
Tetsu

Reputation: 213

resize images by using shell script

I want to resize multiple .jpg and .png images by using bash shell script.

The following script works fine, but I don't want to write same things twice.

for image in *.jpg; do
  mogrify -resize x1000 "${image}"
done

for image in *.png; do
  mogrify -resize x1000 "${image}"
done

How can I filter jpg and png images at once?

Upvotes: 5

Views: 3746

Answers (1)

user142162
user142162

Reputation:

shopt -s nullglob
for image in *.jpg *.png; do
  mogrify -resize x1000 "${image}"
done

Upvotes: 6

Related Questions