I was going around trying to center the contents of a png image with anti-aliasing, and I imported the image into GIMP - but then I realised I didn't know how to select all the non-transparent pixels inside it.

My first thought, and that of many other answers on stack exchange, was to use Alpha to Selection - but it doesn't actually select all the non-transparent pixels. It has an arbitrary cut-off point, and some pixels with alphas of more than zero weren't selected - of course, that certainly won't work properly if I want to move the selection.

Does anyone know what I'm missing?

  • Your question puzzles me. Can't you just move the whole layer? There is normally no need to make a selection to centre a graphic.
    – Billy Kerr
    Oct 2, 2021 at 11:45
  • @BillyK Well then, how can I center it? Oct 2, 2021 at 12:50
  • With the move tool.
    – Billy Kerr
    Oct 2, 2021 at 15:25

2 Answers 2


Alpha to selection selects all the pixels but proportionally to their opacity (the "marching ants" are telling you where the selection level goes from >50% to <50%). This selection is fine from many things, but not to copy/paste the contents(*). If you want to have them fully selected you have to Select > Save to channel, threshold the saved channel with a value of 1, and then re-create a selection from the channel (right-click, and Channel to selection). But this is not necessary, to center you contents there are at least two techniques:

Method #1:

Layer > Crop to content: this makes the smallest layer that contains all the non fully transparent pixels. You can then center this.

Method #2:

If you want a selection, use the Color selector, set Select by: Alpha, check Select transparent areas and set the threshold to 0. Then click on the layer's background. This will only select the fully transparent pixels. Select > Invert and you have the selection that you originally sought.

Also, keep in mind that centering is somewhat visual when you have semi-transparent pixels on the edges. This is why in many fonts, characters with a round base (C,G,O,Q,U) slightly extend below the baseline.

(*) Because a half-opaque pixel, being half-opaque, will be half-selected, and therefore half-copied. When pasted, the half-copy of the half-opaque will be quarter-opaque which is much more transparent. This makes things look thinner.

  • Neither of those worked, but I didn't know about the Select by Color tool - so thanks for that! I tried doing something a bit different from Method #2, and that worked. Edit: Oh wait, Method #2 did work - but Select transparent areas needed to be on. Oct 2, 2021 at 7:59
  • OK, fixed answer
    – xenoid
    Oct 2, 2021 at 8:08

The Select by Color tool

The tool called Select by Color does exactly what is needed to select all the opaque pixels in a layer. All you need to do is to select Alpha in the Select by dropdown, and drag Threshold all the way to the right.
Then, click in any opaque area of the layer, and all the non-transparent pixels will be selected!

So basically, all you need to do is this:

  1. Select the Select by Color tool.
  2. Select Alpha from the Select by dropdown.
  3. Drag Threshold all the way to the right - that'll probably be 255.
  4. Click on any non-transparent pixel in the layer.
  5. And voila! All the non-transparent pixels in the layer are selected.
  • Exactly, and if the background isn't 100% transparent, it is selected. My technique works form the other end, you select the pixels that are exactly as transparent as the background, and then take the other ones.
    – xenoid
    Oct 2, 2021 at 10:49
  • can we do same in photoshop? if so how Jan 14, 2023 at 18:33

Your Answer

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

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