Image Asset Optimization - davidortinau/ControlGallery GitHub Wiki
๐ฌ Copilot Chat Prompt
Audit my .NET MAUI appโs image usage. Look for oversized images, bitmaps loaded at runtime instead of using ImageSource, and missing UriImageSource caching. Suggest resizing strategies and use of SVGs where appropriate.
Improper image usage can lead to high memory usage and laggy UI.
๐ What to Look For
- Images that are larger than their display size
- Bitmaps not cached and loaded repeatedly
- Use of bitmap formats for icons instead of SVGs
โ Fix Examples
- Provide downsampled images matched to display size (donโt display a 2000px-wide image at 100px)
- Enable caching on remote images:
new UriImageSource { Uri = new Uri("https://example.com/image.jpg"), CachingEnabled = true, CacheValidity = TimeSpan.FromDays(7) }
- Use SVG or vector icons when supported (e.g., via
SvgImageSource
or a custom handler) - Remove unused image assets from the Resources/Images folder to reduce app size