Skip to content

Commit

Permalink
fix bug: added a warning if the image was GIF (#5474)
Browse files Browse the repository at this point in the history
Co-authored-by: wuls <linsheng.wu@beantechs.com>
  • Loading branch information
JerryWu1234 and wuls authored Nov 28, 2022
1 parent f90a368 commit 299ae9b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/dirty-scissors-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/image': minor
---

added a warning if the image was GIF
4 changes: 4 additions & 0 deletions packages/integrations/image/src/vendor/squoosh/impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 299ae9b

Please sign in to comment.