diff options
author | 2022-11-29 03:27:39 +0800 | |
---|---|---|
committer | 2022-11-28 14:27:39 -0500 | |
commit | 299ae9bb6a84e178e742cceb20d87190e64653fc (patch) | |
tree | 89212b137064e65502a544e50ef18e98fc34d6e8 | |
parent | f90a36873cb7e7a232f147d00d5eb2d2eda9fa16 (diff) | |
download | astro-299ae9bb6a84e178e742cceb20d87190e64653fc.tar.gz astro-299ae9bb6a84e178e742cceb20d87190e64653fc.tar.zst astro-299ae9bb6a84e178e742cceb20d87190e64653fc.zip |
fix bug: added a warning if the image was GIF (#5474)
Co-authored-by: wuls <linsheng.wu@beantechs.com>
-rw-r--r-- | .changeset/dirty-scissors-fail.md | 5 | ||||
-rw-r--r-- | packages/integrations/image/src/vendor/squoosh/impl.ts | 4 |
2 files changed, 9 insertions, 0 deletions
diff --git a/.changeset/dirty-scissors-fail.md b/.changeset/dirty-scissors-fail.md new file mode 100644 index 000000000..0ec7f4cde --- /dev/null +++ b/.changeset/dirty-scissors-fail.md @@ -0,0 +1,5 @@ +--- +'@astrojs/image': minor +--- + +added a warning if the image was GIF diff --git a/packages/integrations/image/src/vendor/squoosh/impl.ts b/packages/integrations/image/src/vendor/squoosh/impl.ts index fa50c0fd9..3d01141d3 100644 --- a/packages/integrations/image/src/vendor/squoosh/impl.ts +++ b/packages/integrations/image/src/vendor/squoosh/impl.ts @@ -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 |