Release 11 New Features |
TIFF and JPEG Device Drivers
MATLAB 5.1 added new built-in device drivers for producing Tagged Image File Format (TIFF) and Joint Photographic Experts Group (JPEG) graphics files from MATLAB figures. These drivers are available on all platforms. This table summarizes the command-line switches for these drivers.print
command.
TIFF
To produce a TIFF file from a MATLAB figure, use the-dtiff
switch. For example, this command produces a TIFF file named newplot.tif
from the current figure
print -dtiff newplot.tifYou can use the
-r
option in conjunction with the -dtiff
switch to specify the resolution of the output. For example,
print -dtiff -r100 newplot.tifIf you do not specify the resolution, MATLAB uses the default resolution of 150 dots per inch. Note that you must specify a filename because TIFF files cannot be sent directly to a printer. If you omit the filename, MATLAB assigns the file a name, such as
figure1.tif
. If you specify a filename that does not include the .tif
extension, MATLAB appends the extension automatically.
The TIFF files that MATLAB produces are 24-bit truecolor bitmaps. MATLAB renders these graphics using the Z-buffer renderer, regardless of the setting of the figure Renderer
property. If you use the -painters
switch with the print
command, the switch is ignored.
Compression
The TIFF output produced by-dtiff
uses packbit compression, a lossless compression scheme that is supported by virtually all applications that can import TIFF graphics. If you need to import a TIFF file into an application that does not read packbit-compressed TIFF, use the -dtiffnocompression
switch to produce an uncompressed TIFF file. (You can abbreviate this switch to -dtiffn
.) For example,
print -dtiffn -r100 newplot.tifAn uncompressed TIFF file is often much larger than the same file compressed. For certain plots, the uncompressed file may be more than 10 times the size of the compressed file. (The actual ratio will vary. The size of an uncompressed file depends only on the resolution and the width and height values in the
PaperPosition
figure property; the size of the compressed file also depends on the content of the figure.)
JPEG
To produce a JPEG file from a MATLAB figure, use the-djpeg
switch. For example, this command produces a JPEG file named newplot.jpg
from the current figure
print -djpeg newplot.jpgYou can you use the
-r
option in conjunction with the -djpeg
switch to specify the resolution of the output. For example,
print -djpeg -r100 newplot.jpgIf you do not specify the resolution, MATLAB uses the default resolution of 150 dots per inch. Note that you must specify a filename because JPEG files cannot be sent directly to a printer. If you omit the filename, MATLAB assigns the file a name such as
figure1.jpg
. If you specify a filename that does not include the .jpg
extension, MATLAB appends the extension automatically.
The JPEG files that MATLAB produces are 24-bit truecolor bitmaps. MATLAB renders these graphics using the Z-buffer renderer, regardless of the setting of the figure Renderer
property. If you use the -painters
switch with the print
command, the switch is ignored.
Compression
JPEG files use a lossy compression scheme that compresses files dramatically with relatively little loss of information. This scheme enables you to make tradeoffs between file size and quality, by specifying a quality level between 0 (minimum quality, maximum compression) and 100 (maximum quality, minimum compression). By default,-djpeg
uses a quality level of 75; however, you can use a different level by appending the value to the device name. For example, this command produces a JPEG file with a quality level of 50
print -djpeg50 -r100 newplot.jpgEven at the highest quality level, JPEG files are often highly compressed. In fact, depending on the figure, a JPEG file with a quality level of 100 may be considerably smaller than a packbit-compressed TIFF file of the same figure.