Skip to content

Is Astro making images larger? #12314

@blopker

Description

@blopker

Astro Info

Astro                    v4.16.7
Node                     v23.0.0
System                   macOS (arm64)
Package Manager          bun
Output                   static
Adapter                  none
Integrations             @astrojs/mdx
                         @astrojs/tailwind
                         pagefind
                         @astrojs/solid-js
                         astro-icon

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

No response

Describe the Bug

It seems like the image optimization process is actually making image larger. Here's the output from astro build:

4:34:25 PM:  generating optimized images 
4:34:25 PM: 09:34:25   ▶ /_astro/bali_vids.Bokn6UPM_ZdW7qj.webp (before: 92kB, after: 106kB) (+280ms) (1/29)
4:34:25 PM: 09:34:25   ▶ /_astro/traffic.CY3uXBQB_Z2coWA1.webp (before: 70kB, after: 82kB) (+114ms) (2/29)
4:34:25 PM: 09:34:25   ▶ /_astro/fastboat.Bv4mBUji_2hYwmC.webp (before: 80kB, after: 93kB) (+134ms) (3/29)
4:34:26 PM: 09:34:26   ▶ /_astro/horsey.BXViqSaB_9Am1W.webp (before: 97kB, after: 112kB) (+229ms) (4/29)
4:34:26 PM: 09:34:26   ▶ /_astro/ubud.CvSjUs1F_1clYMi.webp (before: 153kB, after: 180kB) (+294ms) (5/29)
4:34:26 PM: 09:34:26   ▶ /_astro/lush.PzJLZ22N_2kV5sa.webp (before: 116kB, after: 135kB) (+120ms) (6/29)
4:34:26 PM: 09:34:26   ▶ /_astro/sunset.xi1IdWl6_15L7mX.webp (before: 54kB, after: 63kB) (+244ms) (7/29)
4:34:27 PM: 09:34:27   ▶ /_astro/tr-header.DAh8LYlv_1ty9jI.webp (before: 173kB, after: 201kB) (+299ms) 
[truncated]

Collectively, Astro is adding 541 kB to the images for this site. Is this expected?

Here's the output for ls for a single image, first one is the original and second is the post processed image in dist/_astro:

116K Oct 27 16:19 lush.webp
135K Oct 27 16:31 lush.PzJLZ22N_2kV5sa.webp

Is it possible for Astro to throw away the optimization if the original image is smaller than the processed image?

What's the expected result?

Astro should not be making images larger.

Here's an example image that is made larger:
lush.webp.zip

Link to Minimal Reproducible Example

None

Participation

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs reproIssue needs a reproduction

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions