Hi Magick People!
Is it possible to position an image relative to a piece of text? I'm new to IM and have managed to position a line of text exactly but now I would like to add an image at the end of the text.
I don't know where the text will end, in terms of pixel position, and would like to position the image adjacent to it, relative to the position of the text, eg. X pixels to the right of the end of the text.
Is this possible?
Many thanks in advance IM ninjas!
R
Positioning image relative to text?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Positioning image relative to text?
How do you create the text? You could create it as an image. Then you know the dimensions, and can composite it wherever you want, and you know where the right and bottom edges will be.
snibgo's IM pages: im.snibgo.com
Re: Positioning image relative to text?
Thanks for the reply. I dont know the width of the image as this will be a script running thru several lines so different text/image blocks will have different lengths.
Is there actually a way to find out the width of an image and position another image relative to each other?
Is there actually a way to find out the width of an image and position another image relative to each other?
- GeeMack
- Posts: 718
- Joined: 2015-12-01T22:09:46-07:00
- Authentication code: 1151
- Location: Central Illinois, USA
Re: Positioning image relative to text?
There are a few ways to approach this. If you let us know what platform you're working on and which version of ImageMagick you're using we can point you in the right direction. If you have any example before/after type images that would be helpful, too.r2997790 wrote:Is there actually a way to find out the width of an image and position another image relative to each other?
Re: Positioning image relative to text?
Thank you. I am using a Windows PC running Windows 10 using the latest version of IM. (Later I'm hoping to put it on a webserver and run it automatically).
The task I'm trying to acheive is to place an emoji at the end of a username and there will be a series of usernames eg.
Scott *smiley face*
Samantha *sad face*
Jo *laughing*
The names are read from a data file. I don't know how long they will be.
I'd like to place the emoji image 10px to the right of the name text. The emoji will be a fixed known size. The text (name) will vary.
Thanks for your help!
R
The task I'm trying to acheive is to place an emoji at the end of a username and there will be a series of usernames eg.
Scott *smiley face*
Samantha *sad face*
Jo *laughing*
The names are read from a data file. I don't know how long they will be.
I'd like to place the emoji image 10px to the right of the name text. The emoji will be a fixed known size. The text (name) will vary.
Thanks for your help!
R
- GeeMack
- Posts: 718
- Joined: 2015-12-01T22:09:46-07:00
- Authentication code: 1151
- Location: Central Illinois, USA
Re: Positioning image relative to text?
One approach would be to make your usernames as labels, essentially separate images, and "+append" your emojis to each username. Then "-append" all the labels to create a single output image. An example from a Windows 10 command line using ImageMagick 7 might look something like this...r2997790 wrote:I'd like to place the emoji image 10px to the right of the name text. The emoji will be a fixed known size. The text (name) will vary.
Code: Select all
magick -bordercolor none -background none -pointsize 24 ^
( label:"Scott" smilyface.png -border 5x5 +append ) ^
( label:"Samantha" sadface.png -border 5x5 +append ) ^
( label:"Jo" laughing.png -border 5x5 +append ) ^
-append output.png
Re: Positioning image relative to text?
GeeMack, you are very kind and generous. Thank you for your fantastic suggestion. I'll give it a go!