Chris
Chris

Reputation: 9529

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.

Upvotes: 5

Views: 3757

Answers (3)

Johannes Schaub - litb
Johannes Schaub - litb

Reputation: 507343

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.

Upvotes: 14

Alnitak
Alnitak

Reputation: 340045

Various packages exist for command line or script driven manipulation of image files.

I'd suggest looking at netpbm, or ImageMagick. Personally I prefer the former as it's far simpler to use.

Upvotes: 2

dusoft
dusoft

Reputation: 11479

image magick package needs to be installed: mogrify -resize 320x240 *.jpg where 320 = width, 240 = height

or you can just leave width parameter: mogrify -resize 320 *.jpg and rest will be taken care of.

Upvotes: 2

Related Questions