Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
GMImage.Border
Border image (add border to image).
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
GraphicsMagick | 2.0 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameters
Parameter | Description | Example | Flags |
---|---|---|---|
ImageRef | The image reference number. | 1 | |
Geometry | Optional, The rectangle with border width and height. Geometry is specified as a width and height "100x200". | "100x200" | Optional |
Result
Returns "OK" on success.
Description
Border image (add border to image).The color of the border is specified by the borderColor attribute.
Offset from geometry is not used, just width and height.
Examples
Add whitespace on top and bottom of image:
Let ( [
$Image = MBS("GMImage.NewFromContainer"; GraphicsMagick::image);
$r = MBS( "GMImage.SetBorderColor"; $Image; "white" );
$r = MBS("GMImage.Border";$Image; "0x100");
$Result = MBS("GMImage.WriteToPNGContainer"; $Image);
$r = MBS("GMImage.Release";$Image)
];
$Result)
Add white space:
Set Variable [ $image ; Value: MBS("GMImage.NewFromContainer"; ScancodeTests::MyImage ) ]
Set Variable [ $r ; Value: MBS("GMImage.SetBorderColor"; $image; "white") ]
Set Variable [ $r ; Value: MBS("GMImage.Border"; $image; "20x2") ]
Scale image down, add border and crop:
# Load from container
Set Variable [ $Image ; Value: MBS("GMImage.NewFromContainer"; Image Scaling::InputImage) ]
#
# Scale the image by the size needed
Set Variable [ $r ; Value: MBS("GMImage.Scale";$Image; "80x200") ]
#
# calculate border to add
Set Variable [ $w ; Value: Round ( (80 - MBS("GMImage.GetWidth";$Image)) / 2 ; 0 ) ]
Set Variable [ $h ; Value: Round ( (200 - MBS("GMImage.GetHeight";$Image)) / 2 ; 0 ) ]
Set Variable [ $r ; Value: MBS("GMImage.SetBorderColor";$Image; "white") ]
Set Variable [ $r ; Value: MBS("GMImage.Border";$Image; $w & "x" & $h) ]
#
# cut to make sure we are not off by one extra pixel
Set Variable [ $r ; Value: MBS("GMImage.Crop";$Image; "80x200") ]
#
# Write image to container and set the Information text
Set Field [ Image Scaling::Result ; MBS("GMImage.WriteToPNGContainer"; $Image) ]
Set Variable [ $r ; Value: MBS("GMImage.Free";$Image) ]
See also
- GMImage.Coders
- GMImage.Crop
- GMImage.Format
- GMImage.Free
- GMImage.New
- GMImage.NewFromContainer
- GMImage.Release
- GMImage.Scale
- GMImage.SetBorderColor
- GMImage.WriteToPNGContainer
Blog Entries
This function checks for a license.
Created 18th August 2014, last changed 27th August 2022