Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/common-signs-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': minor
Comment thread
Princesseuh marked this conversation as resolved.
Outdated
---

The built-in image service now supports converting SVG images to raster formats.
5 changes: 1 addition & 4 deletions packages/astro/src/assets/services/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,7 @@ export function verifyOptions(options: ImageTransform): void {
throw new AstroError(AstroErrorData.IncompatibleDescriptorOptions);
}

if (
(options.src.format === 'svg' && options.format !== 'svg') ||
(options.src.format !== 'svg' && options.format === 'svg')
) {
if (options.src.format !== 'svg' && options.format === 'svg') {
throw new AstroError(AstroErrorData.UnsupportedImageConversion);
}
}
Expand Down
4 changes: 0 additions & 4 deletions packages/astro/src/assets/services/sharp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ const sharpService: LocalImageService<SharpImageServiceConfig> = {
if (!sharp) sharp = await loadSharp();
const transform: BaseServiceTransform = transformOptions as BaseServiceTransform;

// Return SVGs as-is
// TODO: Sharp has some support for SVGs, we could probably support this once Sharp is the default and only service.
if (transform.format === 'svg') return { data: inputBuffer, format: 'svg' };

const result = sharp(inputBuffer, {
failOnError: false,
pages: -1,
Expand Down
Loading