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:
9.3
9.4
9.5
10.0
10.1
10.2
10.3
10.4
10.5
10.6
Statistic
FMM
Blog
GMImage.WriteToFile
Write single image frame to a file.
| Component | Version | macOS | Windows | Linux | Server | FileMaker iOS SDK |
| GraphicsMagick | 2.0 | Yes | Yes | Yes | Yes | Yes |
Parameters
| Parameter | Description | Example |
|---|---|---|
| ImageRef | The image reference number. | 1 |
| Path | A platform specific filepath where to write the image. | "C:\Test.jpg" |
Result
Returns "OK" on success.
Description
Write single image frame to a file.See also GMImage.WriteToPNGContainer, GMImage.WriteToBMPContainer, GMImage.WriteToTiffContainer, GMImage.WriteToJPEGContainer and GMImage.WriteToGIFContainer.
This function requires a native path. Use Path.FileMakerPathToNativePath to convert a FileMaker path to a native path if required. If you like to have the user choose the path, you can use FileDialog functions.
For Server be aware that server has limited permissions and may not be able to access all files on a computer.
Examples
Save file to Bob's desktop as GIF file on macOS:
MBS( "GMImage.WriteToFile"; $BigImageRef; "/Users/Bob/Desktop/test.gif" )
Save file to Bob's desktop as JPG file on Windows:
MBS( "GMImage.WriteToFile"; $BigImageRef; "C:\Data\logo.jpg" )
Convert image to 1 bit TIFF:
# Load from container
$Image = MBS("GMImage.NewFromContainer"; GraphicsMagick::image);
# make black and white with threshold
$Result = MBS("GMImage.Threshold";$Image; 127);
# mark as monochrome image
$Result = MBS("GMImage.SetMonochrome";$Image; 1);
# set type to 1 for black/white
$Result = MBS("GMImage.SetType";$Image; 1);
# set to use TIFF for compression
$Result = MBS("GMImage.SetMagick";$Image; "TIFF");
# set to use CCITT 4 Fax compression
$Result = MBS("GMImage.SetCompressType";$Image; 4);
# and write to a file
$Result = MBS("GMImage.WriteToFile"; $Image; "/tmp/test.tif");
# cleanup
$Error = MBS("GMImage.Release";$Image)
Loads from file and writes to other file:
Set Variable [$img; Value:MBS("GMImage.NewImagesFromFile"; "/Users/cs/Desktop/test.jpg")]
If [MBS("IsError") = 0]
Set Variable [$r; Value:MBS( "GMImage.WriteToFile"; $img; "/Users/cs/Desktop/test.tif" )]
Set Variable [$r; Value:MBS( "GMImage.Release"; $img)]
End If
Draw something and write to file on desktop:
# New Image
Set Variable [$img; Value:MBS("GMImage.New"; "300x200"; "RGB 1 1 1")]
# Set colors and line width
Set Variable [$r; Value:MBS("GMImage.SetStrokeColor"; $img; "RGB 1 0 0")]
Set Variable [$r; Value:MBS("GMImage.SetFillColor"; $img; "RGB 0 0 1")]
Set Variable [$r; Value:MBS("GMImage.SetLineWidth"; $img; 5)]
# draw a rectangle
Set Variable [$r; Value:MBS("GMImage.DrawRectangle"; $img; 50; 50; 250; 150)]
# save to test.png on desktop:
Set Variable [$DesktopPath; Value:MBS( "Folders.UserDesktop" )]
Set Variable [$path; Value:MBS( "Path.AddPathComponent"; $DesktopPath; "test.png")]
Set Variable [$r; Value:MBS("GMImage.WriteToFile"; $img; $path)]
# cleanup
Set Variable [$r; Value:MBS("GMImage.Release"; $img)]
See also
- GMImage.SetMagick
- GMImage.SetStrokeColor
- GMImage.SetType
- GMImage.WriteToBMPContainer
- GMImage.WriteToGIFContainer
- GMImage.WriteToJPEGContainer
- GMImage.WriteToPDFContainer
- GMImage.WriteToPNGContainer
- IsError
- Path.AddPathComponent
Example Databases
Blog Entries
FileMaker Magazin
Created 18th August 2014, last changed 10th August 2020
GMImage.WriteToContainer - GMImage.WriteToGIFContainer
Feedback: Report problem or ask question.
Links
MBS Xojo blog