Manualmsdos
Manualmsdos

Reputation: 1547

How to reduce size of several photos in bash?

I want to leave a feedback on aliexpress.com, but this site does not accept photos larger than 5 MB. Can I write a simple bash script to reduce size of several photos at the same time?

for file in *.JPG; do echo 'reduce size image here'; done

Thanks for any help.

Upvotes: 0

Views: 869

Answers (1)

Aman Gupta
Aman Gupta

Reputation: 440

for img in *.JPG; do
        convert "$img" -resize "1280x960>" $(basename "$img" .JPG)_new.jpg
done

here is the pixel format for photo size less than 5 MB

Image Dimensions in Pixels  Printed Size (W x H)    Approximate File Size (CMYK Tiff)
1024 x 768 pixels           3.41" x 2.56"           3 Mb
1280 x 960 pixels           4.27" x 3.20            4.7 Mb

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

Upvotes: 4

Related Questions