/** * {@inheritdoc} */ public function load($imagePath) { if (!is_file($imagePath)) { throw new ImageNotFoundException(sprintf("File '%s' not found. Are you sure this is the right path?", $imagePath)); } $info = Imanee::getImageInfo($imagePath); $this->mime = strtolower($info['mime']); $this->width = $info['width']; $this->height = $info['height']; $this->imagePath = $imagePath; switch ($this->getMime()) { case "image/jpeg": case "image/jpg": case "image/pjpeg": case "image/pjpg": $this->format = "jpg"; $this->resource = imagecreatefromjpeg($imagePath); break; case "image/gif": $this->format = "gif"; $this->resource = imagecreatefromgif($imagePath); break; case "image/png": $this->format = "png"; $this->resource = imagecreatefrompng($imagePath); break; default: throw new UnsupportedFormatException(sprintf("The format '%s' is not supported by this Resource.", $this->getMime())); break; } return $this; }
/** * {@inheritdoc} */ public function load($imagePath) { if (!is_file($imagePath)) { throw new ImageNotFoundException(sprintf("File '%s' not found. Are you sure this is the right path?", $imagePath)); } $info = Imanee::getImageInfo($imagePath); $this->mime = strtolower($info['mime']); $this->width = $info['width']; $this->height = $info['height']; $this->imagePath = $imagePath; $this->resource = new \Imagick($this->imagePath); return $this; }