This widget is available on graphic displays only!
The image widget allows you to place a individual image on your display. PNG, JPEG, GIF and BMP files are supported; PNG with full color and transparency. The image can be scaled and centered.
The definition of a image widget looks like this:
Widget myImage {
class 'Image'
file <string>
scale <number>
width <number>
height <number>
center <0|1>
update <number>
reload <0|1>
visible <0|1>
inverted <0|1>
}
| file | path to the image file (PNG, JPEG, GIF or BMP). The format is detected from the content of the file, not from its name. |
| scale | scale factor in percent (default is 100 = original size), or -1 to fit the image into width x height. See below. |
| width, height | maximum size of the image in pixels (default is 0 = not used). See below. |
| center | set to 1 to center the image horizontally on the display (default is 0). See below. |
| update | update interval (msec), default is 100. Use 0 (zero) for static images |
| reload | expression controlling image reloading on update |
| visible | expression controlling the visibility (for blinking effects) |
| inverted | expression controlling the inversion (for displays that draw white pixels on dark background) |
The image widget is not placed on a row/column basis, but with true pixel resolution. Therefore the layout section looks a bit different:
Layout TestImage {
Row1 {
Col1 'OS'
}
Layer 2 {
X1.Y1 'ImageTest'
}
}
Note that using an extra layer for images may be very useful!
Widget ImageTest {
class 'Image'
file '/home/michi/avatar.png'
update 1000
visible 1
inverted 0
}
Layout Avatar {
X1.Y1 'ImageTest'
}
All entries of the image widget are expressions, so the size may depend on variables or plugins.
| width and/or height given, scale 100 (or not given) | The image is resized so that it fits into width x height pixels. The aspect ratio is kept. If only one of the two is given, the other one results from the aspect ratio. Small images are enlarged. |
| scale -1, width and height given | The same: the image is scaled to width, but limited to height. Both entries are needed. |
| scale greater than 1 and not 100 | The image is scaled to this percentage of its original size (50 = half, 200 = double). width and height are ignored. |
Widget Logo {
class 'Image'
file '/share/icons/logo.png'
width 200
height 120
update 0
}
Note: with a percentage in scale use either a static image (update 0) or reload 1. Otherwise the image, which is already scaled, is scaled again at every update.
With center 1 the image is centered horizontally on the display. The horizontal position from the layout is ignored then, only the vertical position (the number after X) is used. If the image is replaced by a smaller one (reload 1), the new image is centered vertically within the height of the previous one.
Widget Cover {
class 'Image'
file '/tmp/cover.jpg'
height 200
center 1
reload 1
update 2000
}
Layout Default {
Layer 2 {
X20.Y1 'Cover'
}
}
When the reload property evaluates to zero, the image file will not be reloaded at image update, so only the visible and inverted properties will change the display. If you want to reload the image every time (maybe because the image may change), set the reload property to 1.
You can specify an expression for visible, which will be evaluated every time the image is updated (every update msec). If the expression evaluates to 0 (zero), the image is invisible, and will be replaced by blank (transparent) pixels. If the result is not zero, the image will be displayed. This is useful for blinking effects, or activity display.
The Truetype widget renders text with a TrueType font and is placed in the same way.