Maple Professional
Maple Academic
Maple Student Edition
Maple Personal Edition
Maple Player
Maple Player for iPad
MapleSim Professional
MapleSim Academic
Maple T.A. - Testing & Assessment
Maple T.A. MAA Placement Test Suite
Möbius - Online Courseware
Machine Design / Industrial Automation
Aerospace
Vehicle Engineering
Robotics
Power Industries
System Simulation and Analysis
Model development for HIL
Plant Modeling for Control Design
Robotics/Motion Control/Mechatronics
Other Application Areas
Mathematics Education
Engineering Education
High Schools & Two-Year Colleges
Testing & Assessment
Students
Financial Modeling
Operations Research
High Performance Computing
Physics
Live Webinars
Recorded Webinars
Upcoming Events
MaplePrimes
Maplesoft Blog
Maplesoft Membership
Maple Ambassador Program
MapleCloud
Technical Whitepapers
E-Mail Newsletters
Maple Books
Math Matters
Application Center
MapleSim Model Gallery
User Case Studies
Exploring Engineering Fundamentals
Teaching Concepts with Maple
Maplesoft Welcome Center
Teacher Resource Center
Student Help Center
ImageTools[Write] - write an image to a file
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
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.
Options
format = BMP, JPEG, 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.
Examples
See Also
ImageTools, ImageTools[Formats], ImageTools[Read], ImageTools[Read], ImageTools[Write]
Download Help Document