Monday, March 8, 2010

Easy way to scale images

Goal: A bucket full of images from Bike week to upload to Flikr.

Issue: Images are to big to upload.

Solution 1: edit each pic manually.

Solution 2: script scaling.

I went with Solution 2.
  1. Installed Imagemagick ( exe
  2. I have cygwin to script, you'll need it.
  3. create script in directory with images:
  4. Run script.
Script:
#!/bin/bash

for i in `ls *.JPG`;
do
n=`echo $i| awk -F "." '{print $1"a."$2}'`
echo $n
/cygdrive/c/Program\ Files/ImageMagick-XXXX/convert.exe $i -scale 800x600 $n
done


That is it. This will convert all JPG files in directory to 800 x 600, creating a copy with an 'a' in the name.

You are welcome. :)

No comments: