Scripting Imagemagick (was Re: [plug] Scripting Gimp)

Peter Wright pete at flooble.apana.org.au
Tue Oct 28 23:47:30 WST 2003


On 29/10 02:44:09, Kimberly Shelt wrote:
> On Tue, Oct 28, 2003 at 11:20:01PM +0800, Ben New wrote:
> > >Yes, but why not use ImageMagick for that?
> > >
> > >mkdir lowres
> > >for i in *.jpg; do
> > >    convert -size 320x200 -quality 55 $i lowres/$i;
> > >done
> > >
> > >Or Konqueror? (-: Ctrl-I or Tools/Create Image Gallery.
> > >
> > >Cheers; Leon
> > 
> > I've only just discovered the ImageMagick convert utility since I read 
> > about it here... I was wondering the same thing as the original poster.
> > 
> > Anyway running the above creates output images that are not 320x200 in 
> > size... (They are 512x384).  Changing the -size to -resize does, but it 
> > runs really slowly.  Using both -size and -resize seems to work faster 
> > and give the right sized output:
> > 
> > convert -size 320x200 -resize 320x200 -quality 70 input.jpg output.jpg
> 
> Did everyone stop using mogrify somewhere along the line..

If it makes you feel any better, I still use mogrify, not convert. In
fact I only just became aware of convert in this email...

But it looks like while mogrify and convert can do exactly the same
thing for the purpose described by the original poster, mogrify is
probably more appropriate for the specific task required. Maybe. :)

convert(1) man page extract:

  DESCRIPTION
     Convert converts an input file using one image format to an
     output file with a differing image format. In addition, various
     types of image processing  can  be performed on the converted
     image during the conversion process. Convert recognizes the image
     formats listed in ImageMagick(1).
  
  EXAMPLES
     To make a thumbnail of a JPEG image, use:
  
         convert -size 120x120 cockatoo.jpg -resize 120x120
                 +profile "*" thumbnail.jpg
  
     In  this example, '-size 120x120' gives a hint to the JPEG
     decoder that the image is going to be downscaled to  120x120,
     allowing it to  run faster by avoiding returning full-resolution
     images to ImageMagick for the subsequent resizing operation.


mogrify(1) man page extract:

  DESCRIPTION
     Mogrify  transforms  an image or a sequence of images. These
     transforms include image scaling, image rotation,  color
     reduction,  and others.  Each  transmogrified image overwrites
     the corresponding original image, unless an option such as
     -format causes the output filename to be different from the
     input filename.
  
     The graphics formats supported by mogrify are listed in
     ImageMagick(1).
  
  EXAMPLES
     To convert all the TIFF files in a particular directory to JPEG,
     use:
  
         mogrify -format jpeg *.tiff
  
     To convert a directory full of JPEG images to thumbnails, use:
  
         mogrify -size 120x120 *.jpg -resize 120x120 +profile "*"



Interestingly enough, I've never used the -resize option - I've only
ever used -geometry, eg.

for i in * ; do mogrify -geometry 10%x10% $i ; done

...to shrink a collection of .jpg files to 10% of original height/width.

> why do I feel like I type this kind of sentance a lot :(
> I am going grey :)

Join the club. ;)

> Kim

Pete.
-- 
http://akira.apana.org.au/~pete/
"On May 26, 1972, two students at Princeton University took the
programming community if not by storm, at least by mild sprinkle when
they released INTERCAL. They were summarily dismissed from Princeton
and forced to flee to a small banana republic where they refine the
finer points of the language on political prisoners."
    -- "Abstraction and Modularity in INTERCAL", D. Alexander Garrett
_______________________________________________
plug mailing list
plug at plug.linux.org.au
http://mail.plug.linux.org.au/cgi-bin/mailman/listinfo/plug


More information about the plug mailing list