Topics
All
MacOS
(Only)
Windows
(Only)
Linux
(Only, Not)
iOS
(Only, Not)
Components
Crossplatform Mac & Win
Server
Client
Old
Deprecated
Guides
Examples
Videos
New in version:
12.2
12.3
12.4
12.5
13.0
13.1
13.2
13.3
13.4
13.5
Statistic
FMM
Blog
Queries space needed for text.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
GraphicsMagick | 7.3 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameter | Description | Example |
---|---|---|
ImageRef | The image reference number. | 1 |
text | Some text | "Hello World" |
Returns list or error.
Draw some text on a picture:
# open a picture
Set Variable [ $ref ; Value: MBS("GMImage.NewFromContainer"; Annotate Image::InputImage) ]
# set font size
Set Variable [ $r ; Value: MBS("GMImage.SetFontPointsize"; $ref; 20) ]
# set the font
Set Variable [ $r ; Value: MBS("GMImage.SetFont"; $ref; "@/System/Library/Fonts/LucidaGrande.ttc") ]
# set the fill color
Set Variable [ $r ; Value: MBS("GMImage.SetFillColor"; $ref; "RGB 0 0 0") ]
# Query size for this text:
Set Variable [ $r ; Value: MBS("GMImage.FontTypeMetrics"; $ref; Annotate Image::Text) ]
# draw the text:
Set Variable [ $r ; Value: MBS("GMImage.Annotate"; $ref; Annotate Image::Text; "100x200+10+40"; 1) ]
# write image
Set Field [ Annotate Image::OutputImage ; MBS( "GMImage.WriteToPNGContainer"; $ref ) ]
# free memory
Set Variable [ $Error ; Value: MBS("GMImage.Release";$ref) ]
Measure text:
MBS("GMImage.FontTypeMetrics"; $ref; Annotate Image::Text)
Example result:
"528.000000
47.000000
39.000000
-8.000000
66.000000
40.000000"
This function checks for a license.
Created 20th June 2017, last changed 26th September 2021