DocumentTools[Layout]
Image
generate XML for a Image element
Calling Sequence
Parameters
Options
Description
Examples
Compatibility
Image( img, opts )
img
-
content for the Image element, as either a file name or a numeric Array image as used with the ImageTools package
opts
(optional) ; one or more keyword options as described below
captionalignment : identical(left,center,right):=left Indicates how the caption is horizontally aligned.
captionposition : identical(below,above):=below Indicates whether the caption is positioned below or above the image.
drawcaption : truefalse:=false Indicates whether the caption will be shown. The form of the caption is automatically generated and numbered by the interface upon display.
height : posint:=200 ; The height in pixels to be used. If img specifies a filename then by default the height used is 200. If img is an Array then by default the first dimension's size is used as the height.
width : posint:=200 ; The width in pixels to be used. If img specifies a filename then by default the width used is 200. If img is an Array then by default the second dimension's size is used as the width.
The Image command in the Layout Constructors package returns an XML function call which represents a Image element of a worksheet.
The generated XML may be used with the results of other commands in the Layout Constructors package to create an entire Worksheet or Document in XML form. Such a representation of a Worksheet or Document may be inserted into the current document using the InsertContent command.
with⁡DocumentTools:
with⁡DocumentTools:-Layout:
This example uses an Array with a single 2-dimensional layer for a grayscale image.
A≔Array⁡1..20,1..20,i,j↦evalhf⁡argument⁡sin⁡i2−5+I⋅j−102,datatype=float8:img≔ImageTools:-FitIntensity⁡A
Executing the Image command produces a function call, in which the supplied image has been encoded.
g≔Image⁡A,height=150,width=150
g≔_XML_Image⁡captionalignment=1,captionposition=1,drawcaption=false,height=150,width=150,zoomable=false,TUZOV3RLVWI8b2I8Uj1NRExDZE5CP0o+SjpcXFRrRW5iazphTlxcQE5kXFxrZUhQVEhQajxQdnl5eXl4YVl5YWFLaj1ycmhrW3lRPXl5eXhRWHVtV3hrSlxcVnJ5Sz90a0tgclJ0eV08bWptTE1cXG0/YEpqUEtcXFxceFpcXHM7cW9MVG9aTFJ1TGx4bVY+QG5DYE51XFxsP2BuTFlTRT1rV0htS0hqO0hMUz1sPWhrQ0hMPGlWRmlWWj1Wcnl5aXl0YVh5YUhMTGFraUVOO2B4ZEFUa0xsWlxcdUhdTj1ATGhhbkp5UkJNdTt2cj5GX2ZpXFxLcVtRXFw6RmM/b2M+b288P2Y8Mzw=
By using additional commands from the Layout Constructors package a nested function call can be produced which represents an entire worksheet.
xml≔Worksheet⁡Group⁡Input⁡Textfield⁡g:
That XML representation of a worksheet can be inserted directly.
InsertContent⁡xml:
A color image can also be supplied. The next example uses an Array with three 2-dimensional layers for a color image. The first layer initially represents the Hue layer in HSV colorspace, and the Array is recomputed in the RGB colorspace before being passed to the Image element constructor.
By default the dimensions of the Array are used to determine the height and width of the Image.
A≔Array⁡1..200,1..100,i,j↦evalhf⁡argument⁡sin⁡i20−5+I⋅j−5010,datatype=float8:A≔ImageTools:-FitIntensity⁡A⋅360:img≔Array⁡1..200,1..100,1..3,1.0,datatype=float8:img..,..,1≔A:img≔ImageTools:-HSVtoRGB⁡img:g≔Image⁡img:
InsertContent⁡Worksheet⁡Group⁡Input⁡Textfield⁡g:
The image may also be specified with a file name, as a string.
img≔cat⁡kernelopts⁡datadir,/images/antennas.jpg:
g≔Image⁡img:InsertContent⁡Worksheet⁡Group⁡Input⁡Textfield⁡g:
The height and width options can be used to control the displayed dimensions of the Image.
g≔Image⁡img,height=150,width=300:InsertContent⁡Worksheet⁡Group⁡Input⁡Textfield⁡g:
img2≔cat⁡kernelopts⁡datadir,/images/undercarriage.jpg:A2≔ImageTools:-Read⁡img2:h,w≔ceil⁡ImageTools:-Height⁡A22,ceil⁡ImageTools:-Width⁡A22
h,w≔200,300
g≔Image⁡img2,height=h,width=w:
An Image element can also be used as the content of a Table cell.
g≔Image⁡cat⁡kernelopts⁡datadir,/images/antennas.jpg:T≔Table⁡Row⁡g,g,exterior=none,interior=none,alignment=center:InsertContent⁡Worksheet⁡T:
Note that Table cells' contents are automatically rescaled, on display, to fit the cell width. In this next example the Table is specified to have a width of 25 percent of the visible worksheet.
g1≔Image⁡cat⁡kernelopts⁡datadir,/images/antennas.jpg:
g2≔Image⁡cat⁡kernelopts⁡datadir,/images/lichtenstein.jpg:
T≔Table⁡Row⁡g1,g2,Row⁡Some text.,InlinePlot⁡plot⁡sin,alignment=center,Row⁡g2,g1,width=25,alignment=center:InsertContent⁡Worksheet⁡T:
Some text.
A numbered caption can be used.
g≔Image⁡img,drawcaption:InsertContent⁡Worksheet⁡Group⁡Input⁡Textfield⁡g:
The caption position is optional.
g≔Image⁡img,drawcaption,captionposition=above,captionalignment=left:InsertContent⁡Worksheet⁡Group⁡Input⁡Textfield⁡g:
The DocumentTools:-Layout:-Image command was introduced in Maple 2015.
For more information on Maple 2015 changes, see Updates in Maple 2015.
See Also
Array
Component Constructors
DocumentTools
Embed
ImageTools
InsertContent
Layout Constructors
Table
XMLTools
Download Help Document