Carl Groth
Carl Groth

Reputation: 97

Wand - Right aligning text with offset

Gravity seemed like what I wanted but it does not let me change the x offset.

bg.caption(f"{xp} / {req_xp}", left=200, top=165, font=montserrat_bold, gravity='north_east')

Correctly offsets in the y direction but no matter what I put for left it remains glued to the right. Is this a bug with wand? I saw several examples of pure imagemagick where alignment seemed possible.

Upvotes: 1

Views: 319

Answers (1)

emcconville
emcconville

Reputation: 24419

Captions are created by building a new bounding box (width x height), and renders the text to fit within the box -- while respecting the gravity parameter. After the text has been rendered, the bonding box is composited at the left x top coordinates of the image.

[...] it remains glued to the right. Is this a bug with wand?

With gravity set to "north_east" & width undefined, the text will remain "glued to the right".

Try the following ...

bg.caption(f"{xp} / {req_xp}",
           left=200,
           top=165,
           width=100,
           height=50,
           font=montserrat_bold,
           gravity='north_east')

Adjust the width= & height= parameter values to respect the pointsize of montserrat_bold variable.

Upvotes: 3

Related Questions