Random.php
public function image($destination, $min_resolution, $max_resolution) {
    $extension = pathinfo($destination, PATHINFO_EXTENSION);
    $min = explode('x', $min_resolution);
    $max = explode('x', $max_resolution);

    $width = rand((int) $min[0], (int) $max[0]);
    $height = rand((int) $min[1], (int) $max[1]);

    // Make an image split into 4 sections with random colors.
    $im = imagecreate($width, $height);
    for ($n = 0; $n < 4; $n++) {
      $color = imagecolorallocate($im, rand(0, 255), rand(0, 255), rand(0, 255));
      $x = $width / 2 * ($n % 2);
      $y = $height / 2 * (int) ($n >= 2);
      imagefilledrectangle($im, $x, $y, $x + $width / 2, $y + $height / 2, $color);
    }

    // Make a perfect circle in the image middle.
    $color = imagecolorallocate($im, rand(0, 255), rand(0, 255), rand(0, 255));
    $smaller_dimension = min($width, $height);
    imageellipse($im, $width / 2, $height / 2, $smaller_dimension, $smaller_dimension, $color);

    $save_function = 'image' . ($extension == 'jpg' ? 'jpeg' : $extension);
    $save_function($im, $destination);
    return $destination;
  }
public function image($destination, $min_resolution, $max_resolution) {
    $extension = pathinfo($destination, PATHINFO_EXTENSION);
    $min = explode('x', $min_resolution);
    $max = explode('x', $max_resolution);

    $width = rand((int) $min[0], (int) $max[0]);
    $height = rand((int) $min[1], (int) $max[1]);

    // Make an image split into 4 sections with random colors.
    $im = imagecreate($width, $height);
    for ($n = 0; $n < 4; $n++) {
      $color = imagecolorallocate($im, rand(0, 255), rand(0, 255), rand(0, 255));
      $x = $width / 2 * ($n % 2);
      $y = $height / 2 * (int) ($n >= 2);
      imagefilledrectangle($im, $x, $y, $x + $width / 2, $y + $height / 2, $color);
    }

    // Make a perfect circle in the image middle.
    $color = imagecolorallocate($im, rand(0, 255), rand(0, 255), rand(0, 255));
    $smaller_dimension = min($width, $height);
    imageellipse($im, $width / 2, $height / 2, $smaller_dimension, $smaller_dimension, $color);

    $save_function = 'image' . ($extension == 'jpg' ? 'jpeg' : $extension);
    $save_function($im, $destination);
    return $destination;
  }
public function image ( $ destination , $ min_resolution , $ max_resolution ) { $ extension = pathinfo ( $ destination , PATHINFO_EXTENSION ) ; $ min = explode ( 'x' , $ min_resolution ) ; $ max = explode ( 'x' , $ max_resolution ) ; $ width = rand ( ( int ) $ min [ 0 ] , ( int ) $ max [ 0 ] ) ; $ height = rand ( ( int ) $ min [ 1 ] , ( int ) $ max [ 1 ] ) ; // Make an image split into 4 sections with random colors. $ im = imagecreate ( $ width , $ height ) ; for ( $ n = 0 ; $ n < 4 ; $ n ++ ) { $ color = imagecolorallocate ( $ im , rand ( 0 , 255 ) , rand ( 0 , 255 ) , rand ( 0 , 255 ) ) ; $ x = $ width / 2 * ( $ n % 2 ) ; $ y = $ height / 2 * ( int ) ( $ n >= 2 ) ; imagefilledrectangle ( $ im , $ x , $ y , $ x + $ width / 2 , $ y + $ height / 2 , $ color ) ; } // Make a perfect circle in the image middle. $ color = imagecolorallocate ( $ im , rand ( 0 , 255 ) , rand ( 0 , 255 ) , rand ( 0 , 255 ) ) ; $ smaller_dimension = min ( $ width , $ height ) ; imageellipse ( $ im , $ width / 2 , $ height / 2 , $ smaller_dimension , $ smaller_dimension , $ color ) ; $ save_function = 'image' . ( $ extension == 'jpg' ? 'jpeg' : $ extension ) ; $ save_function ( $ im , $ destination ) ; return $ destination ; }
Create a placeholder image.

@param string $destination
The absolute file path where the image should be stored.
@param int $min_resolution
@param int $max_resolution

@return string
Path to image file.
Create a placeholder image .