diff --git a/README.md b/README.md index 32a1c61..8a0aaa9 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,55 @@ return $image->stream('png', 100); ```` 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. + +### Example usage in a webpage +To display the image generated by the InitialAvatarGenerator library directly on a webpage, you can utilize PHP headers to output the image as a stream or generate a temporary file and display it using an `````` tag. + +To output the image as a stream, you can create a separate PHP endpoint (like avatar.php) that generates the avatar image and streams it as a PNG. Then, you use the URL of this endpoint as the src of an `````` tag on your webpage. + +An example endpoint file (**avatar.php**) is below: + +```php +name($name)->generate(); + +// Stream the image directly to the output +echo $image->stream('png', 100); +exit; + +``` + +In the HTML file, you can reference the snippet below: + +```html + + + + + + Avatar Example + + +

User Avatar

+ + Avatar for John Doe + + Avatar for Jane Smith + + + +``` + ## SVG generation ````php $avatar = new LasseRafn\InitialAvatarGenerator\InitialAvatar();