Comments (11)
Thank you!
Sure thing, I will attempt to make centering better! π
from ui-avatars.
Sorry for the crazy slow response, been super busy. Anyway, I think this makes sense π Will try to experiment and compare the two, maybe add an option to use one, but default to the most correct one
from ui-avatars.
Hi Lasse,
I did some more debugging. And as one friend of mine once said: "The sitation is strange." :D
Changing the driver of ImageManager to Imagick in InitialAvatar class ...
InitialAvatar.php, line 34:
$this->image = new ImageManager(['driver' => 'imagick']);
... makes text to get then properly aligned in horizontal but the vertical alignment then goes wrong :)
Bugger.
Maybe there be a bug somewhere in Intervention -> Image lib.
Or with the font.
from ui-avatars.
And I debugged even a bit more using directly ImageMagick. I did this simple command line script:
<?php
declare(strict_types=1);
$fontFileName =
"/tmp/fonts/OpenSans-Regular.ttf";
$fillColor = new \ImagickPixel('#000');
$strokeColor = new \ImagickPixel('#000');
$backgroundColor = new \ImagickPixel('#f7f924');
$initials = 'PM';
$avatarSize = 256;
$fontSize = 0.5 * $avatarSize;
$draw = new \ImagickDraw();
$draw->setStrokeColor($strokeColor);
$draw->setFillColor($fillColor);
$draw->setStrokeWidth(2);
$draw->setFontSize($fontSize);
$draw->setFont(
$fontFileName
);
$draw->setGravity(\Imagick::GRAVITY_CENTER);
$draw->annotation(0, 0, $initials);
$imagick = new \Imagick();
$imagick->newImage($avatarSize, $avatarSize, $backgroundColor);
$imagick->drawImage($draw);
$imagick->writeImage("/tmp/test.png");
That one also has some problems to place the text correctly "exactly" aligned. But, IMHO, has better general output on different fonts and sizes.
What do you think Lasse? If you feel like this won't fix on UI-avatars, i understand :) In that case, just close this issue.
from ui-avatars.
Hi this is a really useful service however this off centre issue is starting to bug me too. Is there any update on fixing this?
from ui-avatars.
from ui-avatars.
Any solution yet ?
from ui-avatars.
@aliaanis I've been unable to find a solution π I will try @HsRealDev's solution as I think he is definitively onto something (good work, thanks!)
from ui-avatars.
fwiw: it looks like svg might be rendering correctly and failing during png conversion?
svg (https://ui-avatars.com/api/?name=B&size=250&format=svg)
png (https://ui-avatars.com/api/?name=B&size=250&format=png)
from ui-avatars.
Any updates on this @LasseRafn ? ππΌ
from ui-avatars.
@LasseRafn did the solution you tried lead anywhere?
from ui-avatars.
Related Issues (20)
- Add support for gradient backgrounds HOT 2
- No usage tracking HOT 2
- First load error HOT 1
- Custom font name when requesting .svg
- Fatal error: Uncaught Error: Class 'Utils\Input' not found HOT 1
- ui-avatars.com is down again HOT 6
- Gravatar strips the spaces in the name from default URL HOT 3
- receiving duplicate cors headers
- The deployed website does not match the code on GitHub
- Duplicate response headers returned
- ui-avatars.com is down - return Error 502
- Directory URLs not working (incl Gravatar fallbacks) HOT 7
- Dockerfile fails to start HOT 1
- "EΜdward Doe" returns "ED" when it should return "EΜD"
- Error in avatar - User with special char "&" HOT 2
- feat: Unique (background)color based on text HOT 2
- Monospace Font? HOT 1
- Use Own Avatars with the API
- Can't generate avatar with three initials (including middle initial) HOT 2
- Error when value of param `name` contains `<` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ui-avatars.