Skip to content

Image Asset Optimization

David Ortinau edited this page Apr 10, 2025 · 3 revisions

💬 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

📚 Additional Resources


➡️ Next: Optimize Startup Performance

Clone this wiki locally