diff --git a/server/startup/avatar.js b/server/startup/avatar.js index 261f18fa276..912cd887a08 100644 --- a/server/startup/avatar.js +++ b/server/startup/avatar.js @@ -1,4 +1,4 @@ -/* globals FileUpload */ +/* globals FileUpload, RocketChatFile */ Meteor.startup(function() { WebApp.connectHandlers.use('/avatar/', Meteor.bindEnvironment(function(req, res/*, next*/) { @@ -86,11 +86,16 @@ Meteor.startup(function() { initials = initials.toUpperCase(); } - const svg = `\n\n\n\n${ initials }\n\n`; - - res.write(svg); - res.end(); + const svg = `\n\n\n\n${ initials }\n\n`; + if (RocketChat.Info.GraphicsMagick.enabled || RocketChat.Info.ImageMagick.enabled) { + const svgBuffer = new Buffer(svg); + res.setHeader('Content-Type', 'image/png'); + RocketChatFile.gm(svgBuffer).stream('png').pipe(res); + } else { + res.write(svg); + res.end(); + } return; } }