### Install PHP Initial Avatar Generator via Composer Source: https://github.com/lasserafn/php-initial-avatar-generator/blob/master/README.md This command installs the PHP initial avatar generator package using Composer, making it available for use in your PHP project. ```bash composer require lasserafn/php-initial-avatar-generator ``` -------------------------------- ### Displaying Generated Avatar in HTML Source: https://github.com/lasserafn/php-initial-avatar-generator/blob/master/README.md Provides an example of how to use an `` tag in HTML to display the avatar generated by the PHP script, setting the width, height, and applying basic styling like border-radius. ```html ``` -------------------------------- ### Creating PHP Endpoint for Avatar Streaming Source: https://github.com/lasserafn/php-initial-avatar-generator/blob/master/README.md Full PHP script (`avatar.php`) demonstrating how to create an endpoint that generates an avatar based on a GET parameter ('name') and streams it directly as a PNG image using appropriate headers. ```php name($name)->generate(); // Stream the image directly to the output echo $image->stream('png', 100); exit; ``` -------------------------------- ### Switching Image Driver (PHP) Source: https://github.com/lasserafn/php-initial-avatar-generator/blob/master/README.md Demonstrates how to explicitly select the image processing driver, either GD (`gd()`) or Imagick (`imagick()`), before generating the avatar. ```php $image = $avatar->gd()->generate(); // Uses GD driver $image = $avatar->imagick()->generate(); // Uses Imagick driver ``` -------------------------------- ### Chaining Methods for PHP Avatar Generation Source: https://github.com/lasserafn/php-initial-avatar-generator/blob/master/README.md Shows how to chain multiple configuration methods (`name`, `length`, `fontSize`, `size`, `background`, `color`) together to customize the avatar before generating and streaming the image output. ```php return $avatar->name('Lasse Rafn') ->length(2) ->fontSize(0.5) ->size(96) // 48 * 2 ->background('#8BC34A') ->color('#fff') ->generate() ->stream('png', 100); ``` -------------------------------- ### Displaying Avatar using PHP Endpoint (HTML) Source: https://github.com/lasserafn/php-initial-avatar-generator/blob/master/README.md HTML snippet showing how to use the `` tag to display avatars generated by a PHP endpoint (`avatar.php`), passing the desired name as a query parameter. ```html Avatar Example

User Avatar

Avatar for John Doe Avatar for Jane Smith ``` -------------------------------- ### Using Font Awesome Glyphs with PHP Avatar Generator Source: https://github.com/lasserafn/php-initial-avatar-generator/blob/master/README.md Illustrates how to generate an avatar using a specific Font Awesome glyph instead of user initials by using the `glyph()` method with the icon's unicode and specifying the Font Awesome font file. ```php // note that we // 1) use glyph() instead of name // 2) change the font to FontAwesome! return $avatar->glyph('f007') ->font('/fonts/FontAwesome5Free-Regular-400.otf') ->color('#fff') ->background('#ff0000') ->generate() ->stream('png', 100); ``` -------------------------------- ### Setting Avatar Name (PHP) Source: https://github.com/lasserafn/php-initial-avatar-generator/blob/master/README.md Demonstrates using the `name()` method to specify the name from which initials are derived for the avatar. Defaults to 'JD' if no name is provided. ```php $image = $avatar->name('Albert Magnum')->generate(); ``` -------------------------------- ### Generating Basic Avatar Image (PHP) Source: https://github.com/lasserafn/php-initial-avatar-generator/blob/master/README.md Initializes the InitialAvatarGenerator and generates a basic avatar image from a name. Returns an Intervention Image instance. ```php $avatar = new LasseRafn\InitialAvatarGenerator\InitialAvatar(); $image = $avatar->name('Lasse Rafn')->generate(); ``` -------------------------------- ### Enabling Smooth Rounding (PHP) Source: https://github.com/lasserafn/php-initial-avatar-generator/blob/master/README.md Improves the appearance of rounded avatars by applying a smoothing technique using the `smooth()` method, which helps avoid pixelated edges. Recommended when using `rounded()`. ```php $image = $avatar->rounded()->smooth()->generate(); ``` -------------------------------- ### Enabling Auto Color for Avatar (PHP) Source: https://github.com/lasserafn/php-initial-avatar-generator/blob/master/README.md Uses the `autoColor()` method to automatically select a background color based on the name and a contrasting font color. The color choice is consistent for a given name. ```php $image = $avatar->autoColor()->generate(); ``` -------------------------------- ### Enabling Auto Font for Avatar (PHP) Source: https://github.com/lasserafn/php-initial-avatar-generator/blob/master/README.md Uses the `autoFont()` method to enable automatic detection of the language script and selection of a suitable font that supports it. ```php $image = $avatar->autoFont()->generate(); ``` -------------------------------- ### Setting Avatar Background Color (PHP) Source: https://github.com/lasserafn/php-initial-avatar-generator/blob/master/README.md Sets the background color of the avatar using the `background()` method. Accepts color codes like hex (`#ff0000`). ```php $image = $avatar->background('#ff0000')->generate(); ``` -------------------------------- ### Setting Avatar Size (PHP) Source: https://github.com/lasserafn/php-initial-avatar-generator/blob/master/README.md Sets both the width and height of the generated avatar image to the same value using the `size()` method. This is a convenience method for square avatars. ```php $image = $avatar->size(96)->generate(); ``` -------------------------------- ### Setting Avatar Font File (PHP) Source: https://github.com/lasserafn/php-initial-avatar-generator/blob/master/README.md Specifies the TrueType font file to use for the initials text using the `font()` method. The method searches for the file and can fall back to GD internal fonts. ```php $image = $avatar->font('/fonts/OpenSans-Semibold.ttf')->generate(); ``` -------------------------------- ### Streaming Generated Image (PHP) Source: https://github.com/lasserafn/php-initial-avatar-generator/blob/master/README.md Streams the generated Intervention Image instance as a PNG image with 100% quality. Suitable for direct output to a browser or file. ```php return $image->stream('png', 100); ``` -------------------------------- ### Setting Initials Length (PHP) Source: https://github.com/lasserafn/php-initial-avatar-generator/blob/master/README.md Specifies the number of initials to extract from the name using the `length()` method. Defaults to 2 initials. ```php $image = $avatar->name('John Doe Johnson')->length(3)->generate(); // 3 letters = JDJ ``` -------------------------------- ### Setting Font Size for PHP Avatar Generator Source: https://github.com/lasserafn/php-initial-avatar-generator/blob/master/README.md Demonstrates how to set the font size for the generated avatar using the `fontSize()` method. The value is a multiplier of the image size, where 0.5 means 50% of the image size. ```php $image = $avatar->fontSize(0.25)->generate(); // Font will be 25% of image size. ``` -------------------------------- ### Generating Avatar as SVG (PHP) Source: https://github.com/lasserafn/php-initial-avatar-generator/blob/master/README.md Initializes the generator and generates an avatar as an SVG string instead of a raster image. The `generateSvg()` method returns an SVG object which can be converted to XML. ```php $avatar = new LasseRafn\InitialAvatarGenerator\InitialAvatar(); echo $avatar->name('Lasse Rafn')->generateSvg()->toXMLString(); // returns SVG XML string ``` -------------------------------- ### Setting Avatar Font Color (PHP) Source: https://github.com/lasserafn/php-initial-avatar-generator/blob/master/README.md Sets the color of the initials text on the avatar using the `color()` method. Accepts color codes like hex (`#ff0000`). ```php $image = $avatar->color('#ff0000')->generate(); ``` -------------------------------- ### Enabling Rounded Avatar (PHP) Source: https://github.com/lasserafn/php-initial-avatar-generator/blob/master/README.md Applies a rounded mask to the generated avatar image using the `rounded()` method, making it appear circular or with rounded corners. ```php $image = $avatar->rounded()->generate(); ``` -------------------------------- ### Setting Avatar Width (PHP) Source: https://github.com/lasserafn/php-initial-avatar-generator/blob/master/README.md Sets the width of the generated avatar image in pixels using the `width()` method. The default width is 48 pixels. ```php $image = $avatar->width(96)->generate(); ``` -------------------------------- ### Setting SVG Font Name (PHP) Source: https://github.com/lasserafn/php-initial-avatar-generator/blob/master/README.md Sets the font name to be used within the generated SVG output using the `fontName()` method. This is relevant for SVG generation, not raster images. ```php $image = $avatar->fontName('Arial, Helvetica, sans-serif')->generate(); ``` -------------------------------- ### Setting Avatar Height (PHP) Source: https://github.com/lasserafn/php-initial-avatar-generator/blob/master/README.md Sets the height of the generated avatar image in pixels using the `height()` method. The default height is 48 pixels. ```php $image = $avatar->height(96)->generate(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.