Flutter Image Asset Pipeline (WebP & ImageMagick)
Guidance for preparing image assets before adding them to the Flutter app — which format to use for which kind of image, and how to generate the resolution variants Flutter expects.
Format Comparison
| Format | Use Case | Why |
|---|---|---|
| WebP | Product photos, banners, grids | Best balance of file size, quality, and transparency support — a product photo on a transparent background can be roughly 80% smaller than the equivalent PNG at the same visual quality, which matters once a grid is rendering dozens of thumbnails at once. |
| SVG | Icons, logos, simple shapes | Scales to any size with no quality loss, since it’s vector rather than raster. |
| PNG | Screenshots, simple UI elements | Fall back to this only when WebP isn’t available for a given asset source — it’s usually larger than WebP for the same image. |
| Lottie | Complex UI animations | Vector-based animation, smaller than an animated WebP for the same motion. |
Setup: ImageMagick
Image resizing/conversion is done with ImageMagick, not a Flutter package — it runs once at asset-preparation time, outside the app itself.
brew install imagemagick
Verify:
magick -version
Resolution Variants (1.0x / 2.0x / 3.0x)
Flutter resolves an image asset against the device’s pixel density by looking for 2.0x//3.0x/ subfolders next to the base file — the base file itself is the 1.0x variant, no 1.0x/ folder needed:
assets/images/shoes/
├── shoes_01.webp ← base (1.0x)
├── 2.0x/
│ └── shoes_01.webp ← 2.0x
└── 3.0x/
└── shoes_01.webp ← 3.0x
Generating All Three From a @2x Source
Design handoffs often arrive as a single @2x file. Treat that as the 2.0x baseline and scale in both directions:
| Target | Formula | Scale |
|---|---|---|
| 1.0x | 1.0 ÷ 2.0 | 50% (downscale) |
| 2.0x | source baseline | 100% (direct convert) |
| 3.0x | 3.0 ÷ 2.0 | 150% (upscale) |
mkdir 2.0x 3.0x
# 3.0x — upscale by 150%
magick [email protected] -resize 150% -quality 85 3.0x/output.webp
# 2.0x — direct conversion, no resize
magick [email protected] -quality 85 2.0x/output.webp
# 1.0x — downscale by 50%
magick [email protected] -resize 50% -quality 85 output.webp
Adjust -quality down for large banner images if file size matters more than near-lossless fidelity; 85 is a reasonable default for product photography.