Letter avatar font - letters horizontally off centre

Further to:

It looks like some letters have gone off centre - perhaps because of a font update?

Not sure if this is all of them - but R, N, M and G are off.

The numbers in the image are the width of rendered pixels for the character left / right of the black line.


It’s because we updated ImageMagick to the latest version due to ImageTragick and, like every time we change version, avatars got “decentered:expressionless:


Don’t know a upgrade can do that…ImageMagick are so nice at API :sweat:
My multimedia project is generating letter avatar. I think I will go with OpenResty. Either way, I would tweak ImageMagick. And PR welcome here? I still need to center the avatar by all means. (<= Next week)

By the way, how you generate this graph? Looks good to generate for testing!


I think the Discourse team has submitted the same, if not similar, PR to ImageMagick to fix this issue multiple times now. As future versions continue to break it.

1 Like

I was referencing letter_avatars microservice. There is a spot you can have an offset for those avatars.

Although, I will try to find the root cause

1 Like

Yeah, so was I. There have been times the offset was caused by a change in ImageMagick. I don’t really recall the details, may I can find the related topics here. I know there is also an offset table/array too.

I think this is semi-related

Granted now we’re talking horizontally instead of vertically


This one was manual - didn’t trust ImageMagick for this.


A PR against the microservice to realign letter avatars would be greatly appreciated. The problems we had keeping letters aligned previously were related to our pulling whatever counted as “the latest” IM version when we built the image; I’ve fixed that now so we depend on a well-specified version of IM, so we can have better control over when things go haywire. So, if you’d like to submit a PR with a set of manual adjustment tweaks, that should be enough to keep things in the right place from now on.


Putting some tests on canvas. My local env does say different thing, so takes some time to dig into. When pointing to avatar services, got a lot of 500s.

Source: https://github.com/fantasticfears/letter-avatars-test

I would bet ImageMagick and fontconfig version will cause a lot of differences.

Update1: 500 is caused by…I exhausted the avatar service. Here is what we have now for official service:

Update2: @mpalmer My investigation is done. I would need the information of deploy environment to test the result.
I would bet MPC intermediate file will be much faster than PNG file, so I would update the command if applicable.
I can exhaust the service because of only 16 threads. But that’s because file IO. Nginx should queue all those requests before bombing the ruby scripts.


Hi Eric,

The deployment environment is contained in the Dockerfile in the letter-avatars repo. We just point port 80 on the host to the puma running in the container, and let 'er rip.


If you are using 120x120 images I would recommend making your black guide lines 2 pixels wide…
… otherwise they will always look off centre as 1 pixel does not evenly divide into 120 visually.