File tree Expand file tree Collapse file tree
packages/astro/src/assets/services Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -71,6 +71,9 @@ const sharpService: LocalImageService<SharpImageServiceConfig> = {
7171 // always call rotate to adjust for EXIF data orientation
7272 result . rotate ( ) ;
7373
74+ // get some information about the input
75+ const { format } = await result . metadata ( ) ;
76+
7477 // If `fit` isn't set then use old behavior:
7578 // - Do not use both width and height for resizing, and prioritize width over height
7679 // - Allow enlarging images
@@ -108,15 +111,7 @@ const sharpService: LocalImageService<SharpImageServiceConfig> = {
108111 }
109112 }
110113
111- const isGifInput =
112- inputBuffer [ 0 ] === 0x47 && // 'G'
113- inputBuffer [ 1 ] === 0x49 && // 'I'
114- inputBuffer [ 2 ] === 0x46 && // 'F'
115- inputBuffer [ 3 ] === 0x38 && // '8'
116- ( inputBuffer [ 4 ] === 0x39 || inputBuffer [ 4 ] === 0x37 ) && // '9' or '7'
117- inputBuffer [ 5 ] === 0x61 ; // 'a'
118-
119- if ( transform . format === 'webp' && isGifInput ) {
114+ if ( transform . format === 'webp' && format === 'gif' ) {
120115 // Convert animated GIF to animated WebP with loop=0 (infinite)
121116 result . webp ( { quality : typeof quality === 'number' ? quality : undefined , loop : 0 } ) ;
122117 } else {
You can’t perform that action at this time.
0 commit comments