PDA

View Full Version : Simple script to mass resize jpgs??



Guardian-Mage
October 29th, 2007, 12:13 AM
I am looking for the easiest and quickest way to take 46 .jpg photos, resize them, say to 25%, and reduce their quality to say 65% and then save them. Is the best way with a shell script or C++ or what and how do I go about doing it?

arsenic23
October 29th, 2007, 12:38 AM
I use phatch for such things:
http://photobatch.stani.be/

jordilin
October 29th, 2007, 12:45 AM
I would go for some scripting with Perl using the Image::Magick module. It should be quite easy. There are already some tools in the repositories to do that if I remember. If you want to do some Perl, just check this web page
http://www.imagemagick.org/script/perl-magick.php

aysiu
October 29th, 2007, 12:50 AM
I would also recommend ImageMagick. It doesn't even have to be a script. It can just be a one-line command (supposing all the images are in the one folder).

meatpan
October 29th, 2007, 12:53 AM
I Agree with the above users, and would like to add that the 'convert' program (which is from the ImageMagick package) will get the job done. convert -resize <file-1.jpg> <file-resized.jpg>

rustalot
October 29th, 2007, 02:25 AM
You should take a look here: http://www.imagemagick.org/Usage/ . It will be very helpful.

I imagine if you want to resize all jpegs in directory foo, you could do something like


#!/bin/bash
#script to resize jpegs

for i in *.jpeg
do
(resize command)
done


If there's something wrong with my bash, let me know...

dwhitney67
October 29th, 2007, 02:37 AM
I uses this script to make my thumbnails:


#!/bin/bash

FILES=*.jpg

mkdir -p ./thumbs

for i in $FILES
do
echo "Processing image $i..."

/usr/bin/convert -thumbnail 200 $i ./thumbs/thumb.$i

done

trak87
October 29th, 2007, 02:43 AM
Install ImageMagick and do it as a one line command as aysiu says. I just tested this and it works:


for i in *.jpg; do convert -resize 25% -quality 75 "$i" "$i"_smaller.jpg; done

You will end up with a new set of files with the word "smaller" in them. To be on the safe side, back up the original images before doing running the command.

ThinkBuntu
October 29th, 2007, 02:53 AM
Use the "mogrify" command in imagemagick. Works very, very well.

Guardian-Mage
October 29th, 2007, 12:13 PM
for i in *.jpg; do convert -resize 450x400! -quality 65 "$i" thumb/"$i"; done


works fine thanks