Skip to content

Commit b75733d

Browse files
committed
SVG and height/width support
1 parent 50406a7 commit b75733d

File tree

4 files changed

+226
-27
lines changed

4 files changed

+226
-27
lines changed

README.md

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ return $image->stream('png', 100);
3939
````
4040
You can also just pass along the initials, and it will use those. Should you just include a first name, it will use the first two letters of it.
4141

42+
## SVG generation
43+
````php
44+
$avatar = new LasseRafn\InitialAvatarGenerator\InitialAvatar();
45+
46+
echo $avatar->name('Lasse Rafn')->generateSvg()->toXMLString(); // returns SVG XML string
47+
````
48+
4249
## Supported methods and parameters
4350
Of cause, passing a name is not the only thing this sweet thing does!
4451

@@ -55,19 +62,31 @@ Will detect language script (using [lasserafn/php-string-script-language](https:
5562
$image = $avatar->autoFont()->generate();
5663
````
5764

58-
### Size - default: 48
65+
### Width - default: 48
66+
````php
67+
// will be 96 pixels wide.
68+
$image = $avatar->width(96)->generate();
69+
````
70+
71+
### Height - default: 48
72+
````php
73+
// will be 96 pixels tall.
74+
$image = $avatar->height(96)->generate();
75+
````
76+
77+
### Size - default: 48 (proxy for `$avatar->width(X)->height(X)`)
5978
````php
6079
// will be 96x96 pixels.
6180
$image = $avatar->size(96)->generate();
6281
````
6382

64-
### Background color - default: #000
83+
### Background color - default: #f0e9e9
6584
````php
6685
// will be red
6786
$image = $avatar->background('#ff0000')->generate();
6887
````
6988

70-
### Font color - default: #fff
89+
### Font color - default: #8b5d5d
7190
````php
7291
// will be red
7392
$image = $avatar->color('#ff0000')->generate();
@@ -88,8 +107,11 @@ If you input an integer between 1 and 5, it will use a GD Internal font as per t
88107
$image = $avatar->font('/fonts/OpenSans-Semibold.ttf')->generate();
89108
````
90109

91-
### Cache - removed!
92-
Cache has been removed. Performance-wise it was not doing much anyway.
110+
### Font name (for SVGs) - default: Open Sans, sans-serif
111+
112+
````php
113+
$image = $avatar->fontName('Arial, Helvetica, sans-serif')->generate();
114+
````
93115

94116
### Length - default: 2
95117
````php
@@ -171,7 +193,7 @@ return $avatar->glyph('f007')
171193
```
172194

173195
## Requirements
174-
* PHP 5.6, 7.0, 7.1 or 7.2
196+
* PHP +7.0
175197
* Fileinfo Extension (from intervention/image)
176198

177199
## Script/Language support

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"keywords": [
55
"initials",
66
"image",
7-
"avatar"
7+
"avatar",
8+
"svg",
89
],
910
"type": "library",
1011
"license": "MIT",
@@ -20,6 +21,7 @@
2021
"intervention/image": "^2.3",
2122
"lasserafn/php-initials": "^2.20",
2223
"lasserafn/php-string-script-language": "^0.1.0",
24+
"meyfa/php-svg": "^0.9.0",
2325
"overtrue/pinyin": "^4.0"
2426
},
2527
"require-dev": {

composer.lock

Lines changed: 47 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)