Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
GMImage.New
Construct a blank image canvas of specified size and color.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
GraphicsMagick | 2.0 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameters
Parameter | Description | Example |
---|---|---|
Geometry | The rectangle. 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" |
Color | A color value. This can be a string in the following format "HSL h s l a", "YUV y u v a", "RGB r g b a", "MONO m a", "GRAY g a" or "COLOR R G B a". Alpha value a is optional. Range of values is 0 to 1.0 except if you use COLOR where RGB values are 0 to 65535. Starting with version 5.4 of our plugin, you can use hex notation. # followed by 2 digits for red, green, blue and optional alpha, e.g. #FF0000 for full red. |
"RGB 1 0 0" |
Result
Returns the ImageRef number on success.
Description
Construct a blank image canvas of specified size and color.Please call GMImage.Release later to free memory for this image.
Image reference numbers are starting at 18000 and counting up for each new image.
Examples
New white image:
MBS( "GMImage.New"; "16x16"; "white" )
New red image:
MBS( "GMImage.New"; "16x16"; "#FF0000" )
Create red square and save to container:
Set Variable [$img; Value:MBS( "GMImage.New"; "16x16"; "red" )]
Set Field [test::test; MBS( "GMImage.WriteToPNGContainer"; $img; "test.png" )]
Set Variable [$r; Value:MBS( "GMImage.Release"; $img)]
Build in a calculation:
SetVars ( [
img = MBS( "GMImage.New"; "16x16"; "random" );
result = MBS( "GMImage.WriteToPNGContainer"; img; "test.png" );
r = MBS( "GMImage.Release"; img)
]; result )
Create picture with red and 50% alpha:
#Create picture
Set Variable [$img; Value:MBS( "GMImage.New"; "16x16"; "white")]
#Add alpha channel
Set Variable [$r; Value:MBS( "GMImage.SetMatte"; $img; 1)]
#Set background color and fill
Set Variable [$r; Value:MBS( "GMImage.SetBackgroundColor"; $img; "COLOR 65535 0 0 0.5")]
Set Variable [$r; Value:MBS( "GMImage.Erase"; $img)]
#Write to field
Set Variable [$pic; Value:MBS( "GMImage.WriteToPNGContainer"; $img; "test.png" )]
Set Field [test::r; $pic]
#Cleanup
Set Variable [$r; Value:MBS( "GMImage.Release"; $img)]
Create a transparent picture by erasing with transparent color:
Set Variable [ $img ; Value: MBS("GMImage.New"; $width & "x" & $height; "RGB 1 1 1") ]
Set Variable [ $r ; Value: MBS( "GMImage.SetMatte"; $img; 1) ]
Set Variable [ $r ; Value: MBS( "GMImage.SetBackgroundColor"; $img; "transparent") ]
Set Variable [ $r ; Value: MBS("GMImage.Erase"; $img) ]
See also
- GMImage.Free
- GMImage.Map
- GMImage.SkewY
- ImageView.CreateWithSize
- OCR.GetText
- OCR.SetImage
- ProgressDialog.SetTitleIcon
- Window.SetTitleIcon
- XL.Book.AddPictureContainer
- XL.Sheet.SetPictureWithSize
Release notes
- Version 14.4
- Fixed a problem with GMImage.NewFromFile and Japanese characters on Windows.
- Version 13.0
- Changed JPEG loader for GMImage.NewFromContainer, GMImage.NewFromFile and related to not stop loading of an image on a warning.
- Version 9.5
- Improved JPEG detection for byte streams, so we can detect if a PNG is actually a JPEG. Now GMImage.NewFromContainer can read JPEG, GIF, PNG, TIFF and BMP even if they are passed in wrong container format.
- Version 9.0
- Improved error handling for GMImage.NewFromContainer, so we pass on error messages from GraphicsMagick.
- Version 8.5
- Changed GMImage.NewImagesFromFile to reject .PDF file as GraphicsMagick doesn't really read PDF files.
- Version 8.4
- Added Magick parameter for GMImage.NewFromFile function.
- Fixed problem with GMImage.NewFromFile function.
- Version 8.3
- Fixed GMImage.NewFromContainer to handle SVG files better.
- Version 7.2
- Fixed a bug with GMImage.NewFromContainer where referenced image file would stay open.
Example Databases
- Color Panel
- GraphicsMagick/Clip Image
- GraphicsMagick/Colors
- GraphicsMagick/Create GIF
- GraphicsMagick/Drawing
- GraphicsMagick/GraphicsMagick Path Drawing
- GraphicsMagick/ProgressBar in Portal
- GraphicsMagick/Reduce Image
- GraphicsMagick/Text Wrap
- Overlay
Blog Entries
- Create QR-Codes with circles
- Custom progress bars for FileMaker
- GraphicsMagick in FileMaker, part 24
- GraphicsMagick in FileMaker, part 20
- Convert a SVG image to PNG with alpha channel
- Gradients in GraphicsMagick
- Circle crop images in FileMaker with MBS Plugin
FileMaker Magazin
This function checks for a license.
Created 18th August 2014, last changed 11st April 2023
