fix bug: added a warning if the image was GIF (#5474)
Co-authored-by: wuls <linsheng.wu@beantechs.com>
This commit is contained in:
parent
f90a36873c
commit
299ae9bb6a
2 changed files with 9 additions and 0 deletions
5
.changeset/dirty-scissors-fail.md
Normal file
5
.changeset/dirty-scissors-fail.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@astrojs/image': minor
|
||||
---
|
||||
|
||||
added a warning if the image was GIF
|
|
@ -31,6 +31,10 @@ export async function decodeBuffer(
|
|||
const firstChunkString = Array.from(firstChunk)
|
||||
.map((v) => String.fromCodePoint(v))
|
||||
.join('')
|
||||
// TODO (future PR): support more formats
|
||||
if (firstChunkString.includes('GIF')) {
|
||||
throw Error(`GIF images are not supported, please install the @astrojs/image/sharp plugin`)
|
||||
}
|
||||
const key = Object.entries(supportedFormats).find(([, { detectors }]) =>
|
||||
detectors.some((detector) => detector.exec(firstChunkString))
|
||||
)?.[0] as EncoderKey | undefined
|
||||
|
|
Loading…
Reference in a new issue