public function load($filename)
{
$image_info = @getimagesize($filename);
if ($image_info) {
$this->type = $image_info[2];
switch ($this->type) {
case IMAGETYPE_JPEG:
$this->image = imagecreatefromjpeg($filename);
break;
case IMAGETYPE_PNG:
$this->image = imagecreatefrompng($filename);
break;
default:
throw new \InvalidArgumentException('Image Type not allowed.');
}
} else {
throw new \InvalidArgumentException('The file must be a valid image.');
}
}