PHP code example of boomdraw / laravel-dummy-image
1. Go to this page and download the library: Download boomdraw/laravel-dummy-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/ */
boomdraw / laravel-dummy-image example snippets
// Generate and store an image
DummyImage::put($path, $disk);
// Generate and return image as response
DummyImage::toResponse($code, $headers);
// Generate and return image as base64
DummyImage::toBase64($code, $headers);
return [
/*
* Default disk for generated image
*/
'disk' => 'local',
/*
* Default path for generated image
*/
'path' => 'dummyimage',
/*
* Additional headers for response
*/
'headers' => [
//
],
/*
* Additional html color names with hex value for name to hex convertation
*/
'color_names' => [
//'color_name' => '00ffff'
],
];
// Generate an image with custom params
$image = DummyImage::generate($dimensions = '200x1:5', $format = 'gif', $bg_color = 'ff00cc', $fg_color = '00ffcc', $text = 'I am image text');
// Generate and store an image
$image->put($path, $disk);
// Generate and return image as response
$image->toResponse($code, $headers);
// Generate and return image as base64 string
$image->toBase64($code, $headers);