Saturday, 25 April 2009

Batch Image Editing using Script-Fu & GIMP

I have a large number of bitmap images which i need to include in a latex document. I didn't want to manually scale the images and save them to PNG format so I looked for ways of automating GIPM. Script-Fu is the language/interface for GIMP. It is unlike any other language I have used before and so it took me a little time to work out what was going on.

The script below, when saved to ~/.gimp-2.6/scripts/ directory can be used to convert any image file to a PNG and scaling it in the process to 150px by 150px.

(define (chris infile outfile)
(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE infile infile)))
(drawable (car (gimp-image-get-active-layer image))))
(gimp-image-scale image 150 150)
(file-png-save-defaults 0 image drawable outfile outfile)

To run it from the terminal:

gimp -i -b '(chris "infile.bmp" "outfile.png")' -b '(gimp-quit 0)'


Or to run this automatically on all bitmap files within a directory use this bash script:

#!/usr/bin/env bash

for myfile in *.bmp
echo Converting $myfile...
gimp -i -b "(chris \"$myfile\" \"$myfile.png\")" -b "(gimp-quit 0)"



Thursday, 23 April 2009

Student Robotics Competition 2009

After a year of hard work and preparation the second ever Student Robotics competition happened last Sunday at Southampton University. A film of the event has already been edited and does a far better job of describing the event than I can. This will appear on the site as soon as I encode it into something which isn't half a gigabyte. Instead I want to dedicate this blog post to look forward to the next competition.


The first meeting after the competition is usually the most fun as everyone, regardless of their technical involvement has ideas and suggestions of how we can make SR better. Yesterday's meeting was no exception and at least 3 whiteboards of ideas were generated. The criticism which has captivated my imagination is that the was a distinct lack of competitive spirit on the day. This manifested itself as:
  • Limited interaction between teams
  • General calmness on the day, no frantic hacking or code writing
  • Poor team images - some teams didn't have names or proper flag
Whilst the more technical failures of the day can be solved with a palette of probes and debugging equipment, this problem requires a different approach. It was reassuring to hear everyone's wide-ranging ideas for how to make this better but it is clearly a difficult question to answer.


Here are some of my favourite suggestions from yesterday's meeting:
  • Online blogs for every teams - Students are encouraged to take loads of photos and blog about their progress. There is an award (publicised from the start) for the best online presence and we try to push this as being almost as coveted as first prize (like First)
  • Robot Showcase - At the start of the competition, each team exhibits their robot in the arena to intimidate other teams and encourage competitism.
  • SR Points - Teams can score points before the competition day by achieving certain milestones. This could be for being the first to post X blog posts or the first to demonstrate a working ball launcher or for helping another team solve their technical problem. Points could also be awarded for posting helpful responses in forums
  • Kickstart reminders - When we have the `year in an hour' build session at Kickstart, we take photos of progress after each `month' and then during the year when students log in they are first presented with a picture of their progress for the equivalent month. For most teams this will be an incentive to work harder!

Fostering a strong online community is clearly a difficult task, you need only look at the comments on youtube for evidence of this - however we are in a good position to do so, since we have a large group of sixth form students with a common interest in robotics and hopefully a desire to win.