Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shell script for adjusting image size

Is there a way to adjust all image sizes in a directory?

If I set the max size to 800x600 it will make larger ones smaller and leave smaller ones at their original size.

like image 902
Chris Avatar asked Dec 01 '22 08:12

Chris


1 Answers

for img in *.png; do
    convert "$img" "800x600>" $(basename "$img" .png)_new.png
done

convert is from ImageMagick. ">" says it's only resized if larger. See here for its other options.

like image 97
Johannes Schaub - litb Avatar answered Dec 04 '22 04:12

Johannes Schaub - litb