mirror of
https://github.com/withastro/astro.git
synced 2025-01-20 22:12:38 -05:00
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)
|
const firstChunkString = Array.from(firstChunk)
|
||||||
.map((v) => String.fromCodePoint(v))
|
.map((v) => String.fromCodePoint(v))
|
||||||
.join('')
|
.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 }]) =>
|
const key = Object.entries(supportedFormats).find(([, { detectors }]) =>
|
||||||
detectors.some((detector) => detector.exec(firstChunkString))
|
detectors.some((detector) => detector.exec(firstChunkString))
|
||||||
)?.[0] as EncoderKey | undefined
|
)?.[0] as EncoderKey | undefined
|
||||||
|
|
Loading…
Add table
Reference in a new issue