public function open($imgname) { if (!is_file($imgname)) { throw new Exception("不存在的图像文件"); } empty($this->img) || $this->img->destroy(); $this->img = new Imagick(realpath($imgname)); $this->info = array("width" => $this->img->getImageWidth(), "height" => $this->img->getImageHeight(), "type" => strtolower($this->img->getImageFormat()), "mime" => $this->img->getImageMimeType()); }
/** * 打开一张图像 * @param string $imgname 图像路径 */ public function open($imgname) { //检测图像文件 if (!is_file($imgname)) { throw new Exception('不存在的图像文件'); } //销毁已存在的图像 empty($this->img) || $this->img->destroy(); //载入图像 $this->img = new \Imagick(realpath($imgname)); //设置图像信息 $this->info = array('width' => $this->img->getImageWidth(), 'height' => $this->img->getImageHeight(), 'type' => strtolower($this->img->getImageFormat()), 'mime' => $this->img->getImageMimeType()); }
/** * 获取图片宽度 */ public function getWidth() { return self::$resource->getImageWidth(); }
/** * stamp gif caution mark. * * @param resource $thumb * @return resource */ protected function _decorateGifCaution($thumb) { $deco = new Imagick(); $deco->readImage($this->getDecorateGifCautionFilePath()); $thumb->compositeImage($deco, Imagick::COMPOSITE_OVER, ($thumb->getImageWidth() - $deco->getImageWidth()) / 2, ($thumb->getImageHeight() - $deco->getImageHeight()) / 2); $deco->destroy(); return $thumb; }