PHP code example of ccharz / faker-gd-image

1. Go to this page and download the library: Download ccharz/faker-gd-image library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ccharz / faker-gd-image example snippets


$faker = \Faker\Factory::create();
$faker->addProvider(new \Faker\Provider\GdImage($faker));

// Stores a generated image in the systems tmp folder
$image_path = $faker->gdImage($dir = null, $width = 640, $height = 480);

// Returns a gd image object
$gd_image = $faker->gdImageObject($width = 640, $height = 480, $text = 'Test', $background_color = '6A6A6A');

/**
 * Register any application services.
 *
 * @return void
 */
public function register()
{
    $this->app->singleton(\Faker\Generator::class, function () {
        $faker = \Faker\Factory::create();
        $faker->addProvider(new \Faker\Provider\GdImage($faker));
        return $faker;
    });
}