Sunday, April 12, 2009

Transparent Background Revisited

Yes: WOW. This is such a simple tutorial, but it's probably one which many of you have considered and (maybe) not quite gotten away with. Avid reader "D" has a Visio document which he saved in .bmp format, and now he wants to open it in GiMP and take the diagram out of the source file and create a new file in which the background is transparent.

Excellent.

I've created a source file for us to use, thus:


This is a fairly-rudimentary example of what "D" is thinking about, but it's a size we can work with and see what's about to happen to our image.

Now, this image is 488x488, so our first step is to create a target image of the same dimensions with a transparent background, thus:


Now go back to our source image and select the white background using the "magic wand" tool. After the white is selected, go under the "Select" menu and choose "Invert" and then "Grow...", telling GiMP to grow your selection by 1 pixel.


What you have now is a selection of your image which is mostly protected from the jaggies -- the rough pixels which will make your final use of the image mostly perfect. I say "mostly" perfect for a reason we will discuss in a minute.

Copy that selection and go back to your transparent target image.

Now, when you "paste" what you have copied from your source image into the target, your "Layers" dialog is going to look something like this:


Right? The pasted stuff is in a "Floating Selection (pasted layer)", which is deceiving -- because it needs to be anchored to the transparent layer so we can go on.

Just click the little anchor button in the "Layers" dialog, and let's move on.

Now, the last step here is critical -- because the n00b will think, "well, just save as a .gif now, and I'm golden.

NO. You are NOT golden. See: a .gif file requires the image to be in INDEXED color mode to save exactly as you see it, so first you have to go into the "Image" menu, and under "Mode" select "Indexed".

This will produce this dialog, for which you should make the options look exactly like this:


And this really will have two effects on this image. The first is one you may or may not care about, but by reducing the color pallet to 16 colors, you will make the file significantly smaller. But the second is the real money-maker: this allows the GiMP to save the image as a transparency when you save.

Now, before we save, let's look at this image one last time. I know all of you by now have noticed the white border around the image. This isn't really all white: it is the field in this image where all jaggies get buffered to some intermediate color so when you lay it over some other image, the original image on transparency doesn;t have all manner of jagged edges. It simply has a one-pixel wide white boundary which, in most circumstances, is totally agreeable to the eyes. And this is especially useful when your source image isn't as high-res as this one is: it protects the original image from completely disintegrating when you paste it over something else.

So now we're going to save the target image thus, using "Save as ...":


And when the "GIF" dialog comes up, just click "Save". And what you should get in the end is this:

And the chopped-off parts here are Blogger's fault. But notice that my image shows the gray of the background through without making you crazy from looking at jaggedy edges.

Makes sense? I knew it would.

Friday, April 3, 2009

GiMP vs Photoshop, revisited

via Facebook, I found this link which talks about how to make GiMP more Photoshop-user friendly.

I have read it, but not tried all the suggestions. However, I figured you readers might find the info useful.

HT: Jon Swerens.