1

I have created a function that creates an initials avatar using node.js gm. But it always creates a square-shaped avatar, I want it to create a circle shaped image. I have already tried other solutions but they seem to be not working. I want to use only gm module. Following is my function

function setCircleInitials(initialsData){
  gm(initialsData.size, initialsData.size, initialsData.background_color)
  .gravity('Center')
  .fill('white')
  .font('fonts/AvenirNext.otf', initialsData.font_size)
  .drawText(0, initialsData.top_offset, initialsData.initials.substring(0,2).toUpperCase())
  .toBase64('png', function(err, base64) {
  if (err) {
    return console.log(err);
  }
}
Saad Zafar
  • 21
  • 3
  • possible duplicate of https://stackoverflow.com/questions/29256640/how-to-use-graphicsmagick-in-node-js-to-crop-circle-picture-other-use-any-other – mehari Jun 14 '18 at 06:43
  • I have already tried that solution. And I want to use only the `gm` library – Saad Zafar Jun 14 '18 at 07:15

0 Answers0