Flet Dev Docs Controls Image
Flet Dev Docs Controls Image
Image
An image is a graphic representation of something (e.g photo or illustration).
Examples
Live example
Python
import flet as ft
img = ft.Image(
src=f"/icons/icon-512.png",
width=100,
height=100,
fit=ft.ImageFit.CONTAIN,
)
images = ft.Row(expand=1, wrap=False, scroll="always")
page.add(img, images)
Convert web pages and HTML files to PDF in your applications with the Pdfcrowd HTML to PDF API Printed with Pdfcrowd.com
)
page.update()
ft.app(target=main)
Properties
border_radius
Clip image to have rounded corners. See Container.border_radius for more information
and examples.
color
If set, this color is blended with each image pixel using color_blend_mode .
color_blend_mode
Convert web pages and HTML files to PDF in your applications with the Pdfcrowd HTML to PDF API Printed with Pdfcrowd.com
The default is BlendMode.COLOR . In terms of the blend mode, color is the source and this
image is the destination.
error_content
Fallback Control to display if the image cannot be loaded from the source.
fit
How to inscribe the image into the space allocated during layout.
Property value is ImageFit enum with supported values: NONE (default), CONTAIN , COVER ,
FILL , FIT_HEIGHT , FIT_WIDTH , SCALE_DOWN .
gapless_playback
Whether to continue showing the old image ( True ), or briefly show nothing ( False ), when
the image provider changes. The default value is False .
height
If not set, the image will pick a size that best preserves its intrinsic aspect ratio.
NOTE
It is strongly recommended that either both the width and the height be specified, or that
the Image be placed in a context that sets tight layout constraints, so that the image
does not change size as it loads. Consider using fit to adapt the image's rendering to
fit the given width and height if the exact image dimensions are not known in advance.
src
Convert web pages and HTML files to PDF in your applications with the Pdfcrowd HTML to PDF API Printed with Pdfcrowd.com
You can specify assets_dir in flet.app() call to set the location of assets that should be
available to the application. assets_dir could be a relative to your main.py directory or an
absolute path. For example, consider the following program structure:
/assets
/images/my-image.png
main.py
import flet as ft
flet.app(
target=main,
assets_dir="assets"
)
src_base64
import flet as ft
ft.app(target=main)
Use base64 command (Linux, macOS, WSL) to convert file to Base64 format, for example:
On Windows you can use PowerShell to encode string into Base64 format:
Convert web pages and HTML files to PDF in your applications with the Pdfcrowd HTML to PDF API Printed with Pdfcrowd.com
[convert]::ToBase64String((Get-Content -path "your_file_path" -Encoding
repeat
How to paint any portions of the layout bounds not covered by the image.
Property value is ImageRepeat enum with supported values: NO_REPEAT (default), REPEAT ,
REPEAT_X , REPEAT_Y .
semantics_label
tooltip
width
If not set, the image will pick a size that best preserves its intrinsic aspect ratio.
NOTE
It is strongly recommended that either both the width and the height be specified, or that
the Image be placed in a context that sets tight layout constraints, so that the image
does not change size as it loads. Consider using fit to adapt the image's rendering to
fit the given width and height if the exact image dimensions are not known in advance.
Convert web pages and HTML files to PDF in your applications with the Pdfcrowd HTML to PDF API Printed with Pdfcrowd.com