Write - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


ImageTools

  

Write

  

write an image to a file

 

Calling Sequence

Parameters

Options

Description

Examples

Calling Sequence

Write( file, img, opts )

Parameters

file

-

string; filename

img

-

Image; image to write

opts

-

(optional) equation(s) of the form option = value; specify options for the Write command

Options

• 

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.

Description

• 

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.

Examples

withImageTools:

imgCreate100,200,r,cevalf0.5sinr500.5sinc30:

img_cCreate100,200,channels=3:

SetLayerimg_c,0.7img,1,inplace:

SetLayerimg_c,0.1img,2,inplace:

SetLayerimg_c,0.5img,3,inplace:

Writegood_img.jpg,img_c

1203

(1)

Writelittle_img.jpg,img_c,quality=20

1018

(2)

Writebig_img.tif,img_c,format=TIFF

9249

(3)

See Also

ImageTools

ImageTools[Formats]

ImageTools[Read]

ImageTools[Read]

ImageTools[Write]