Skip to content

NoImageMetadata for SVG with either zero height or width #16633

@dotnetCarpenter

Description

@dotnetCarpenter

Astro Info

Astro                    v6.2.2
Node                     v24.15.0
System                   Linux (x64)
Package Manager          bun
Output                   static
Adapter                  none
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

All

Describe the Bug

Astro 6.2 can not import SVG files with either zero height or width. This is useful for importing SVG filters.

Error: Could not process image metadata.

Steps to reproduce

  1. Create a file in src/assets/ called bug.svg
<svg width="0" height="0"></svg>
  1. Create a file in src/pages/ called index.astro
---
import Bug from "../assets/bug.svg";
---
<Bug/>
  1. Run bun run dev
  2. Observe the error.

What's the expected result?

Output the SVG into the page after running optimisations defined in astro.config.mjs.

Link to Minimal Reproducible Example

https://github.com/dotnetCarpenter/astro-svg-bug

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    - P3: minor bugAn edge case that only affects very specific usage (priority)pkg: astroRelated to the core `astro` package (scope)

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions