position text string immediatly before another text string
position text string immediatly before another text string
I have a the following text "FROM £1.99" that I want to generate.
The problem is I want the "FROM" to be a different size font to the "£1.99".
Is there any way to place the "FROM" next to the "£1.99" ? I tried using -repage but that sets the canvas to the middle of the £1.99, what I need is to set the it to the far left of the price.
The problem is I want the "FROM" to be a different size font to the "£1.99".
Is there any way to place the "FROM" next to the "£1.99" ? I tried using -repage but that sets the canvas to the middle of the £1.99, what I need is to set the it to the far left of the price.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: position text string immediatly before another text stri
I believe if you use PANGO you may be able to change font colors in one command. See http://www.imagemagick.org/Usage/text/#pango
Re: position text string immediatly before another text stri
Pango looks very very interesting. I don't know how I've not come across it before!
I'll give it a go, thanks alot!
I'll give it a go, thanks alot!
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: position text string immediatly before another text stri
It is relatively new in IM. see http://www.imagemagick.org/script/changelog.php
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: position text string immediatly before another text stri
The only other way is to use two different labels and append them. Getting baselines aligned is another matter entirely but even that is do able.
See IM examples, Text Handling, Creating Lines of Mixed Font Styles
http://www.imagemagick.org/Usage/text/#mixed_font_lines
Other people have used font metrics to annotate each text correctly relative to each other, and even wrote scripts to do this. See the links from the above examples section.
See IM examples, Text Handling, Creating Lines of Mixed Font Styles
http://www.imagemagick.org/Usage/text/#mixed_font_lines
Other people have used font metrics to annotate each text correctly relative to each other, and even wrote scripts to do this. See the links from the above examples section.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: position text string immediatly before another text stri
anthony, that's where I was before pango, but couldn't work out how to position the fonts.
I was looking for something similar to the draw text position.
I'll take a look at those examples though.
I was looking for something similar to the draw text position.
I'll take a look at those examples though.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: position text string immediatly before another text stri
Make two text images on transparent background using label:. Add whatever padding between the two that you want. See either -border or -splice. Then +append the two images. Then overlay them onto your background image.
see
http://www.imagemagick.org/Usage/text/#label
http://www.imagemagick.org/Usage/crop/#border
http://www.imagemagick.org/Usage/crop/#extent
http://www.imagemagick.org/Usage/crop/#splice
http://www.imagemagick.org/Usage/layers/#append
http://www.imagemagick.org/Usage/layers/#convert
see
http://www.imagemagick.org/Usage/text/#label
http://www.imagemagick.org/Usage/crop/#border
http://www.imagemagick.org/Usage/crop/#extent
http://www.imagemagick.org/Usage/crop/#splice
http://www.imagemagick.org/Usage/layers/#append
http://www.imagemagick.org/Usage/layers/#convert
Re: position text string immediatly before another text stri
I got to a point where I can do what I want with labels as suggested. Now what if I want to add a gradient to the text? Is that possible with labels, or will I have to use -annotate? If so, can I use +append with -annotate?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: position text string immediatly before another text stri
eekaleek wrote:I got to a point where I can do what I want with labels as suggested. Now what if I want to add a gradient to the text? Is that possible with labels, or will I have to use -annotate? If so, can I use +append with -annotate?
Gradients for the background or the letters?
Either way, one approach is the create your text as black on white and use that as a mask to overlay your actual text onto a gradient so that either the background is gradient or the text is gradient.
If this is not what you are inquiring about, please explain further or give some example.
Re: position text string immediatly before another text stri
Gradients for the letters is what I meant.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: position text string immediatly before another text stri
I am pretty sure that -tile gradient: does not work for label (possibly only if you specify the image size). So the two choices I see are using label once to get the image size you need and then repeating with -annotate. This is what I do in my texteffect script (link below). Or doing what I suggested above creating a label image, then a mask image, then a gradient image (all the same size). Then using the mask image to overlay the gradient where the letters are. However, to create the mask image, you will need to know the size of the image created by label. So it seems the first solution is a bit easier.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: position text string immediatly before another text stri
Note that while label: does not directly apply a pattern (only solid colors), -annotate can.eekaleek wrote:I got to a point where I can do what I want with labels as suggested. Now what if I want to add a gradient to the text? Is that possible with labels, or will I have to use -annotate? If so, can I use +append with -annotate?
http://www.imagemagick.org/Usage/text/#annotate
Doing this may interfer with whatever you are using for aligning multi-font text strings.
However once you have a black and white text labels, you can replace those colors with whatever you want, either using solid colors using +level-colors or using the lable image as a mask for a Composition to select the source colors from gradient or patterned images.
See Level-Colors (solid colors)
http://www.imagemagick.org/Usage/color_ ... vel-colors
And Coloring Labels (using color pattern image)
http://www.imagemagick.org/Usage/text/#coloring_text
I have added a 'level-color' example to the latter 'coloring text' examples area. Update to appear in a few hours.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: position text string immediatly before another text stri
Can you create a label and use it as a mask in one command instead of creating the label as an image, then using that image as a mask?
Here is the command I currently have:
convert "master/4289_banner-lg2_MASTER.jpg" \( -gravity SouthWest "tabs/bottom_bar.png" \( -pointsize 20 -background transparent -fill '#ffffff' -font "fonts/SST-ROMAN.TTF" -draw 'text 10,13 "Buy Now!"' \) \) -compose Over -composite -gravity SouthEast \( \( -pointsize 15 -background transparent -fill '#ffffff' -font "fonts/SST-MEDIUM.TTF" -splice 0x21 "label:From" \) \( -pointsize 30 -background transparent -fill '#ffffff' -font "fonts/SST-MEDIUM.TTF" -splice 0x8 "label:14" \) \( -pointsize 15 -fill '#ffffff' -font "fonts/SST-MEDIUM.TTF" -background transparent -splice 0x21 "label:,49 kn" \) +append \) -compose Over -composite output/4289_banner_lg2.jpg
Here is the command I currently have:
convert "master/4289_banner-lg2_MASTER.jpg" \( -gravity SouthWest "tabs/bottom_bar.png" \( -pointsize 20 -background transparent -fill '#ffffff' -font "fonts/SST-ROMAN.TTF" -draw 'text 10,13 "Buy Now!"' \) \) -compose Over -composite -gravity SouthEast \( \( -pointsize 15 -background transparent -fill '#ffffff' -font "fonts/SST-MEDIUM.TTF" -splice 0x21 "label:From" \) \( -pointsize 30 -background transparent -fill '#ffffff' -font "fonts/SST-MEDIUM.TTF" -splice 0x8 "label:14" \) \( -pointsize 15 -fill '#ffffff' -font "fonts/SST-MEDIUM.TTF" -background transparent -splice 0x21 "label:,49 kn" \) +append \) -compose Over -composite output/4289_banner_lg2.jpg
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: position text string immediatly before another text stri
No problem, that is what IMv6 was all about. (IMv5 would have required it )eekaleek wrote:Can you create a label and use it as a mask in one command instead of creating the label as an image, then using that image as a mask?
just watch the image order. -composite needs the first (zeroth) image to be background (destination), and the second to be the overlay or 'source' image.
After reformatting your command to make it easier to study!
Basically new line any time the line gets long, OR you complete a logical step in image processing.
Code: Select all
convert "master/4289_banner-lg2_MASTER.jpg" \
\( -gravity SouthWest "tabs/bottom_bar.png" \
\( -pointsize 20 -background transparent -fill '#ffffff' -font "fonts/SST-ROMAN.TTF" \
-draw 'text 10,13 "Buy Now!"' \) \) \
-compose Over -composite \
-gravity SouthEast \
\( \( -pointsize 15 -background transparent -fill '#ffffff' -font "fonts/SST-MEDIUM.TTF" -splice 0x21 "label:From" \) \
\( -pointsize 30 -background transparent -fill '#ffffff' -font "fonts/SST-MEDIUM.TTF" -splice 0x8 "label:14" \) \
\( -pointsize 15 -fill '#ffffff' -font "fonts/SST-MEDIUM.TTF" -background transparent -splice 0x21 "label:,49 kn" \) \
+append \) \
-compose Over -composite \
output/4289_banner_lg2.jpg
Second your -gravity setting is after the -composite instead of before it (unless it is for the -append and composite that follows.)
Third your -splice operations is also being applied to no image. IMv6 may not error, but may do some unusual and undefined legacy reordering of operations. IMv7 (in development) would just give a no-image error, when you use a operator without any images present.
Remember settings remain set until cleared using the + version of the setting. So you should be able to set your
background, fill, and font, once. in the outer parenthesis for the three final labels. Or at the very start for ALL the label: image creation operators. If a setting does not remain defined until reset, you have found a bug.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: position text string immediatly before another text stri
Apologies anthony, my server doesn't like it when it's split into lines annoyingly.
This is a bit cheeky of me, but could you refactor my command with your suggested fixes? I'm struggling to visualise how the code should look.
Thanks!
This is a bit cheeky of me, but could you refactor my command with your suggested fixes? I'm struggling to visualise how the code should look.
Thanks!