write an image to a file
Write( file, img, opts )
Image; image to write
(optional) equation(s) of the form option = value; specify options for the Write command
format = BMP, JPEG, PNG, or TIFF
Specifies the image format. It must be one of the values in ImageTools[Formats]. If not specified, the Write command guesses the format from the extension of file.
quality = numeric
Specifies the JPEG format quality. This option is allowed only if the file is being written in JPEG format, and must be a value from 0 to 100 inclusive. Lower quality settings produce smaller files; higher settings produce better image quality. The default is 75, which is suitable for most photographic images.
The Write command writes an image into a file in one of the supported formats and returns the number of bytes written. After completing the write, the file is closed.
The file parameter is the name of the file and it must be a Maple string. If the format option is not provided, the file format is determined from the extension of the file name. For example, the string image.jpg is written as a JPEG file.
The img parameter must be of type Image.
If img is of type GrayImage, the image is assumed to be grayscale and is written to the file accordingly. A ColorImage image is written as RGB and a ColorAImage is written as RGBA.
The first two dimensions of img correspond to the height and width, respectively, in pixels. Note that this is the reverse of the way image sizes are typically specified (width x height), but this allows the arrangement of pixels in an image to correspond to the Matrix terminology of rows and columns.
If img has a color depth of 4 (red, green, blue, and alpha) and the format being written to (JPEG or BMP) does not support this depth, the last channel (alpha) is dropped.
Color values in img are assumed to range from 0.0 to 1.0, and are scaled to range from 0 to 255 when written into the file. Color values less than 0.0 become 0; values greater than 1.0 become 255.
The Write command can only write RGB, RGBA, or grayscale images, depending on the dimensions of img. Other formats, such as CMYK or color-mapped images cannot be written. See ImageTools[Formats] for further information.
Download Help Document
What kind of issue would you like to report? (Optional)