ImageWrite
Syntax
ImageWrite( name [, path] )Or as a member:
someImage.write( [path] )Arguments
name
any
Yes
The image to write. Can be a BoxImage object or image name.
path
String
No
The file path to write the image to. If omitted, writes back to the image's original source path (only for images loaded from files).
Returns
BoxImage — The image object after writing to disk.
Description
Writes the specified image to disk. The function has two modes:
With path parameter: Writes the image to the specified file location. The output format is auto-detected from the file extension (e.g.,
.png→ PNG,.jpg→ JPEG,.webp→ WebP,.gif→ GIF,.bmp→ BMP,.tiff→ TIFF).Without path parameter: Writes the image back to its original source location (requires the image was loaded from a file).
Parent directories are automatically created if they don't exist. The file stream is properly closed after writing, so the file can be safely deleted or moved immediately after writing.
Alpha Channel Handling: When writing to formats that do not support transparency (JPEG, BMP), images with alpha channels are automatically composited onto a white background before encoding, preventing write failures.
Example
Related BIFs
ImageRead
ImageNew
ImageGetBlob
ImageWriteBase64
Notes
The
nameargument can be aBoxImageobject or the name of an image variable in the current context.If no path is provided, the image must have been loaded from a file (via
ImageReadorImageNewwith a file path).Images created from scratch (blank canvases) or from Base64 cannot use the parameterless
write()- they require an explicit path.Parent directories in the path are created automatically if they don't exist.
The operation returns the image object for chaining or further processing.
File handles are properly managed - files can be deleted immediately after writing (no Windows file lock issues).
Last updated
Was this helpful?
