Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow sharp format options #13073

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Ceres6
Copy link

@Ceres6 Ceres6 commented Jan 26, 2025

Changes

Allow sharp format options (e.g. https://sharp.pixelplumbing.com/api-output#avif)

Testing

I haven't added any tests yet, just opening to see if the feature is desired and this a good approach. However I'm not sure how to test this, trying all combinations would be impossible, maybe mocking to check options are actually passed is an option

Docs

I will add the change to the config reference once the api is decided.

cc @Princesseuh as discussed on Discord

@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) semver: minor Change triggers a `minor` release labels Jan 26, 2025
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is blocked because it contains a minor changeset. A reviewer will merge this at the next release if approved.

Copy link

codspeed-hq bot commented Jan 26, 2025

CodSpeed Performance Report

Merging #13073 will not alter performance

Comparing Ceres6:feat/sharp-format-options (5cd2ca5) with main (e36837f)

Summary

✅ 6 untouched benchmarks

@ematipico
Copy link
Member

@Ceres6 if there has been a discussion on Discord, it would be useful to link here the thread/topic/message, so it will provides us more context.

@ematipico
Copy link
Member

I don't see anything wrong in adding more options, however since the PR lacks context, and it doesn't describe how these options will be used by our end users (lack of tests, changeset or even description), I find it very difficult to give a proper review.

@Ceres6
Copy link
Author

Ceres6 commented Jan 27, 2025

Here is the thread although it wasn't a long discussion.

The context is that for some webs where image quality is critical having those extra options would be great. My use case is a photographers portfolio where compression to avif in images with smooth white backgrounds appear riddles, so options as effort or lossless provide better customisation.

The change is to be able to pass that in config like:

import { defineConfig } from 'astro/config'

export default defineConfig({
  image: {
    // Example: Enable the Sharp-based image service with a custom config
    service: {
       entrypoint: 'astro/assets/services/sharp',
       config: {
         formatConfig: {
           avif: {
             effort: 9,
             lossless: true,
           },
         },
       },
     },
  },
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope) semver: minor Change triggers a `minor` release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants