Embed images in text
-
- Posts: 4
- Joined: 2012-08-23T07:23:28-07:00
- Authentication code: 67789
Embed images in text
Hello,
I am using RMagick on Windows to render cards. Apologies if this is not the correct subforum, but I couldn't find one that was for RMagick.
I have to use ImageMagick <7.0 because that is what RMagick supports and I am using the latest version that I could find - I believe 6.9.
I want to embed images in my text. I know that ImageMagick is perfectly capable of compositing two images, but the issue that comes to mind is that the image can be anywhere in the text. I also have to deal with things like text-alignment. I saw that Pango might be a possible option, but I am unsure exactly where to progress there. Even a simple convert command would be helpful.
Thanks!
I am using RMagick on Windows to render cards. Apologies if this is not the correct subforum, but I couldn't find one that was for RMagick.
I have to use ImageMagick <7.0 because that is what RMagick supports and I am using the latest version that I could find - I believe 6.9.
I want to embed images in my text. I know that ImageMagick is perfectly capable of compositing two images, but the issue that comes to mind is that the image can be anywhere in the text. I also have to deal with things like text-alignment. I saw that Pango might be a possible option, but I am unsure exactly where to progress there. Even a simple convert command would be helpful.
Thanks!
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Embed images in text
It would help us to know exactly what you are trying to do. Please upload an example image to some place such as dropbox.com and put the URL here. Then explain where you want the image and the text or show an example with an image in the text.
Also please identify your exact IM version and OS/platform. You can get the IM version from
Also please identify your exact IM version and OS/platform. You can get the IM version from
Code: Select all
convert -version
-
- Posts: 4
- Joined: 2012-08-23T07:23:28-07:00
- Authentication code: 67789
Re: Embed images in text
Thanks for your response.
My IM version: 6.9.7-3 Q16 x64, on Windows 10.
Essentially, I would like to treat an image as just another character, where it can be anywhere in a block of text and have the text wrapped around it. So, basically an emoticon, really.
My IM version: 6.9.7-3 Q16 x64, on Windows 10.
Essentially, I would like to treat an image as just another character, where it can be anywhere in a block of text and have the text wrapped around it. So, basically an emoticon, really.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Embed images in text
IM does not have any emoticon or color symbols as a font. So any image and the text on either side needs to be planned out.
You can create three images. The first is a text image create from "I am some text" using the IM function label:"I am some text". The second is your emoticon. The third is your text image create from label:"image". Then you could just append the three images.
See
http://www.imagemagick.org/Usage/text/#label
http://www.imagemagick.org/Usage/layers/#append
Alternately, you can create your text image with a white area where you want the emoticon. Then you can insert the emoticon using -compose over -composite in the proper location.
You can create three images. The first is a text image create from "I am some text" using the IM function label:"I am some text". The second is your emoticon. The third is your text image create from label:"image". Then you could just append the three images.
See
http://www.imagemagick.org/Usage/text/#label
http://www.imagemagick.org/Usage/layers/#append
Alternately, you can create your text image with a white area where you want the emoticon. Then you can insert the emoticon using -compose over -composite in the proper location.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Embed images in text
See http://www.imagemagick.org/Usage/text/#mixed_font_lines. Where you would replace one set of text with your emoticon.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Embed images in text
See also http://www.imagemagick.org/Usage/quantize/#diy_symbols. Though this is not what you want, if you have a black symbol font, you could use Pango to mix fonts and color them as desired.
-
- Posts: 4
- Joined: 2012-08-23T07:23:28-07:00
- Authentication code: 67789
Re: Embed images in text
I had been thinking about using the second method, but I was running into problems on where to put the image when the text wasn't left-aligned. I think the first method will work, however.fmw42 wrote: ↑2017-01-30T10:47:56-07:00 IM does not have any emoticon or color symbols as a font. So any image and the text on either side needs to be planned out.
You can create three images. The first is a text image create from "I am some text" using the IM function label:"I am some text". The second is your emoticon. The third is your text image create from label:"image". Then you could just append the three images.
See
http://www.imagemagick.org/Usage/text/#label
http://www.imagemagick.org/Usage/layers/#append
Alternately, you can create your text image with a white area where you want the emoticon. Then you can insert the emoticon using -compose over -composite in the proper location.
Thanks for pointing me in the right direction!
This link should be helpful. I can always scale the emoticon down to match the size of the font, so hopefully the vertical alignment won't be a problem.fmw42 wrote: ↑2017-01-30T10:58:54-07:00 See http://www.imagemagick.org/Usage/text/#mixed_font_lines. Where you would replace one set of text with your emoticon.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Embed images in text
Here is another thought. You could create a text image with all the text you want, but use some symbol of the right size to match the size of your emoticon image. Then you could do a subimage compare using the symbol image as a template. Then you could have a list of emoticons and a script that would replace each occurrence of the matched icon with the next emoticon in your list.