From da44bb19e9ed3cf3b50fa1925173fa2bb9e3ae8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lindo=C3=A9lio=20L=C3=A1zaro?= Date: Mon, 18 Sep 2017 17:13:14 -0300 Subject: [PATCH] Add avatar conversion of SVG to PNG. --- server/startup/avatar.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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; } }