{"record":{"id":"e0e60cb5bb32ec4f","repo":"withastro/astro","slug":"astro-could-not-optimize-image-transform-src","errorCode":null,"errorMessage":"Astro could not optimize image \"${transform.src}\". Sharp doesn't support this format. The image will be used unoptimized. Consider converting to WebP or placing in the public/ folder.","messagePattern":"Astro could not optimize image \"(.+?)\"\\. Sharp doesn't support this format\\. The image will be used unoptimized\\. Consider converting to WebP or placing in the public/ folder\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/astro/src/assets/services/sharp.ts","lineNumber":253,"sourceCode":"\t\t} else if (outputFormat === 'png') {\n\t\t\tresult.png(encoderOptions as PngOptions | undefined);\n\t\t} else if (outputFormat === 'avif') {\n\t\t\tresult.avif(encoderOptions as AvifOptions | undefined);\n\t\t} else if (outputFormat === 'jpeg' || outputFormat === 'jpg') {\n\t\t\tresult.jpeg(encoderOptions as JpegOptions | undefined);\n\t\t} else {\n\t\t\tresult.toFormat(outputFormat as keyof FormatEnum, encoderOptions);\n\t\t}\n\n\t\tlet data: Uint8Array;\n\t\tlet info: { format: string };\n\t\ttry {\n\t\t\t({ data, info } = await result.toBuffer({ resolveWithObject: true }));\n\t\t} catch {\n\t\t\t// Sharp cannot decode this image (e.g. animated AVIF sequences).\n\t\t\t// Pass it through unmodified rather than crashing the build. When Sharp adds support for these\n\t\t\t// formats, the image will be optimized automatically without code changes.\n\t\t\tlogger.warn(\n\t\t\t\t`Astro could not optimize image \"${transform.src}\". Sharp doesn't support this format. The image will be used unoptimized. Consider converting to WebP or placing in the public/ folder.`,\n\t\t\t);\n\t\t\treturn { data: inputBuffer, format: bufferFormat as ImageOutputFormat };\n\t\t}\n\n\t\t// Sharp can sometimes return a SharedArrayBuffer when using WebAssembly.\n\t\t// SharedArrayBuffers need to be copied into an ArrayBuffer in order to be manipulated.\n\t\tconst needsCopy = 'buffer' in data && data.buffer instanceof SharedArrayBuffer;\n\n\t\treturn {\n\t\t\tdata: needsCopy ? new Uint8Array(data) : data,\n\t\t\tformat: info.format as ImageOutputFormat,\n\t\t};\n\t},\n};\n\nexport default sharpService;\n","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/withastro/astro/blob/e294953aa8aadd98d5be92e60a03037b05dbdfd4/packages/astro/src/assets/services/sharp.ts#L235-L271","documentation":"Error \"Astro could not optimize image \"${transform.src}\". Sharp doesn't support this format. The image will be used unoptimized. Consider converting to WebP or placing in the public/ folder.\" thrown in withastro/astro.","triggerScenarios":"Thrown at packages/astro/src/assets/services/sharp.ts:253 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e294953aa8aadd98d5be92e60a03037b05dbdfd4","analyzedAt":"2026-09-09T03:35:40.650Z","contentChangedAt":"2026-09-09T03:35:40.650Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}