make — Create a new image resource

Description

public static Intervention\Image\Image make(mixed $source)

Static universal factory method to create a new image instance from source, which can be a filepath, a GD image resource or a binary image data.

Parameters

source

Source to create an image from. The method responds to the following input types:

  • string - Path of the image in filesystem.
  • string - URL of an image (allow_url_fopen must be enabled).
  • string - Binary image data.
  • resource - PHP resource of type gd.

Return Values

Instance of Intervention\Image\Image

Examples

  1. // create a new image resource from file
  2. $img = Image::make('public/foo.jpg');
  3. // create a new image from gd resource
  4. $resource = imagecreatefromjpeg('public/foo.jpg');
  5. $img = Image::make($resource);
  6. // create a new image resource from binary data
  7. $data = file_get_contents('public/foo.jpg');
  8. $img = Image::make($data);
  9. // create a new image directly from an url
  10. $img = Image::make('http://example.com/example.jpg');

See also