23

I want to convert a JPG to transparent and using GIMP I added alpha layers and transparency same way I make a GIF transparent I converted it to PNG but it doesn't display well when I load it on my template:

enter image description here

The original image isenter image description here

Why doesn't it look good when it's made into a transparent PNG? Could I have better luck making a transparent GIF? OR is it the blue colors that don't mix well with the black and I could have more luck using some of the other logos:

enter image description hereenter image description here

Thanks

4
  • 1
    It would be best if you would clarify how you converted it into transparent png.
    – Joonas
    Jan 26, 2012 at 11:43
  • Thanks for the comment. I update the questions with the info that I used GIMP same way I make a GIF transparent. I didn't try making it a gif yet but that would be my alternative step to see if that works better. Jan 26, 2012 at 11:47
  • 2
    I can tell you right now that .gif wont work better. The current quality that your .png image has is not the best that .png can do. However that is the best that .gif can do. So there must be something with the way you do it that just leaves white spots around the logo. ( This could possibly help you journalxtra.com/easyguides/… )
    – Joonas
    Jan 26, 2012 at 11:56
  • Additional weird GIMP 2.8.10 observation: * when transparency is added via "Layer" -> "Transparency" -> "Color to alpha", substraction is made regardless of selection * when you first do "Layer" -> "Transparency" -> "Add alpha channel", then "Color to alpha" will operate only on selection.
    – tomash
    Jan 29, 2015 at 12:14

2 Answers 2

31
+50

The main trick, in my experience, to adding smooth transparency to an image in GIMP is using the Layer → Transparency → Color to Alpha... tool. Of course, you have to know how to use it to good effect — on its own, all it does is make your images look all funny and translucent.

If I take the image you posted above, and just run Color to Alpha on it (picking white for the transparent color, of course), what I get is this:

        Logo after Color to Alpha

As you can see, this image looks fine on a light background. Unfortunately, putting it on a dark background makes the gray elements vanish completely, and the blue parts don't look so great either:

        Logo after Color to Alpha on a black background

The problem is that the Color to Alpha tool did what it was supposed to do: it converted all the white in the original image into transparency. This means that the gray lines became semi-transparent black lines, and the light blue became semi-transparent dark blue.

What we really want, however, is presumably that the basic colors of the text and the other elements of the logo should stay opaque, and only the anti-aliased pixels around their edges should become semi-transparent. To fix this, we need to add some white back into the colors. One way to achieve that, for an image like this where the opaque areas consist mostly of single colors, is this:

  1. Duplicate the layer.

  2. On the lower layer, convert the transparency to a mask by doing Layer → Mask → Add Layer Mask... and selecting "Transfer layer's alpha channel".

  3. After transferring the transparency to a mask, make the lower layer completely white (e.g. using the Bucket Fill tool in "Fill whole selection" mode).

  4. You've now added some white to all the colors of the image, but the interiors of the letters and figures still aren't completely opaque. To make them so, we need to normalize the mask on the lower layer — but, since the different parts of the image have different colors and lightnesses, we need to do it separately for each part.

    To do that, click on the mask of the lower layer in the Layers dialog to edit it, use the Rectangle Select tool to select each distinct part of the image (the "B", the "NANO" and the drawing above them) in turn, and run Colors → Auto → Normalize on each selection.

After doing all that (and optionally merging the layers), the result should look like this:

        Logo after restoring white to opaque parts

If you compare this with the first image above, there's almost no difference to be seen. But see what happens when we put it on a black background:

        Logo after restoring white to opaque parts, black background

Now the colors look opaque, but the background is still transparent and the edges are smooth.

Unfrotunately, you can also see some gray fringing around the letters, especially the "B". I suspect this is mostly because the original JPEG image already suffered from chroma loss in those areas due to lossy compression, it just wasn't so apparent on a white background. There are two ways (that I know of) to try to fix that: you can either manually adjust the mask color levels on the white layer to reduce the fringing, or you can try sampling the solid colors from the letters in the original image and replacing the white on the lower layer white those solid colors (Rectangle Select, Bucket Fill). Or you can even try both.

However, all this is really something you should only try if you have no other choice. A much better solution is to try and find the original vector (AI, SVG, EPS, PDF, etc.) files from which these logos were surely rendered — they should have full transparency information, be free of compression artifacts, and be scalable too! Only if it's really impossible to obtain the originals should you even consider working from low-resolution JPEG files like these.

Also, even if you do end up using the bitmaps, you could still get a much cleaner result by redrawing some of the elements — in particular the text, which seems to be simple Copperplate.

0
2

The problem here is that the image has a "fade-to white" at the edges, and you have not removed this. The fade or anti-aliasing is achieved using greys which become high contrast against darker colors.

I don't use GIMP, but in simple terms, the easiest way work with this is to make a new layer on the bottom of the layer stack and flood fill it with a color obvious, high contrast, and generally not in the image. I often use RGB(255,0,0). This will instantly highlight for you all the areas you need to remove or adjust to get the image to work on any background. You need to remove (not color white) the areas in the upper layers so that you see the red from the bottom layer showing through. When you are done, you remove or hide the contrast layer before exporting the PNG. This contrast layer is especially helpful because you can see the end result without needing to export it to test.

What you want to wind up with is a essentially a single layer with all the transparent portions removed (not white, but transparent). I use layer masks generally to do this, since it is non-destructive, but do whatever needs to be done.

I do think, however, that you will have better results if you reconstruct the elements instead of merely importing the JPEG. Also, the lines in this are really thin and light, and on black they might drop out.

In some cases it is better to conceive of the logo being a stamp or sticker, leave the inner bits white and stroke a 5px white line around the outer edges.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.