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.