__construct — Create new instances

Description

public Intervention\Image\Image __construct([mixed $source, [int $width, [int $height, [mixed $bgcolor]]]])

Returns new Intervention Image object.

Parameters

source

Source to create an image from. Can be one of the following input types:

  • string - Path of the image in filesystem.
  • string - Binary image data.
  • resource - PHP resource of type gd.

width

Width of the canvas when created without the path parameter.

height

Height of the canvas when created without the path parameter.

bgcolor

Background color of the canvas when created without the path parameter. See what color formats are supported.

Return Values

Instance of Intervention\Image\Image

Examples

  1. // create an empty object
  2. $img = new Image;
  3. // create an object from image file
  4. $img = new Image('public/foo.jpg');
  5. // create an empty image object with transparent background
  6. $img = new Image(null, 800, 600);
  7. // create an empty image object with red background
  8. $img = new Image(null, 800, 600, '#ff0000');

See also