FilterQuality
Quality levels for image sampling in Image and DecorationImage objects.
Inherits: enum.Enum
Properties
HIGH- Best possible quality when scaling up images by scale factors larger than 5-10x.LOW- Better quality than none, faster than medium.MEDIUM- The best all around filtering method that is only worse than high at extremely large scale factors.NONE- The fastest filtering method, albeit also the lowest quality.
Examples
Filter Quality showcase
play_arrowTry Online
import flet as ft
IMAGE_URL = "https://picsum.photos/id/1025/64/64"
def showcase_card(quality: ft.FilterQuality) -> ft.Container:
return ft.Container(
width=300,
padding=12,
border=ft.Border.all(1, ft.Colors.RED),
border_radius=10,
bgcolor=ft.Colors.SURFACE_CONTAINER_LOW,
content=ft.Column(
spacing=8,
controls=[
ft.Text(quality.name, weight=ft.FontWeight.BOLD),
ft.Container(
width=240,
height=120,
border=ft.Border.all(1, ft.Colors.OUTLINE),
border_radius=8,
clip_behavior=ft.ClipBehavior.HARD_EDGE,
bgcolor=ft.Colors.SURFACE,
content=ft.Image(
src=IMAGE_URL,
width=240,
height=120,
fit=ft.BoxFit.FILL,
filter_quality=quality,
),
),
],
),
)
def main(page: ft.Page):
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
page.appbar = ft.AppBar(title="FilterQuality Showcase")
page.add(
ft.SafeArea(
content=ft.Column(
controls=[
ft.Text(
"Compare image sampling quality while scaling the "
"same source image."
),
ft.Row(
wrap=True,
spacing=12,
expand=True,
scroll=ft.ScrollMode.AUTO,
alignment=ft.MainAxisAlignment.CENTER,
controls=[
showcase_card(quality) for quality in ft.FilterQuality
],
),
],
),
)
)
if __name__ == "__main__":
ft.run(main)
Properties
HIGHclass-attributeinstance-attribute
Best possible quality when scaling up images by scale factors larger than 5-10x. When images are scaled down, this can be worse than medium for scales smaller than 0.5x, or when animating the scale factor. This option is also the slowest.
LOWclass-attributeinstance-attribute
Better quality than none, faster than medium.
MEDIUMclass-attributeinstance-attribute
The best all around filtering method that is only worse than high at extremely large scale factors.
NONEclass-attributeinstance-attribute
The fastest filtering method, albeit also the lowest quality.