Resizing pictures

Marcelo Magno T. Sales mmtsales at gmail.com
Wed Nov 28 19:29:46 UTC 2007


Em Qua 28 Nov 2007, Rick Stevens escreveu:
> On Wed, 2007-11-28 at 09:50 +0000, John Austin wrote:
> > On Wed, 2007-11-28 at 10:20 +0900, John Summerfield wrote:
> > > Matthieu wrote:
> > > > -----BEGIN PGP SIGNED MESSAGE-----
> > > > Hash: SHA1
> > > >
> > > >    Hello,
> > > >
> > > > I am looking for a software that would allow me to resize
> > > > automatically a bunch of JPEG pictues, while letting me choose
> > > > the compression rate and keeping the EXIF informations. Waht
> > > > could provide that?
> >
> > I have a crude script for "some" of this.
> >
> > As it stands it overwrites the originals !!!
> >
> > John
> >
> > naxos bin 816# cat image_reduce_size
> > #!/usr/bin/perl -w
> > #Reduce size of all *.jpg files in a directory
> > #Parameter 50% say
> > #cd correct_dir; image_reduce_size 50% *.jpg
> > $size = shift @ARGV;
> > print $size,"\n";
> >
> > while(@ARGV){
> >         $file = shift @ARGV;
> >         ($bfile = $file) =~ s#.*/##s;
> >        print $file,"   ",$bfile,"\n";
> >                 `convert -resize $size $file /tmp/$bfile`;
> >                 `mv -f /tmp/$bfile $file`;
> >         }
> > naxos bin 817#

You can do the same in one line using find with mogrify:

find -iname "*.jpg" -exec mogrify -resize 50% {} \;

This will resize all jpg images in the current directory and in the tree 
below it. mogrify is just the same as convert, but it overwrites the 
original file. No need to do that in two steps (convert + mv)

[]'s
Marcelo




More information about the users mailing list