< November 2006 >
SuMoTuWeThFrSa
    1 2 3 4
5 6 7 8 91011
12131415161718
19202122232425
2627282930  
Wed, 08 Nov 2006:

Recently, I've seen a lot of serious photographers start to watermark their images. I'm not one of them (yet), but I hacked up a quick script to watermark a photo in gimp without much fuss. Basically the script lets you paste a transparent image on your image and without actually using a UI.

To install, copy the watermark.py to your ~/gimp/plug-ins/ and chmod +x it. And to use in batch mode, you'd probably do something like this :-

gimp -i -b \
   '(python-fu-batch-watermark 1 
	  "x.jpg" "watermark.png" "y.jpg" "rb" 33.0)' \
'(gimp-quit 0)'

A more sophisticated invocation would avoid spawning a new gimp instance for every image edit and would truly operate in batch mode.

(for each in images/*.jpg; do
    NEWNAME="`echo $each | sed "s/\.jpg$/_wm&/"`"
    echo "(python-fu-batch-watermark 1 \"$each\"" \
            "\"watermark.png\"" \
            "\"$NEWNAME\" \"rb\" 33.0)"
done
echo "(gimp-quit 0)") | tee /dev/stderr | gimp -i -b -

Now that truly shows the power of small bits put together, with the odd bug thrown in for good measure.

--
Great acts are made up of small deeds.

posted at: 05:23 | path: /hacks | permalink | Tags: ,

Tue, 18 Jul 2006:

The problem with taking photos in a moving car is that it is very hard to get the baseline of the photo on the horizontal. So eventually to get a decent pic, you need to rotate the photo. But after rotation, you need to crop it back to a square. All operations which take time and is relatively annoying. So, I wrote a gimp script.

  r = math.sqrt(x*x + y*y)/2
  
  # as calculated for top left corner
  theta = math.radians(45)
  phi = math.radians(45 + angle)
  dx = r * math.cos(phi) - r * math.cos(theta)
  # -1 * because as the angle comes down, our y decreases
  dy = -1 * (r * math.sin(phi) - r * math.cos(theta))

Basically, this python-fu script (rot-crop.py) does both operations together and gives you a cropped rectangular image.


rotated 6 odd degrees

Script-Fu is esoteric stuff, but the python plugins can actually be read, understood and written by mere mortals like me.

--
My geometry teacher was sometimes acute, and sometimes obtuse, but always,
always, he was right.
       [That's an interesting angle.  I wonder if there are any parallels?]

posted at: 02:22 | path: /hacks | permalink | Tags: , ,