canvas — Create a new empty image resource

Description

public static Intervention\Image\Image canvas(integer $width, integer $height, [mixed $bgcolor])

Static factory method to create a new empty image instance with given width and height. You can define a background-color. By default the canvas background is transparent.

Parameters

width

Width of the new image resource.

height

Height of the new image resource.

bgcolor (optional)

Optional Background-color of the image resource. Pass a color in one of the supported color formats or just leave it blank to get a transparent background.

Return Values

Instance of Intervention\Image\Image

Examples

  1. // create a new empty image resource with transparent background
  2. $img = Image::canvas(800, 600);
  3. // create a new empty image resource with red background
  4. $img = Image::canvas(32, 32, '#ff0000');

See also