An important part of using Maple to prepare materials for World Wide Web distribution is learning how to properly convert Maple plots into bitmap image files and then integrate those images effectively into Web pages. First, some background on the two most common types of bitmap image files (GIF and JPEG) that can be viewed in Web browsers.
The Graphic Interchange Format (GIF) is a bitmapped graphic file format developed by CompuServe in the 1980s. In the 1990s this format was adopted as one of the main supported graphics formats for Web browsers because of its popularity and efficiency. Much of that popularity vanished almost overnight when Unisys and CompuServe announced in December 1994 that, due to a previous copyright held by Unisys on the compression technology used in GIF files, all commercial software companies incorporating GIF support in their (as of 1995) new products would be required to pay licensing fees. This created an immediate and immense furor, and though CompuServe later announced its intention to try and come up with a new and improved copyright-free GIF format, the damage was done and many software companies began dropping GIF support from their products. This is why you will find that the GIF output support previously available in Maple V Release 3 is now gone from Maple V Release 4.
GIF files store pixels as 8-bit values that index a 24-bit colour palette containing at most 256 entries. The collection of pixels representing the image are then compressed using a lossless compressed scheme called LZW (for Lempel Zev Welch). Lossless compression means that the pixels are stored more efficiently but in a way that perfectly preserves the image content. How efficient the compresson actually is depends on how variable the pixel values are: the more homogeneous the image, the greater the degree of compression. All of this means that GIF files are most effective for storing modest-size images with low noise content and a relatively small number of distinct colours: not unreasonable expectations for many Web images.
There is an easy way to save Maple plots as GIF images with Maple V Release 3. All you need to do is use the Maple plotdevice routine to specify the form of output file (whose name should end in ".gif" so Web servers and browsers will know what format the file is in) to be generated and the size of the bitmap you want to produce:
plotsetup(gif, plotoutput=`sinplot.gif`, plotoptions=`height=216,width=288`); plot3d(sin(x*y),x=-Pi..Pi,y=-Pi..Pi, style=patch,scaling=constrained);
To restore Maple V Release 3 to displaying plots normally without generating a GIF file:
If you use MVR3 on a Macintosh or Windows machine, replace the name "x11" with "mac" or "win", respectively.
There are some limitations to the GIF output that can be generated by MVR3. The four most important limitations for you to be aware of are:
JPEG graphics files are based on compression schemes developed by the Joint Photographic Experts Group for storing full-colour photographs. JPEG images can store more colours than GIF files, since each pixel is represented by its own colour value, and that colour representation can be chosen to suite the colour model most appropriate for a given application (eg: 24-bit colour values for RGB images, or 32-bit colour values for CMYK images). All this colour information and typically large photographic image size could result in enormous file sizes, so the JPEG schemes deal with this problem by implementing a form of lossy compression. When producing the JPEG file corresponding to an image, you can specify how much image degradation you are willing to accept to improve compression; as the quality of the image is reduced, the ability to compress non-homogeneous (particularly smooth-transition and noisy) pixel content increases.
An important limitation of JPEG that you must keep in mind is that since it was designed to deal with the characteristics of scanned photographs, it doesn't always deal well with the sharp edges and strong contrasts typical of many computer-generated images. Unusual distortions of an image are called compression artifacts, and are more likely to appear as more lossy degrees of compression are chosen.
Saving Maple plots as JPEG files (whose name should end in ".jpg") with Maple V Release 4 is almost as easy as producing GIF images was in MVR3. The only difficulty comes from the need to work around a minor bug in the current release of MVR4 that prevents the plotdevice command from easily finding the jpeg plot device driver:
eval(plotsetup): `plotsetup/devices`[jpeg]:=[jpeg,`plot.jpg`,,,``]: plotsetup(jpeg, plotoutput=`sinplot.jpg`, plotoptions=`height=216,width=288`); plot3d(sin(x*y),x=-Pi..Pi,y=-Pi..Pi, style=patch,scaling=constrained);
To restore Maple V Release 4 to displaying plots normally, no matter what platform you are using, just do:
There are some limitations to the JPEG output that can be generated by Maple. The three key limitations for you to keep in mind are:
Once you have turned your Maple plots into bitmap image files, the last step is to edit the content of your HTML files to incorporate those bitmaps as inline images. The HTML markup for including a GIF file is:
<img src="sinplot.gif" height=216 width=288>and similarly for JPEG images:
<img src="sinplot.jpg" height=216 width=288>
There are three things you should learn from these HTML fragments:
In the next how-to article we will continue by discussing how different browsers and computing environments can cause different renderings of bitmaps, and describe how to produce robust and professional-looking plot images by using software tools like Adobe Illustrator and Adobe Photoshop to improve on the plot output that Maple produces.