[FIX] Avatars with transparency were being converted to black (#13181)

pull/13194/head
Rodrigo Nascimento 6 years ago committed by GitHub
parent a2bdd3b8fd
commit dc2005b76d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      packages/rocketchat-file-upload/server/lib/FileUpload.js

@ -101,12 +101,20 @@ export const FileUpload = Object.assign(_FileUpload, {
metadata = {}; metadata = {};
} }
s.toFormat(sharp.format.jpeg) s.flatten({ background: '#FFFFFF' })
.resize(Math.min(height || 0, metadata.width || Infinity), Math.min(height || 0, metadata.height || Infinity)) .jpeg()
.resize({
width: Math.min(height || 0, metadata.width || Infinity),
height: Math.min(height || 0, metadata.height || Infinity),
fit: sharp.fit.cover,
})
.pipe(sharp() .pipe(sharp()
.resize(height, height) .resize({
.background('#FFFFFF') height,
.embed() width: height,
fit: sharp.fit.contain,
background: '#FFFFFF',
})
) )
// Use buffer to get the result in memory then replace the existing file // Use buffer to get the result in memory then replace the existing file
// There is no option to override a file using this library // There is no option to override a file using this library

Loading…
Cancel
Save