5 use \Intervention\Image\Image;
6 use \Intervention\Image\Size;
18 $info = @getimagesize(
$path);
20 if ($info ===
false) {
21 throw new \Intervention\Image\Exception\NotReadableException(
22 "Unable to read image from file ({$path})."
29 $core = imagecreatefrompng(
$path);
34 $core = imagecreatefromjpeg(
$path);
39 $core = imagecreatefromgif(
$path);
44 throw new \Intervention\Image\Exception\NotReadableException(
45 "Unable to read image type. GD driver is only able to decode JPG, PNG or GIF files."
51 $image->mime = $info[
'mime'];
52 $image->setFileInfoFromPath(
$path);
76 throw new \Intervention\Image\Exception\NotSupportedException(
77 "Gd driver is unable to init from Imagick object."
89 $resource = @imagecreatefromstring($binary);
91 if ($resource ===
false) {
92 throw new \Intervention\Image\Exception\NotReadableException(
93 "Unable to init from given binary data."
98 $image->mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $binary);
111 $width = imagesx($resource);
112 $height = imagesy($resource);
115 $canvas = imagecreatetruecolor($width, $height);
118 imagealphablending($canvas,
false);
119 $transparent = imagecolorallocatealpha($canvas, 255, 255, 255, 127);
120 imagefilledrectangle($canvas, 0, 0, $width, $height, $transparent);
121 imagecolortransparent($canvas, $transparent);
122 imagealphablending($canvas,
true);
125 imagecopy($canvas, $resource, 0, 0, 0, 0, $width, $height);
126 imagedestroy($resource);