Grafika\Imagick\Image::createBlank PHP Method

createBlank() public static method

Create a blank image.
public static createBlank ( integer $width = 1, integer $height = 1 ) : self
$width integer Width in pixels.
$height integer Height in pixels.
return self
    public static function createBlank($width = 1, $height = 1)
    {
        $imagick = new \Imagick();
        $imagick->newImage($width, $height, new \ImagickPixel('black'));
        $imagick->setImageFormat('png');
        // Default to PNG.
        return new self($imagick, '', $imagick->getImageWidth(), $imagick->getImageHeight(), $imagick->getImageFormat());
    }

Usage Example

Beispiel #1
0
 /**
  * Create a blank image.
  *
  * @param int $width Width of image in pixels.
  * @param int $height Height of image in pixels.
  *
  * @return ImageInterface
  * @throws \Exception
  */
 public static function createBlankImage($width = 1, $height = 1)
 {
     $editorName = self::detectAvailableEditor();
     if ('Imagick' === $editorName) {
         return ImagickImage::createBlank($width, $height);
     } else {
         return GdImage::createBlank($width, $height);
     }
 }