public function mark($img) { $options = $this->widget('Widget_Options'); $cfg = $options->plugin('Watermark'); $img1 = self::lujin(__TYPECHO_ROOT_DIR__ . base64_decode($img)); $dir = '.' . __TYPECHO_PLUGIN_DIR__ . '/Watermark/'; $ck_p = 0; $ck_t = 0; if (in_array('pic', $cfg->vm_type) && file_exists($dir . $cfg->vm_pic)) { $ck_p = 1; } if (in_array('text', $cfg->vm_type) && file_exists($dir . $cfg->vm_font)) { $ck_t = 1; } $pos_p = $cfg->vm_pos_pic; $pos_t = $cfg->vm_pos_text; $font = $dir . $cfg->vm_font; $text = $cfg->vm_text; $size = $cfg->vm_size; $color = $cfg->vm_color; $mic_x = $cfg->vm_m_x; $mic_y = $cfg->vm_m_y; $width = $cfg->vm_width; $wmpic = $cfg->vm_pic ? $cfg->vm_pic : 'WM.png'; $alpha = $cfg->vm_alpha; $file = false; if (file_exists($img1)) { require_once $dir . 'class.php'; $wm = new WaterMark(); $wm->setImSrc($img1, $width); // 设置背景图 $wm->setImWater($dir . $wmpic); // 设置水印图 $wm->setFont($font, $text, $size, $color); // 设置水印文字相关(字体库、文本、字体大小、颜色) if (isset($cfg->vm_cache) && 'cache' == $cfg->vm_cache) { $file = base64_decode($img); $ext = pathinfo($file, PATHINFO_EXTENSION); $dir_cache = __TYPECHO_ROOT_DIR__ . '/usr/img'; if (!is_dir($dir_cache)) { @mkdir($dir_cache, 0777); } //检测缓存目录是否存在,自动创建 $file = './usr/img/' . md5($file) . '.' . $ext; } $wm->mark($ck_p, $pos_p, $ck_t, $pos_t, $mic_x, $mic_y, $alpha, $file); } else { $this->widget('Widget_Archive@404', 'type=404')->render(); } }