Mikko Koppanen has another image tutorial posted to his blog today - this time the focus is on padding a thumbnail with the color of your choice automatically.
Today's example originates from a question asked by a user. How do I thumbnail the image inside given dimensions proportionally and fill the "blank" areas with a color? Well, the answer is here.
His code pulls in the source image, generates a thumbnail from it and makes a new image (the background) that's a bit bigger than the thumbnail. From there, the thumbnail is laid on top and the whole thing is output as another PNG. An example of the input and output image is included.