Skip to content

passthroughImageService() does not prevent WebP conversion for Image component in Astro 5.15.2 #14721

@lightsound

Description

@lightsound

Astro Info

Astro                    v5.15.2
Vite                     v6.4.1
Node                     v24.8.0
System                   macOS (arm64)
Package Manager          pnpm
Output                   static
Adapter                  none
Integrations             @astrojs/preact (v4.1.2)
                         @astrojs/sitemap (v3.6.0)

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

N/A - This is a build-time issue

Describe the Bug

When using passthroughImageService() in astro.config.ts, images imported and used with the Image component from astro:assets are still being converted to WebP format during build, despite the expectation that all image optimization should be disabled.

Configuration in astro.config.ts:

import { defineConfig, passthroughImageService } from "astro/config";

export default defineConfig({
  image: {
    service: passthroughImageService(),
  },
  // ... other config
});

Component usage:

---
import { Image } from "astro:assets";
import image1 from "./image1.jpg";
---

<Image src={image1} alt="Hero Image" />

Actual behavior:

After running pnpm build, the output in dist/_astro/ contains:

  • WebP files: image1.MoQXd5Vo_1yvslA.webp
  • Original JPG files: image1.MoQXd5Vo_1yvslA.jpg (also generated)

However, the generated HTML uses the WebP version:

<img src="/_astro/image1.MoQXd5Vo_1yvslA.webp" alt="Hero Image" ... />

Build logs show "generating optimized images" step with 481 WebP files being created:

generating optimized images
19:12:19   ▶ /_astro/banner.Diz8Q35Q_CxSSV.webp (before: 109kB, after: 109kB) (+4ms) (1/481)
19:12:19   ▶ /_astro/_about-fair1.8fWoa9p1_dtbvN.webp (before: 298kB, after: 298kB) (+4ms) (2/481)
...
19:12:20 ✓ Completed in 330ms.

Even with passthroughImageService() configured, the image optimization step still runs and converts all images to WebP.

What's the expected result?

What's the expected result?

When passthroughImageService() is configured, the Image component should output images in their original format without any conversion or optimization. The build should:

  1. Not create WebP versions of the images
  2. Use the original image format (JPG, PNG, etc.) in the generated HTML
  3. Skip the "generating optimized images" step entirely, or at minimum not perform format conversion

According to the Astro documentation, passthroughImageService is intended to bypass all image optimization, including format conversion. The expected HTML output should be:

<img src="/_astro/image1.MoQXd5Vo_1yvslA.jpg" alt="Hero Image" ... />

The build logs should not show any "generating optimized images" step, or if it does, it should show that images are being passed through without modification:

generating optimized images
19:12:19   ▶ /_astro/image1.jpg (passthrough, no optimization) (+1ms) (1/481)

Link to Minimal Reproducible Example

Note: Creating a minimal reproduction on StackBlitz is challenging for this issue as it's a build-time problem that requires inspecting the dist/ directory output, which is difficult to verify in browser-based development environments.

Participation

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

Metadata

Metadata

Assignees

Labels

- P3: minor bugAn edge case that only affects very specific usage (priority)feat: assetsRelated to the Assets feature (scope)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions