2

I would like to center text vertically and horizontally in an image within Gimp.

I have the image, I have added the text, I have been able to use the alignment tool to center the text horizontally, but it remains at the top vertically.

The test image has one layer with a simple image in it and when I added the text, it created another image. I aligned the text thing (object? box?) so that it covers the whole image.

Any guidance would be appreciated.

3

While editing the text

  1. add two guides that cross at the center of the canvas

  2. while you are using the Text tool depress AltCtrl and drag the text: a small cross will appear over the center of the layer. Move the layer so that this cross snaps on the intersection of the two guides.

After editing the text

You can always reposition the layer using the usual tools, either the Move tool and guides as above, or using the Align tool.

Notes:

  • All these tools work with the boundaries of the layer, not with the text inside it: a layer with TTTT and one with ____ have the same boundaries, but they won't look visually centered if you just center the center of their layer. But this is more a problem with vertical centering, horizontal centering is usually OK.
  • This of course assumes that you keep the text layer at its initial size as produced by the text tool, if you enlarge it to fill the canvas, then Gimp cannot tell where the text is in the layer.
  • If you are sure that you won't edit the text further (or if you make a copy of the layer and hide it for backup purposes), you can use Layer>Autocrop layer to shrink the layer boundaries to just fit the text. Then the Move/Align tools will work using the visual boundaries of the letters. But even this may not be perfect in some cases, see for instance many fonts where round letters (O,C,S,...) extend slightly below the baseline.
4
  • Thank you! I didn't actually end up doing it the way you suggested, but your second bullet gave me the clue. I was thinking that alignment would align the text within the textbox, and so I was making the textbox the size of the image. Once I don't do that, then the align tool works. – Jack Dec 10 '18 at 23:29
  • (It may sound hard & a pain at first, but to put the text vertically within the text box itself: If you don't have the right letter, get a good capital letter to show the topline of the main text [such as a capital E], get the cursor position at that top line, then calculate the difference to the vert pos of the top border of the text box to get delta. Then match that on the bottom... get the vertical location of the baseline (where the bottom of the non-tailed letters are... the bottom of the capital E)... then add the delta... that's where you need to drag the bottom text border to.) – JeopardyTempest Mar 15 at 11:54
  • It's no fun, but gets faster once you get used to doing it. Though true vertically aligning text would be all of our dream come true! But doubt it's a top priority at the moment :-/ – JeopardyTempest Mar 15 at 11:55
  • Actually very complicated. Could work in some simple cases (All caps or CJK characters) but vertically centering is pretty much an aesthetic choice when you have ascenders, descenders, diacritics, etc... One thing that Gimp misses is snapping the baseline of the text... – xenoid Mar 15 at 12:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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