Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Guides   Examples
New in version: 8.2   8.3   8.4   8.5   9.0   9.1   9.2   9.3   9.4   9.5    Statistic  

GMImage.Crop

Crop image (subregion of original image).

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
GraphicsMagick 2.0 Yes Yes Yes Yes Yes
MBS( "GMImage.Crop"; ImageRef; geometry )   More

Parameters

Parameter Description Example value
ImageRef The image reference number. 1
geometry The rectangle to crop.
Geometry is specified as a width and height "100x200". With an optional offset "100x200+10+20". For percent values, add a percent on the end, for % values add a %: "100x200%!"
"100x200"

Result

Returns "OK" on success.

Description

Crop image (subregion of original image).
You can add pixels with GMImage.Border function.

Examples

Crops the image:

Let ( [
$Image = MBS("GMImage.NewFromContainer"; GraphicsMagick::image);
$Width = MBS("GMImage.GetWidth";$Image);
$Height = MBS("GMImage.GetHeight";$Image);
$Width = $Width/2;
$Height = $Height/2;
$ScaleResult = MBS("GMImage.Crop";$Image; $Width & "x" & $Height);
$Result = MBS("GMImage.WriteToPNGContainer"; $Image);
$Error = MBS("GMImage.Release";$Image)
];
$Result)

Create barcode and crop it:

Set Field [ Barcode Generation::Image ; "" ]
Set Variable [ $img ; Value: MBS("Barcode.Generate"; Barcode Generation::Symbology; Barcode Generation::Text) ]
If [ MBS("IsError") = 0 ]
    Set Variable [ $ImageHeight ; Value: MBS("GMImage.GetHeight"; $img) ]
    Set Variable [ $ImageWidth ; Value: MBS("GMImage.GetWidth"; $img) ]
    # calculate the crop rectangle
    Set Variable [ $w ; Value: $ImageWidth ]
    Set Variable [ $h ; Value: $ImageHeight ]
    Set Variable [ $x ; Value: 0 ]
    Set Variable [ $y ; Value: $ImageHeight - 50 ]
    # crop
    Set Variable [ $r ; Value: MBS("GMImage.Crop"; $img; $w & "x" & $h & "+" & $x & "+" & $y) ]
    Set Field [ Barcode Generation::Image ; MBS( "GMImage.WriteToPNGContainer"; $img; "barcode.png") ]
    Set Variable [ $r ; Value: MBS( "GMImage.Destroy"; $img ) ]
End If

See also

Example Databases

Created 18th August 2014, last changed 20th August 2019


GMImage.CopyChannel   -   GMImage.CycleColormap

Feedback: Report problem or ask question.




Links
MBS Xojo Plugins