Sunday, 25 April 2010

Printing pictures

So today I wrote my first plug-in for the GIMP (it's really just a script but as it's written in Python it goes in the GIMP plug-ins directory).

The reason for the script is that I've found a print lab in the UK that will accept files over the internet and just print them without messing around trying to "correct" them. They give you an icm profile for their printer so that you can convert your images. They're called ProAmImaging. There are other places on the internet that seem to do the same but the sample prints I got from ProAm look pretty good so I'll be using them for now.

Anyway, the flip side of them not touching the images is that I need to scale and crop the images to the exact number of pixels needed for the print size I want. This gets tedious very quickly so I decided to write a script to automate things. What the script does is take an image size in inches, and a desired DPI, and uses them to scale and crop the image to the correct size in one step. It's nothing you couldn't do with the existing tools, but it halves the number of actions you need to do, and does the maths to work out exactly how many pixels to crop automatically.

I'd like to improve it so that it activates the crop tool with the correct aspect ratio so that you can select the crop manually, however it's not obvious to me whether that's even possible so I'll leave that for now.

A couple of things worth noting when writing Python scripts for the GIMP:
  • If python doesn't like your script for some reason the GIMP won't tell you why, your script simply won't appear in the menus. There's probably a way around this but it never got so annoying that I had to figure it out. If you start with a known good script (there are loads at registry.gimp.org) and test regularly it's OK.
  • The GIMP/Python documentation seems to be rather sparse (http://www.gimp.org/docs/python/index.html) and the python object interface is quite small. However you can call all the libgimp methods from Python using pbd.methodName().
  • For debugging pdb.gimp_message("Your message here") is rather helpful.
Please note that this is the first time I've written a GIMP plug-in and almost the first time I've used Python so the take the above with the appropriate dosage of salt.

And finally the script itself - ScaleAndCrop.py, I hope someone else finds it useful.

Tuesday, 20 April 2010

High pass filter effect


This technique has been written about a number of times, not least by Strobist, but I thought I'd see how it works on this rhino rather than a person and what happens if you mess around with it a little.



I use the GIMP for post processing my photos, and by default it doesn't have a high pass filter. So the first thing to do is to head to the GIMP plugin repository to get one.
On Windows put the .scm file in "C:\Documents and Settings\Your User Name\.gimp-2.6\scripts"
On OSX put the .scm file in "~/Library/Application Support/Gimp/scripts"

If all went well you should now have a "High Pass Filter" entry under Filters > Generic.

Now we're all set, so:
Open up the photo you're going to work on
Select Filters > Generic > High Pass Filter
I'm working on a picture that's about 800 pixels wide so in the dialogue I chose:
  • Filter radius: 16
  • Contrast Adjust: 0
  • Mode: Greyscale
  • Keep original layer: Checked

Other values will also work (see below for what happens) but a radius of about 1/50th of the image width is a good place to start.

Change the layer mode on the new grey layer to Hard Light
Tweak the opacity of the layer to taste

The image below has had a different setting applied to each quarter for comparison.

and the original again for comparison:
My favourite here is the radius 16 contrast 0 section. Adding extra contrast to the high pass layer adds contrast to the final image, bleaching out some of the colour. Increasing the radius seems to emphasise larger features turning the effect from a subtleish sharpening effect to something actually affecting the image more obviously.

Saturday, 20 March 2010

Tiger's spider burning bright

I recently bought a game for my iPhone, which in itself is unusual as I don't normally buy things from the iTunes store as I don't like the idea of only being able to use them whilst Apple says I can. The game in question is Spider: The Secret of Bryce Manor (developed by Tiger Style) and in this case a combination of the free demo Spider: Hornet Smash and the fact that Randy Smith was involved was enough to get me to part with the small amount of £1.79.

If you don't want to read any more, I'll say here and now that it's a very good game and if you play games on your iPhone you should buy this one.

As I said I came to the game through the demo; Hornet Smash. The demo uses the same levels as the main game but it takes a small mechanic from the main game and expands it slightly to actually make a fairly different game. Hornet Smash is more fast paced than the main game with greater dynamism as you leap non-stop around the levels tackling as many hornets as you can before inevitably succumbing to the steadily growing number. Playing well will slow the hornets' growth but I don't know if it's possible to play well enough to reach equilibrium.

In contrast, the main game only contains a few (non-multiplying) hornets and mostly plays out at a more sedate pace. The main adventure mode game is based around building webs to catch and eat enough insects in the level to open the portal to the next level. You do this by anchoring a thread to the level and then leaping to a second point to secure the thread between those points. Completely surround an empty space with threads and a web will appear between them trapping any insect that flies over it for long enough. You can anchor threads to webs, allowing you make new webs that were previously impossible. Eating insects will replenish your silk supplies and running out of silk means imminent death (there is a grace period in which to quickly eat an insect). One nice touch is that at the end of a level you are shown the complete room including your cobwebs, giving a feeling of the house gradually becoming more disused and deserted as you travel through it.

After a little practice, if you charge through the game, then the Blitzkrieg acheivement of completing it in under 30 minutes is easily achievable. But, if you do that and then leave the game you'll have missed most of what makes it enjoyable. Rushing through the levels would mean not noticing the many details in the rooms and not finding the numerous secret areas that help to tell the story of the house you are making your way through and the family that lived there. If you find and follow all the clues there is also a secret room to find. (There is also the sealed room which is easier to find but also hidden).

There are also three other game modes, one where you try to eat as many insects as possible in 3 minutes, one where you have to eat insects regularly to avoid dieing (with the frequency increasing as you eat more), and finally a mode very similar to the main game but with your threads shortened and reduced in number which makes forward planning far more important.

According the lifetime stats the game provides I've played it for over 16 hours and have now completed the game, found the secret room, and completed all of the optional achievements which I found rather fun.

So overall an excellent way to spend £1.79, highly recommended.

Saturday, 6 March 2010

New Lens

I recently bought a second hand Nikon 70-210mm f4-f5.6 AF lens from eBay for £65 as I'd read some good things about it, and it comes from the same era as my 35-70mm f2.8 which I like very much (but which was also rather more expensive).

I already have an 18-200 VR so this new 70-210 is going have to be better than that lens to avoid going straight back on eBay.

I set the camera up on a tripod pointing down the garden and took a few shots with each lens at 200mm and 210mm with varying apertures. These are 100% crops from near the centre of the frame (unsharpened). The last shots are shrunk versions of the full image to give an idea of the extra reach the 70-210 has.














These results are a bit disappointing, the 70-210 is clearly putting more pixels over the same area, but I'm not convinced it's actually capturing much more detail (especially at f5.6).

I've also just taken the 70-210 down to the park to take some photos of my daughter, and I've learned how important shutter speed is with this lens at 210mm. I guess I've been spoiled by the VR on the 18-200 but it does seem that you need a shutter speed of 1/400s or faster when hand holding which means you need quite a sunny day to also get down to f8-f11.

That said, I did get some quite nice shots in the park and noticed that it might be front focusing slightly which I should be able to correct for in the camera.

In terms of build quality the 70-210 wins, feeling much more solid. But it loses out in terms of focus speed to the 18-200's built in AFS. The AF-D version of the 70-210 is supposed to focus twice as fast which would certainly help (but they are also rarer and more expensive on eBay).

So for now I'm leaning towards the 18-200 as it's only marginally less sharp, but focuses faster, has VR and can go all the way to 18mm. However, if I didn't already have the 18-200 I'd certainly be happy with 70-210, especially at the bargain price it can be had for.

Saturday, 13 February 2010

Media Hardware

Hopefully the final post in this mini series about my Media PC trials (I'd much rather just be using it!). Most of the hardware in the PC is not particularly important. It's an old Athlon XP on a micro ATX motherboard in an Antec Aria case if you must know :). The imporant parts are the Hauppage WinTV-NOVA-TD 500 with remote control and a wireless Emprex keyboard with built in trackball (you can get one from Amazon here).

The TV card contains two DVB-T tuners allowing us to record two different Freeview channels at once, plus a remote control which works with the provided software and also with at least MythTV and MediaPortal.

The keyboard includes a small trackball, which allows you to completely control a PC without needing an extra mouse. It runs on 4AA batteries and as a pleasant surprise comes with 4 Duracell batteries rather than the usual generic batteries that often come with electronics. The second pleasant surprise is that plugging in the USB dongle and fitting the batteries was all that was needed to get it working. I guess that the dongle must pretend to be a normal keyboard so the computer doesn't need any special drivers to make it work. Whilst the trackball isn't the best in the world it works fine, and given the low price this keyboard is great value for money.

Wednesday, 10 February 2010

Media on Windows

With the new operating system came the choice of what software to use; MythTV on Windows requires you to build it yourself and I didn't fancy going down that road. I started with the software that came with the TV card. This is version 7 of their software and I dread to think what the previous versions must have been like. If you just want to watch TV it's fine, but the UI for recording is pretty poor, and in my case didn't even work. I found a couple of possible solutions on Google, but didn't bother trying them out as I knew there was more user friendly software out there that I wanted to try first.

I tried out GBPVR briefly but the flaky website (Google's cache helps here) and some rough edges put me off. I then went on to MediaPortal. I have used MediaPortal before, but not for TV as my previous TV card wouldn't work with it. On the whole I've been reasonably impressed. The UI is nice and if you tell it you have a Hauppauge remote control it all just works together. There were a couple of things that could have been easier though:
  1. Picking up the programme guide information over the air doesn't seem to work for me which meant I had to follow the instructions here to set up an included tool to get listings from a RadioTimes XML feed. (Although I had to use the XmlTv plugin to read the listing file rather than the WebEPG one).
  2. My first trial recording failed because apparently the TV card takes some time to wake up and so it wasn't ready when MediaPortal looked for it. There is a setting specifically for this under:

    • TV-Server Configuration
    • General Settings
    • Delay for TV card detection
    I set this to 30 seconds and since then it's been fine.

The final problem I've yet to satisfactorily solve is the "Black screen of death" which can happen when you plug a computer into a TV's HDMI socket and then switch the source on the TV. As I understand it, when the source on the TV is switched the HDMI connection to the computer is broken and it gives up on the display. When you switch back to the computer source on the TV the computer doesn't know and continues to ignore the display. You can get round this by getting the computer to re-detect the display but so far the ways I've found are not ideal:
  • Unplug the HDMI connection, wait a couple of seconds, then plug it back in.
  • Put the computer to sleep and then wake it up again.
I've found this program which turns the monitor connection on and off again and can be bound to a particular key combination, but unfortunately doesn't yet work with XP. However, it seems likely that the author will be adding XP support shortly.

To end on a positive note one thing that has worked unexpectedly well is the scheduling plugin. Once enabled you can tell it to put the computer to sleep after a certain amount of inactivity and wake up for recordings. So far it had been hibernating and waking up perfectly which definitely beats having it on all the time. One caveat, if you want to watch a DVD using a different program you need to tell the acheduler not to go to sleep or your viewing will be rudely interrupted by a hibernation screen every few minutes.

Sunday, 7 February 2010

Media on Linux

I've had a media PC sitting under the TV for quite a while now and it's been very useful for recording TV and showing photos to the family. A few months ago I replaced the TV card with one supported under Linux (a Hauppage WinTV-NOVA-TD 500) and thought it would be a good opportunity to learn a bit about how Linux works, plus I'd heard good things about MythTV and wanted to try it out. A few months later the things I have learned are:
  1. With a family and a full time job I don't have the hours of free time needed to get things working, especially when I know I can do the same thing under Windows with far less trouble.
  2. Mythbuntu sounds like a good idea, but when things don't work (which in my experience was all too often) it's another layer of unfamiliarity to work through. i.e. "Is this a problem in MythTV, Ubuntu, or Mythbuntu specifically?". Also walkthroughs for Ubuntu may not work as various tools have been stripped out of Mythbuntu to make it lighter-weight. So if you are familiar with Linux already then Mythbuntu may help, however, if I was doing this again I'd install the full Ubuntu first and then MythTV on top.
  3. MythTV has a pretty slick frontend and when it works it is good. However, it's quite fiddly to set up. If you want to get a TV card IR remote control working at the same time as a USB keyboard and mouse (which may or may not be plugged in at boot time) then be prepared for an unnecessarily convoluted fight with various configuration files. (I believe because the IR receiver in my TV card also looks like a USB device to the operating system.)
  4. For some reason DVDs are jerky under Linux using either VLC or the built in DVD decoder in MythTV. The same (rather old) hardware plays DVDs fine using a free copy of PowerDVD on Windows.
So when DVDs stopped playing altogether it was the final straw. In that particular case it turned out that the DVD drive had actually died but by then the die was cast and Windows XP was back.