Topics   All   Mac OS X (Only)   Windows (Only)   Crossplatform   Server (Not)   Client   Components   Old   Guides
New in version: 4.0   4.1   4.2   4.3   4.4   5.0   5.1   5.2   5.3   5.4   6.0   6.1   6.2    Statistic  

GMImage.WriteToFile

Component: GraphicsMagick
Version: 2.0
Mac OS X: Yes
Windows: Yes
Server: Yes

MBS( "GMImage.WriteToFile"; ImageRef; Path )

Parameters

Parameter Description Example value
ImageRef The image reference (a number returned from the GMImage.New functions) 1
Path A platform specific filepath where to write the image. "C:\Test.txt"

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 Mac OS X:

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.Destroy";$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.Destroy"; $img)]
End If

See also


GMImage.WriteToBMPContainer   -   GMImage.WriteToGIFContainer

Feedback: Report problem or ask question.




Links
MBS Realbasic tutorial videos - Nachhilfe in Andernach