batch manipulation

ImageMagick is your friend

To chop the top from a directory of images:

    mogrify -chop 0x160 *.jpg

To convert them to monochrome

    mogrify -monochrome -format png *.jpg

of for sometimes better results using

    for FILE in training02.jpg training03.jpg training05.jpg;do convert $FILE -colorspace gray +dither -colors 2 -normalize ${FILE/.jpg}.png;done

    mogrify -colorspace gray +dither -colors 2 -normalize -format png *.jpg

If you process a lot of images, you want to use a shell loop instead of globbing, as ImageMagick reads all files specified into RAM at once. That can blow up your system. Notice the use of convert as opposed to mogrify. convert works better in shell loops for some reason. (they may use different arguments) There may be a more creative way to rename the files in the first command rather than take a second step.

    for FILE in `ls *.jpg`;do convert ${FILE} -colorspace gray +dither -colors 2 -normalize ${FILE}.png; done
    for i in *.jpg.png; do mv $i ${i/.jpg}; done
 
 
 


 

Add Captions in Windows

 
Modern photo management systems, such as picasa, use built in jpeg tags to caption photos. The old method was to simply set the file name. The old method doesn't lend itself well to the web however. To batch add captions based on file names requires the exiv program and a batch script.
PATH=%PATH%;c:\program files\exiv2-0.14-win
FOR %%c in (*.jpg) DO exiv2 -k -M"add Iptc.Application2.Caption %%c" "%%c"

I tried this using a FORFILES loop, but the added quote marks added by that looping mechanism seem to be incompatible with exiv.

Comments