/** * 图片处理 * * @param PwUploadAction $bhv 上传行为 * @param object 存储对象 * @return bool|PwError */ public function operateImage($bhv, $store) { $image = new PwImage($this->source); if (!$image->isImage()) { return new PwError('upload.content.error'); } if ($image->ext != 'swf') { if (!$image->getSource() && $image->ext != 'bmp') { return new PwError('upload.content.error'); } if ($bhv->allowThumb()) { $this->makeThumb($image, $bhv->getThumbInfo($this->filename, $this->savedir), $store); } if ($bhv->allowWaterMark()) { $waterinfo = $bhv->getWaterMarkInfo(); $this->watermark($image, $waterinfo); foreach ($this->_thumb as $value) { $this->watermark(new PwImage($value[0]), $waterinfo); } } $this->type = 'img'; } return true; }
public function initWaterWay() { if ($this->type == 1) { $water = new PwImage(Wind::getRealDir('REP:mark') . '/' . $this->file); if (!$water->isImage() || !$water->getSource()) { return false; } } else { if (!$this->text || strlen($this->fontcolor) != 7) { return false; } empty($this->fontfamily) && ($this->fontfamily = 'en_arial.ttf'); empty($this->fontsize) && ($this->fontsize = 12); $this->fontfile = Wind::getRealDir('REP:font') . '/' . $this->fontfamily; $temp = imagettfbbox($this->fontsize, 0, $this->fontfile, $this->text); //取得使用 TrueType 字体的文本的范围 $water = new stdClass(); $water->width = $temp[2] - $temp[6]; $water->height = $temp[3] - $temp[7]; unset($temp); } return $water; }