🔥 All-Access Pass — $199 USD (Regular $499) · Unlock all 2,836 Astro themes ➔
komal.nakrani
Get All-Access Pass ($199)
ThemesCategoriesDocsBlogTips & TricksPricingGet All-Access Pass ($199)
Performance••By Komal Nakrani

Fix: Unsupported Image Format in Astro

Fix Astro's 'Unsupported image format' error: the Image component only processes jpeg, png, tiff, webp, gif, svg and avif. Convert the file or use a plain img tag.

#Astro#Errors#Images

Astro throws “Unsupported image format” when you pass <Image>, <Picture> or getImage() a file type its image service can’t process, such as .apng, or when you ask it to rasterize an SVG without enabling SVG processing. The fix is to convert the file to a supported format (WebP, AVIF, PNG or JPEG), render it with a plain <img> tag, or, for SVGs, keep format="svg" so the file passes through unchanged.

Key Takeaways

  • Supported inputs: jpeg, jpg, png, tiff, webp, gif, svg and avif.
  • .apng can be imported but not processed; use <img> or convert it.
  • Rasterizing an SVG (for example format="webp") needs image.dangerouslyProcessSVG (added in Astro 6.3, off by default).
  • The hint is right: a plain <img> skips the image service entirely.

The exact error

Unsupported image format.

Received unsupported format `apng` from `/src/assets/loader.apng`. Currently only jpeg, jpg, png, tiff, webp, gif, svg, avif are supported by our image services.

Hint: Using an `img` tag directly instead of the `Image` component might be what you're looking for.

For SVG sources the same title comes with a different message:

SVG image processing is disabled, but the source for "/src/assets/logo.svg" is an SVG. Pass it through unchanged by setting `format="svg"` on the component, or set `image.dangerouslyProcessSVG: true` to rasterize SVG sources.

Fix 1: use a plain img tag

An animated APNG doesn’t need Astro’s resizing to work. Import the file for a hashed URL and render it directly:

---
// src/components/Loader.astro
import loader from '../assets/loader.apng';
---
<img src={loader.src} width={loader.width} height={loader.height} alt="Loading" />

Or put the file in public/ and reference it by path: <img src="/loader.apng" alt="Loading" />.

Fix 2: convert the image

If you want responsive sizes and modern formats, convert the source once and commit the result. For animation, convert to an animated WebP or GIF, both of which the service accepts. Then <Image> works as normal:

---
// src/components/Hero.astro
import { Image } from 'astro:assets';
import hero from '../assets/hero.webp';
---
<Image src={hero} alt="Product dashboard" widths={[480, 960, 1440]} sizes="100vw" />

Fix 3: SVG sources

Most SVGs should stay vector. Pass format="svg" so Astro copies the file without processing it:

---
// src/components/Logo.astro
import { Image } from 'astro:assets';
import logo from '../assets/logo.svg';
---
<Image src={logo} format="svg" alt="Company logo" />

You can also import an SVG as a component (<Logo />) to inline it. Only if you really need a PNG or WebP from a trusted SVG, opt in:

// astro.config.mjs
import { defineConfig } from 'astro/config';

export default defineConfig({
  image: { dangerouslyProcessSVG: true },
});

It’s disabled by default because specially crafted SVGs can be very expensive to process. Never enable it for user-uploaded or remote SVGs you don’t control.

For the opposite direction, raster to SVG, see unsupported image conversion. Other image errors are covered in image not found and could not find Sharp, and responsive images in Astro shows the full <Image> setup. Our styling docs cover theme assets, and you can see finished image setups in the Komal theme catalog. The Astro error reference has the official entry.

FAQ

What image formats does Astro support?

The built-in Sharp service processes jpeg, jpg, png, tiff, webp, gif, svg and avif. Output formats are avif, png, webp, jpeg, jpg and svg, with webp as the default.

Can I use APNG files in Astro?

Yes, with a plain <img> tag or from public/. They can’t go through <Image> or getImage().

Why does Astro refuse to convert my SVG to WebP?

SVG rasterization is disabled by default for security. Keep the SVG as vector with format="svg", or set image.dangerouslyProcessSVG: true for trusted files.