@@ -249,15 +249,20 @@ async function infoForImageFile(matrixClient: MatrixClient, roomId: string, imag
249249 const result = await createThumbnail ( imageElement . img , imageElement . width , imageElement . height , thumbnailType ) ;
250250 const imageInfo = result . info ;
251251
252- // we do all sizing checks here because we still rely on thumbnail generation for making a blurhash from.
253- const sizeDifference = imageFile . size - imageInfo . thumbnail_info . size ;
254- if (
255- imageFile . size <= IMAGE_SIZE_THRESHOLD_THUMBNAIL || // image is small enough already
256- ( sizeDifference <= IMAGE_THUMBNAIL_MIN_REDUCTION_SIZE && // thumbnail is not sufficiently smaller than original
257- sizeDifference <= ( imageFile . size * IMAGE_THUMBNAIL_MIN_REDUCTION_PERCENT ) )
258- ) {
259- delete imageInfo [ "thumbnail_info" ] ;
260- return imageInfo ;
252+ // For lesser supported image types, always include the thumbnail even if it is larger
253+ if ( ! [ "image/avif" , "image/webp" ] . includes ( imageFile . type ) ) {
254+ // we do all sizing checks here because we still rely on thumbnail generation for making a blurhash from.
255+ const sizeDifference = imageFile . size - imageInfo . thumbnail_info . size ;
256+ if (
257+ // image is small enough already
258+ imageFile . size <= IMAGE_SIZE_THRESHOLD_THUMBNAIL ||
259+ // thumbnail is not sufficiently smaller than original
260+ ( sizeDifference <= IMAGE_THUMBNAIL_MIN_REDUCTION_SIZE &&
261+ sizeDifference <= ( imageFile . size * IMAGE_THUMBNAIL_MIN_REDUCTION_PERCENT ) )
262+ ) {
263+ delete imageInfo [ "thumbnail_info" ] ;
264+ return imageInfo ;
265+ }
261266 }
262267
263268 const uploadResult = await uploadFile ( matrixClient , roomId , result . thumbnail ) ;
0 commit comments