mirror of
https://github.com/Intervention/image.git
synced 2025-09-08 05:00:41 +02:00
removed repeated code
This commit is contained in:
@@ -98,13 +98,19 @@ class Image
|
|||||||
if ( ! is_null($source)) {
|
if ( ! is_null($source)) {
|
||||||
|
|
||||||
if (is_resource($source)) {
|
if (is_resource($source)) {
|
||||||
|
|
||||||
|
// image properties come from gd image resource
|
||||||
$this->setPropertiesFromResource($source);
|
$this->setPropertiesFromResource($source);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
// image properties come from image file
|
||||||
$this->setPropertiesFromPath($source);
|
$this->setPropertiesFromPath($source);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
// new empty resource
|
||||||
$this->setPropertiesEmpty($width, $height, $bgcolor);
|
$this->setPropertiesEmpty($width, $height, $bgcolor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,31 +123,20 @@ class Image
|
|||||||
*/
|
*/
|
||||||
public static function make($source)
|
public static function make($source)
|
||||||
{
|
{
|
||||||
$image = new Image;
|
return new Image($source);
|
||||||
|
|
||||||
if (is_resource($source)) {
|
|
||||||
$image->setPropertiesFromResource($source);
|
|
||||||
} else {
|
|
||||||
$image->setPropertiesFromPath($source);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $image;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new empty image resource
|
* Create a new empty image resource
|
||||||
*
|
*
|
||||||
* @param int $width
|
* @param int $width
|
||||||
* @param int $height
|
* @param int $height
|
||||||
* @param mixed $bgcolor
|
* @param mixed $bgcolor
|
||||||
* @return Image
|
* @return Image
|
||||||
*/
|
*/
|
||||||
public static function canvas($width, $height, $bgcolor = null)
|
public static function canvas($width, $height, $bgcolor = null)
|
||||||
{
|
{
|
||||||
$image = new Image;
|
return new Image(null, $width, $height, $bgcolor);
|
||||||
$image->setPropertiesEmpty($width, $height, $bgcolor);
|
|
||||||
|
|
||||||
return $image;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user