PHP code example of pjam / prig

1. Go to this page and download the library: Download pjam/prig 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/ */

    

pjam / prig example snippets





use pjam\prig\ImageGenerator\ImageGenerator;

returns a GdImage object that you can use for something else
$imageObject = $imageGenerator->createRandomImage(); 

// outputs the image directly to the browser, with the right header already set
$imageGenerator->outputImage($imageObject);

// returns the base64 encoded string of the image that can be used also in the src attribute of an image tag
// or saved to database, for example
$imageGenerator->getEncodedImage($imageObject);

$imageGenerator = new ImageGenerator(['height' => 20]);

$imageGenerator = new ImageGenerator(['width' => 1800]);

$imageGenerator = new ImageGenerator(['type' => 'webp']);

$imageGenerator = new ImageGenerator(['numColors' => 50]);
html
<img src="https://polar-mountain-75010.herokuapp.com/image.php">
html
<img src="https://polar-mountain-75010.herokuapp.com/image.php?height=600">
html
<img src="https://polar-mountain-75010.herokuapp.com/image.php?width=800">
html
<img src="https://polar-mountain-75010.herokuapp.com/image.php?type=jpeg">
html
<img src="https://polar-mountain-75010.herokuapp.com/image.php?numColors=2">