JPEG - Maple Help

# Online Help

###### All Products    Maple    MapleSim

JPEG (.jpg, .jpeg) File Format

JPEG file format

Description

 • JPEG is a popular lossy image data format for compressed raster data.
 • This format is supported by the ImageTools[Read] and ImageTools[Write] commands. The general-purpose commands Import and Export also support this format.
 • An image may be specified as the background of a plot with the image option (see plot,options).
 • The context-sensitive menu can be used to export Maple plot graphics to JPEG format.
 • Additionally, JPEG images can be inserted directly into a Maple Document.

Notes

 • Content-Type: image/jpeg

Examples

Create an image and write it out to the home directory of the current user.

 > $\mathrm{with}\left(\mathrm{ImageTools}\right):$
 > $\mathrm{image}≔\mathrm{Create}\left(100,200,\left[\left(r,c\right)↦0.25\cdot \left(1+\mathrm{sin}\left(\left(0.005+0.003\cdot c\right)\cdot c\right)\right)\cdot \left(1+\mathrm{sin}\left(0.15\cdot r\right)\right),\left(r,c\right)↦0.5\cdot \left(1+\mathrm{exp}\left(-\frac{r}{50.}\right)\cdot \mathrm{sin}\left(\frac{c}{20.}\right)\right),\left(r,c\right)↦\frac{r}{100.0}\right]\right):$
 > $\mathrm{testFile}≔\mathrm{FileTools}:-\mathrm{JoinPath}\left(\left["test.jpg"\right],\mathrm{base}=\mathrm{homedir}\right)$
 ${"/Users/JohnSmith/test.jpg"}$ (1)
 > $\mathrm{Write}\left(\mathrm{testFile},\mathrm{image}\right)$
 ${4066}$ (2)

Import a JPEG file from disk and view the underlying data.

 > $\mathrm{Import}\left("images/fingerprint.jpg",\mathrm{base}=\mathrm{datadir}\right)$
 $\begin{array}{c}\left[\begin{array}{ccccccccccc}{0.188235294117647}& {0.568627450980392}& {0.505882352941176}& {0.470588235294118}& {0.494117647058824}& {0.505882352941176}& {0.486274509803922}& {0.509803921568627}& {0.501960784313725}& {0.501960784313725}& {\dots }\\ {0.541176470588235}& {0.984313725490196}& {0.992156862745098}& {0.992156862745098}& {1.}& {1.}& {0.992156862745098}& {1.}& {1.}& {1.}& {\dots }\\ {0.478431372549020}& {0.960784313725490}& {1.}& {1.}& {1.}& {0.984313725490196}& {0.964705882352941}& {0.996078431372549}& {0.996078431372549}& {0.996078431372549}& {\dots }\\ {0.517647058823529}& {0.996078431372549}& {1.}& {1.}& {0.988235294117647}& {0.980392156862745}& {0.972549019607843}& {1.}& {1.}& {1.}& {\dots }\\ {0.501960784313725}& {0.976470588235294}& {1.}& {0.980392156862745}& {0.988235294117647}& {1.}& {1.}& {1.}& {1.}& {1.}& {\dots }\\ {0.478431372549020}& {0.960784313725490}& {0.992156862745098}& {0.980392156862745}& {1.}& {1.}& {0.988235294117647}& {0.988235294117647}& {0.996078431372549}& {0.996078431372549}& {\dots }\\ {0.501960784313725}& {0.992156862745098}& {1.}& {0.992156862745098}& {1.}& {1.}& {0.980392156862745}& {0.980392156862745}& {1.}& {1.}& {\dots }\\ {0.494117647058824}& {0.984313725490196}& {1.}& {0.972549019607843}& {0.972549019607843}& {1.}& {1.}& {1.}& {0.992156862745098}& {0.992156862745098}& {\dots }\\ {0.498039215686275}& {1.}& {0.992156862745098}& {1.}& {1.}& {0.980392156862745}& {0.996078431372549}& {0.992156862745098}& {1.}& {1.}& {\dots }\\ {0.494117647058824}& {0.996078431372549}& {0.992156862745098}& {1.}& {1.}& {0.984313725490196}& {0.996078431372549}& {0.996078431372549}& {1.}& {1.}& {\dots }\\ {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {}\end{array}\right]\\ \hfill {\text{240 × 256 Array}}\end{array}$ (3)
 > $\mathrm{Import}\left("images/fingerprint.jpg",\mathrm{base}=\mathrm{datadir},\mathrm{output}=\mathrm{embed}\right)$

 See Also