{"record":{"id":"8ebb7c01722e6180","repo":"withastro/astro","slug":"unsupportedimageformat-8ebb7c","errorCode":"UnsupportedImageFormat","errorMessage":"SVG image processing is disabled, but the source for \"${transform.src}\" is an SVG. Pass it through unchanged by setting `format=\"svg\"` on the component, or set `image.dangerouslyProcessSVG: true` to rasterize SVG sources.","messagePattern":"SVG image processing is disabled, but the source for \"(.+?)\" is an SVG\\. Pass it through unchanged by setting `format=\"svg\"` on the component, or set `image\\.dangerouslyProcessSVG: true` to rasterize SVG sources\\.","errorType":"exception","errorClass":"AstroError","httpStatus":null,"severity":"error","filePath":"packages/astro/src/assets/services/sharp.ts","lineNumber":178,"sourceCode":"\t\t\tif (bufferFormat && bufferFormat !== 'svg') {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`⚠️  Astro expected an SVG for \"${transform.src}\" but the source is ${bufferFormat}. Passing it through as ${bufferFormat} instead.`,\n\t\t\t\t);\n\t\t\t\treturn { data: inputBuffer, format: bufferFormat as ImageOutputFormat };\n\t\t\t}\n\t\t\treturn { data: inputBuffer, format: 'svg' };\n\t\t}\n\n\t\t// If we couldn't figure out the format, it's probably something weird we shouldn't try to process.\n\t\tif (!bufferFormat) {\n\t\t\tthrow new AstroError({\n\t\t\t\t...AstroErrorData.NoImageMetadata,\n\t\t\t\tmessage: AstroErrorData.NoImageMetadata.message(transform.src),\n\t\t\t});\n\t\t}\n\n\t\tif (bufferFormat === 'svg' && !config.dangerouslyProcessSVG) {\n\t\t\tthrow new AstroError({\n\t\t\t\t...AstroErrorData.UnsupportedImageFormat,\n\t\t\t\tmessage: `SVG image processing is disabled, but the source for \"${transform.src}\" is an SVG. Pass it through unchanged by setting \\`format=\"svg\"\\` on the component, or set \\`image.dangerouslyProcessSVG: true\\` to rasterize SVG sources.`,\n\t\t\t});\n\t\t}\n\n\t\tconst result = sharp(inputBuffer, {\n\t\t\tfailOn: 'none',\n\t\t\tpages: -1,\n\t\t\tlimitInputPixels: config.service.config.limitInputPixels,\n\t\t});\n\n\t\t// always call rotate to adjust for EXIF data orientation\n\t\tresult.rotate();\n\n\t\tif (transform.width && transform.height) {\n\t\t\tconst fit: keyof FitEnum | undefined = transform.fit\n\t\t\t\t? (fitMap[transform.fit] ?? 'inside')\n\t\t\t\t: undefined;","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/withastro/astro/blob/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/astro/src/assets/services/sharp.ts#L160-L196","documentation":"Thrown by the sharp service when the input buffer is detected as SVG, outputFormat is not 'svg', and config.dangerouslyProcessSVG is falsy. Astro does not rasterize SVGs through sharp by default for safety; it requires an explicit opt-in. The message tells the user to either pass format='svg' (to pass it through unchanged) or set image.dangerouslyProcessSVG: true to rasterize.","triggerScenarios":"Passing an SVG source to getImage/<Image> with a raster output format (e.g. format: 'png') while image.dangerouslyProcessSVG is unset/false. bufferFormat === 'svg' triggers the guard; outputFormat being anything other than 'svg' was already handled earlier.","commonSituations":"Author imports an SVG and requests rasterization (png/webp) without opting in, or a shared component forces a raster format onto an SVG import. Rasterizing SVG via sharp can be a security/DoS surface, hence the opt-in.","solutions":["Set format: 'svg' on the component/getImage to pass the SVG through unchanged.","Or enable rasterization explicitly: image: { dangerouslyProcessSVG: true } in astro.config.","Pre-convert the SVG to a raster format with an external tool if occasional raster output is needed.","Keep SVGs as SVG unless rasterization is genuinely required."],"exampleFix":"// before\n<Image src={logoSvg} format='png' />\n\n// after\n<Image src={logoSvg} format='svg' />","handlingStrategy":"validation","validationCode":"function svgOutputSafe(srcFormat: string, outputFormat: string | undefined, allowDangerous: boolean): boolean {\n  if (srcFormat === 'svg') return outputFormat === 'svg' || !!allowDangerous;\n  return true;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use format='svg' for SVG sources unless rasterization is intentional.","Only enable image.dangerouslyProcessSVG after a security review.","Avoid forcing a single raster format across mixed svg/raster imports."],"tags":["images","svg","sharp","security","config"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}