Gregwar\Image\Image::create PHP Метод

create() публичный статический Метод

Creates an instance of a new resource.
public static create ( $width, $height )
    public static function create($width, $height)
    {
        return new static(null, $width, $height);
    }

Usage Example

Пример #1
0
 /**
  * @param string $filename
  * @param string|null $sex
  * @param bool $unfiltered
  */
 public function generate($filename, $sex = null, $unfiltered = false)
 {
     $DS = DIRECTORY_SEPARATOR;
     $parts = array('background', 'face', 'clothes', 'hair', 'eyes', 'mouth');
     if (!in_array($sex, array('male', 'female'))) {
         $sex = 1 === mt_rand(1, 2) ? 'male' : 'female';
     }
     $img = Image::create($this->size, $this->size);
     foreach ($parts as $part) {
         $images = glob(__DIR__ . $DS . 'img' . $DS . $sex . $DS . $part . $DS . '*.{jpg,jpeg,png,gif}', GLOB_BRACE);
         if (!$unfiltered) {
             $images = array_filter($images, function ($image) {
                 $path_parts = pathinfo($image);
                 return false === stristr($path_parts['filename'], 'unfiltered-');
             });
         }
         $img->merge(Image::open($images[array_rand($images)]));
     }
     $img->save($filename);
 }
All Usage Examples Of Gregwar\Image\Image::create