Technology weblog

Tuesday Nov 28, 2006

Batch processing pictures on the command line

If you have a lot of holiday pictures to process, the command line interface may provide exactly what you need:

  • To rename all pictures according to the date they were taken (based on the EXIF information contained therein):
    $ for i in *.jpg; do jhead -n%b-%d-%G_%R:%S $i; done
  • To scale all pictures by a factor of 0.25, invoke
    $ for i in *; do convert -scale 25%x25% $i `echo $i | sed -e 's/.jpg//g'`_sm.jpg; done
  • To rename all the small pictures in such a way that the "_sm" suffix disappears, use
    $ for i in *; do mv $i "`echo $i | sed -e 's/_sm.jpg//g'`.jpg"; done
We assumed that jhead and ImageMagick are present on your Linux system.

The tables with holiday pictures on my home page have been generated on these processed images using the webgallery program This relatively simple program does a wonderful job.


Post a Comment:
Comments are closed for this entry.

Hire us